Add Clickable Google Map to Custom Address Field

Was responding to questions in the Answer Community today and this one came up from former co-worker Richard Henry.

This was his idea, I merely assisted in figuring out the formula, but it was such a great use case had to write it up! I’ve seen formulas to add Google Map images to custom addresses, but this formula takes it a step further, allowing you make those images clickable and load within Google Maps.

First – create your 4 custom address fields (or 5 if you want to specify country). In this case, I created four on my custom object, ‘Campsite.’

Next add the following in a formula text field (replace my api names for your own) if you want to display the address above the image:

Site_Street__c +BR()+Site_City__c + ‘, ‘ + Site_State__c + ‘ ‘ + Site_Zip__c + BR()+HYPERLINK(‘https://www.google.com/maps/place/’+ Site_Street__c +’,’+ Site_City__c +’,’+ Site_State__c +’,’+ Site_Zip__c, IMAGE(‘http://maps.google.com/maps/api/staticmap?center&markers=color:red|=’+ Site_Street__c + Site_City__c + Site_State__c + Site_Zip__c + ‘&zoom=15&size=310×175&markers=color:red|’ + ‘&sensor=false&format=png32’ , ‘no map available’, 175, 310))

The result will be a formatted address displayed above a static google map image on your page AND that image is clickable, taking you to the google map site.  See below – this state park & campground happened to be my very first job at 14 years old – I rode my bike 6 miles each direction so I can save up enough money to buy a beat-up, brown two-tone 1985 Pontiac 6000 when I turned 16.

When you click on the image it takes you to the google maps site.

 

 

Or this one if you just want the clickable image:

HYPERLINK(‘https://www.google.com/maps/place/’+ Site_Street__c +’,’+ Site_City__c +’,’+ Site_State__c +’,’+ Site_Zip__c, IMAGE(‘http://maps.google.com/maps/api/staticmap?center&markers=color:red|=’+ Site_Street__c + Site_City__c + Site_State__c + Site_Zip__c + ‘&zoom=15&size=310×175&markers=color:red|’ + ‘&sensor=false&format=png32’ , ‘no map available’, 175, 310))

The result will be a static google map image on your page AND that image is clickable, taking you to the google map site.

 

 

This next one is for Andrés Gluecksmann – obviously it’s still flawed, but its a little closer to the dream – be sure to click the link & keep voting for this idea!

Create a quick action, type ‘Update a Record’ and add your 4 address fields to the page layout, give it a label like ‘Update Address.’  Add it to the page layout, remove your address fields from the main page layout and then use the formula that displays the address block above the map:

Site_Street__c +BR()+Site_City__c + ‘, ‘ + Site_State__c + ‘ ‘ + Site_Zip__c + BR()+HYPERLINK(‘https://www.google.com/maps/place/’+ Site_Street__c +’,’+ Site_City__c +’,’+ Site_State__c +’,’+ Site_Zip__c, IMAGE(‘http://maps.google.com/maps/api/staticmap?center&markers=color:red|=’+ Site_Street__c + Site_City__c + Site_State__c + Site_Zip__c + ‘&zoom=15&size=310×175&markers=color:red|’ + ‘&sensor=false&format=png32’ , ‘no map available’, 175, 310))

This also works for incomplete addresses, see my example using Yellowstone National Park:

Comments

  1. Bruce says:

    I tried this today in sandbox, and never got an image. I get, “no map available” with just a small thumbnail. It is clickable, & goes where desired, but no image.

    I tried adding in API key in the image url, but no go. Any suggestions (My State__c field is a picklist & I’m pulling that in via TEXT(State__c) . Again – the link works, but no image.

Leave a Reply

Your email address will not be published. Required fields are marked *