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.

  2. Karina says:

    Hi, I have the same issue that Bruce had. The hyperlink is working but image is not showing. Any ideas how to solve this?

    Thankyou!

    • Tom says:

      Can you share your formula – also, want to make sure you are using this on the page layout of a record (it won’t work in places like quick actions, related lists, etc).

  3. Bruno says:

    NO MAP AVAILABLE!

    FORMULA THAT I USED:
    Site_Street__c +BR()+Site_City__c + “,” + Site_State__c + “,” + Site_Zip__c + BR()+
    HYPERLINK(“http://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))

  4. Yvonne says:

    Hi!

    I have the same issue …no image available. I use the following formula:

    Ship_to_Street__c & BR()
    & Ship_to_Postal_Code__c & ” ” & Ship_to_City__c & BR()
    & Ship_to_Country__c
    + HYPERLINK(“https://www.google.com/maps/place/”+ Ship_to_Street__c +”,”+ Ship_to_City__c +”,”+ Ship_to_Postal_Code__c, IMAGE(“http://maps.google.com/maps/api/staticmap?center&markers=color:red|=”+ Ship_to_Street__c +”,”+ Ship_to_City__c +”,”+ Ship_to_Postal_Code__c + “&zoom=15&size=310×175&markers=color:red|” + “&sensor=false&format=png32” , “no map available”, 175, 310))

    The link works as well as the text in my formula field, just not the image (I also get the broken icon). When I right click the link and choose “open image in new tab”, it states:

    “The Google Maps Platform server rejected your request. Invalid request. Invalid ‘size’ parameter.”

    Any ideas? Would really like this to work!

  5. Thomas Garcia says:

    What anyone ever able to fix the no image showing issue? I’m having the same error. My formula is below.

    MeetingStreet__c +BR()+MeetingCity__c + “,” + MeetingState__c + “,” + MeetingPostalCode__c + “,” + MeetingCountry__c + BR()+
    HYPERLINK(“http://www.google.com/maps/place/”+ MeetingStreet__c +”,”+ MeetingCity__c +”,”+ MeetingState__c +”,”+ MeetingPostalCode__c +”,”+ MeetingCountry__c,
    IMAGE(“http://maps.google.com/maps/api/staticmap?center&markers=color:red|=”+ MeetingStreet__c + MeetingCity__c + MeetingState__c + MeetingPostalCode__c + MeetingCountry__c +
    “&zoom=15&size=310×175&markers=color:red|” + “&sensor=false&format=png32” , “no map available”, 175, 310))

  6. carly probasco says:

    Greetings! I am receiving the same ‘no map available’, any solution to this?
    Physical_Street__c +BR()+
    Physical_City__c + “, ” + TEXT(Physical_State__c) + ” ” + Physical_Zip__c + BR()
    +HYPERLINK(“https://www.google.com/maps/place/”+Physical_Street__c+’,’+Physical_City__c+’,’+TEXT(Physical_State__c)+’,’+Physical_Zip__c, IMAGE(“http://maps.google.com/maps/api/staticmap?center&markers=color:red|=”+ Physical_Street__c + Physical_City__c + TEXT(Physical_State__c) + Physical_Zip__c + “&zoom=15&size=310×175&markers=color:red|” + “&sensor=false&format=png32” , “no map available”, 175, 310))

  7. Avadhut says:

    Hi Tom,

    I was referring to your “Add Clickable Google Map to Custom Address Field”, my client is asking to have a Google Map created on Opportunity page using the Account billing address.
    Could you please help me.

  8. Megha says:

    I used the same formula and its showing map image as broken and its not clickable. I understand Google API key is no w a paid feature. So I added API key in the formula and its still not working.

    Here is the formula
    HYPERLINK( “https://www.google.com/maps/place/”+ cep_Street_Number_of_Loss__c +”,”+ cep_Street_Of_Loss__c +”,”+ cep_City_Of_Loss__c +”,,” + cep_Postal_Code_Of_Loss__c,

    IMAGE(“https://maps.google.com/maps/api/staticmap?key=AIzaSyDWnBOxsEh8KPWlFPaYAR9-HfNXCzUQxjo&center&markers=color:red|=”+ cep_Street_Number_of_Loss__c + cep_Street_Of_Loss__c +
    cep_City_Of_Loss__c + cep_Postal_Code_Of_Loss__c + “&zoom=15&size=310×175&markers=color:red|” + “&sensor=false&format=png32” , “Take me to Google Maps”,
    175, 310))

    Can anyone please assist?

Leave a Reply to Karina Cancel reply

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