Toggle Side Panel

  • Blogs
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Display related contacts in google map for an account in salesforce

    Tagged: Account, Contact Record, Google Map, Help & Training, Salesforce Development

    • Salesforce® Discussions

      Display related contacts in google map for an account in salesforce

      Posted by Kumar on January 30, 2017 at 11:58 AM

      Hi all,

      How can we display related contacts in google map for an account?

      Any help is appreciated. Thanks

      Vikas Kumar replied 9 years, 7 months ago 3 Members · 2 Replies
      • Account
      • Contact Record
      • Google Map
      • Help & Training
      • Salesforce Development
    • 2 Replies
    • sushant

      Member
      January 31, 2017 at 1:50 PM

      Hi Kumar,

      Follow this link,it may help you.

      Thanks

    • [adinserter block='9']
    • Vikas Kumar

      Member
      January 31, 2017 at 1:50 PM

      Hi Kumar,

      <apex:page standardController="Account" extensions="ContactsOnGoogleMapController" showHeader="false" sidebar="false" standardStylesheets="false">

      <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

      <script type="text/javascript">
      var mapicon = JSON.parse('{!contactJson}');
      var url = '';

      window.onload = function () {
      LoadMap();
      }
      function LoadMap() {
      var mapOptions = {
      center: new google.maps.LatLng(mapicon[0].lat, mapicon[0].lng),
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var infoWindow = new google.maps.InfoWindow();
      var latlngbounds = new google.maps.LatLngBounds();
      var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);

      for (var i = 0; i < mapicon.length; i++) {
      var data = mapicon[i]
      var myLatlng = new google.maps.LatLng(data.lat, data.lng);

      var image = {
      url: data.icon,
      size: new google.maps.Size(100, 65),
      origin: new google.maps.Point(0, 0),
      anchor: new google.maps.Point(17, 34),
      scaledSize: new google.maps.Size(65, 65)
      };

      if('null' == data.email){
      var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title: data.title,
      icon: image,
      contact: data.contact
      });
      }

      else{
      var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title: data.title,
      contact: data.contact
      });
      }
      (function (marker, data) {
      google.maps.event.addListener(marker, "click", function (e) {
      url = 'https://roopamalgo-dev-ed.my.salesforce.com/'+data.Id;
      infoWindow.setContent("<div style = 'width:100%;height:40%'><img width='60px' height='60px' align = 'middle' src = '" + data.icon + "' />&nbsp;&nbsp;<b>"+ data.title + "<b/><br/><a href='#' onclick='event.preventDefault();popup(url)';>LINK</a><br/>"+data.address+"</div>");
      infoWindow.open(map, marker);
      });
      })(marker, data);
      latlngbounds.extend(marker.position);
      }

      map.setCenter(latlngbounds.getCenter());
      map.fitBounds(latlngbounds);
      }

      function popup(url)
      {
      newwindow=window.open(url,'name','width=830,height=600,top=0,toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=yes,left=60,screenX=350,top=100,screenY=100');
      if(window.focus){
      newwindow.focus();
      }
      url = '';
      }

      </script>

      <div id="dvMap" style="width: 100%; height: 300px">
      </div>

      </apex:page>

       

      Controller

      public class ContactsOnGoogleMapController {

      public String contactJson{get;set;}
      private Account acct;

      public ContactsOnGoogleMapController(ApexPages.StandardController controller){

      this.acct = (Account)controller.getRecord();
      List<Contact> conList = [select Id,Name,Email,Phone,GoogleLatitude__c,GoogleLongitude__c,MailingLatitude,MailingLongitude,MailingStreet,MailingCity,MailingState,MailingCountry,PhotoUrl from Contact where accountId = :acct.Id];

      String baseURL = 'https://ap2.salesforce.com';
      String coma = '';

      if(conList.size() > 0){
      contactJson = '[';

      for(Contact con : conList){
      contactJson += coma + '{\"title\":\"' + con.Name + '\",'+
      '\"lat\": \"' + con.GoogleLatitude__c + '\",'+
      '\"lng": \"' + con.GoogleLongitude__c +'\",'+
      '\"address\": \"' + con.MailingStreet +' '+ con.MailingCity +'<br/>'+ con.MailingState + '<br/>' +con.MailingCountry + '\",'+
      '\"contact\": \"' + con.Phone + '\",'+
      '\"email\": \"' + con.Email + '\",'+
      '\"Id\": \"' + con.Id + '\",'+
      '\"icon\": \"' + baseURL +''+ con.PhotoUrl + '\"}';

      coma = ',';
      }

      contactJson += ']';

      }
      }
      }

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    Popular Salesforce Blogs

    3 Tactics to Optimize Your Salesforce Implementation

    Blog in Salesforce Implementation

    Salesforce implementation requires substantial planning and investment. While most businesses invest heavily during the implementation phase, only a significant proportion of them reap above satisfactory…

    Application Components, Business Executives, Business Goals, Business Potential, Business Process
    Jessica Anderson Mar 15, 2022
    4,440  Views

    Top Salesforce Features for the Next Marketing Strategy of Your ECommerce Business

    Blog in Salesforce

    These are the times when a user decides to visit your e-commerce website, his journey starts right there. What’s next is your job to make…

    Artificial Intelligence-based Technologies, Automated Responses, Case Communication, Customer, e-commerce Website
    360 Degree Apr 12, 2022
    2,290  Views

    5 Ways Personalized Salesforce Customer Portal Brings Businesses and Customers Closer

    Blog in Salesforce

    Whether you are in the hospitality, logistics, or education business, a customer portal solution helps you deal with several challenges. To be precise, a personalized…

    Customer Behavior, Customer Behavior Analysis, Customer Engagement, Customer Experience, Customer Satisfaction
    CRMJetty Jun 19, 2024
    918  Views

    Popular Salesforce Videos

    Salesforce Integration with Heroku

    Salesforce Integration with Heroku

    Video in Salesforce Integration

    You can integrate Heroku and the Salesforce Platform in several ways, and choosing among them comes down to understanding your requirements and the capabilities of…

    Salesforce Online Training, Salesforce Integration, Salesforce Consulting, Salesforce Integration Consultant, Best Salesforce Tutorials
    Abhay Mar 21, 2018
    2,083  Views
    Salesforce Billing and Cryptocurrency

    Salesforce Billing and Cryptocurrency

    Video in Others, Salesforce Stories

    THE GOAL: In this video, you're going to learn how Cryptocurrencies can work with Salesforce Billing. ☝️ BEFORE YOU BEGIN, KNOW THIS: 1. In terms…

    salesforce, Salesforce Video, Business, Salesforce Billing, Cryptocurrency
    Jogender Jul 6, 2020
    1,641  Views
    Overview of Salesforce Development Course

    Overview of Salesforce Development Course

    Video in Salesforce Training, Salesforce Development

    In this video, Shrey has given a detailed overview of the Salesforce development training. You will learn the following topics from this course: Apex basics…

    Salesforce Training, Salesforce Certification, Salesforce Developer, Visualforce, Learn Salesforce Development
    S2 Dec 14, 2021
    2,883  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.