Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • 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
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • 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
    • Marketplace
    • Advertise With Us
    • 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 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

    • 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

    application solution

    Popular Salesforce Blogs

    Common Salesforce User Engagement Issues In The Workplace

    Blog in Salesforce

    The success of the Salesforce implementation depends on how efficiently its end users are using the platform. Any Salesforce user engagement issues can cause serious…

    Business Challenges, Business Owners, Business Process, Certified Salesforce Consultants, Chart Sales Growth
    360 Degree Jul 5, 2021
    1,749  Views

    Top 6 Qualities of Salesforce Consulting Partners to Look Out For in 2024

    Blog in Others

    When it comes to CRM, anywhere we go in India or across the globe, everywhere we see Salesforce and Salesforce consulting partners We all know what Salesforce…

    AppExchange, Best Salesforce Partner, Blueprint of Process, Compatibility, Consulting Partners
    Codleo Dec 27, 2023
    1,363  Views

    Hellstar Builds a Community of Bold Dressers

    Blog in Sales

    Hellstar Shapes a Distinct Fashion Identity Explore the latest in bold streetwear and innovative fashion trends at officialhellstr.com, where style meets rebellion. Hellstar builds a…

    towami6310 Jan 20, 2026
    12  Views

    Popular Salesforce Videos

    Creating Multi Screen Wizard Using Apex and Visualforce Salesforce

    Creating Multi Screen Wizard Using Apex and Visualforce Salesforce

    Video in Visualforce, Salesforce Apex, Salesforce Training

    Watch this video to learn how to create a Multi-screen wizard using Apex and Visualforce Salesforce. If you have any questions do let us know…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, salesforce, Apex
    Abhishek May 28, 2021
    2,051  Views
    What is a Salesforce Admin?

    What is a Salesforce Admin?

    Video in Salesforce Admin

    Salesforce administrators are the gatekeepers of their employer's sales and marketing data. They create each user account and determine the proper level of access based…

    Salesforce Training, Salesforce Admin, Salesforce Video, sales, Salesforce Learning
    Abhai Deep Jun 18, 2020
    1,753  Views
    Clean Code in Salesforce | Code Review

    Clean Code in Salesforce | Code Review

    Video in Others, Salesforce Stories

    We spend more time reading our code than writing it. So doesn't it make sense that our code is clean, precise, and easy to read?…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Clean Code in Salesforce
    Jogender Jun 30, 2020
    1,692  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®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.