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

    Process Builder in Salesforce

    Learn All About Process Builder in Salesforce and Its Features

    Blog in Salesforce Apex

    Would you like to make a record for any item from a work process? Would you like to call your Apex class from a work…

    Business Measures, Canvas, Catch Bar, Client, clone
    rajesh andani Sep 30, 2021
    3,404  Views

    Safer Data Migration With Salesforce Audit Fields

    Blog in Others

    In the last decade, companies have made a huge switch from legacy, on-premise servers to cloud-based applications. This shift has had lots of benefits — increased flexibility,…

    API, Application, Archived Data, Audit Field Function, Audit Fields
    Netwrix Jan 21, 2022
    3,421  Views

    9 Common Business Problems Solved via Salesforce Consulting Services: Full Guide

    Blog in Salesforce

    9 Common Business Problems Solved via Salesforce Consulting Services: Full Guide Introduction: Get the Key to Business Growth with Salesforce Consulting Services The modern company is under…

    Salesforce Consulting Services, Salesforce CRM, Salesforce to Salesforce Integration
    AwsQuality Aug 1, 2025
    145  Views

    Popular Salesforce Videos

    2020 Salesforce Admin Certification - Lightning Knowledge Base Setup

    2020 Salesforce Admin Certification - Lightning Knowledge Base Setup

    Video in Salesforce Certifications

    A Salesforce Admin Certification is the highest form of recognition a Salesforce Administrator can achieve; it demonstrates expertise in the field as well as a…

    Salesforce Certification, Salesforce Lightning, Salesforce Administrator, Salesforce Admin, Salesforce Video
    Abhishek Oct 16, 2020
    2,102  Views
    Getting started with Salesforce integration patterns using MuleSoft

    Getting started with Salesforce integration patterns using MuleSoft

    Video in Salesforce Integration

    Learn how to develop different integration patterns between Salesforce and external systems. You can read the full tutorial, and download the project jar file by…

    Salesforce Training, Salesforce Integration, Salesforce Video, #integration, Salesforce Learning
    Neha Yadav Jul 31, 2020
    2,281  Views
    Algoworks All Set To Attend French Touch Dreamin’ 2019!

    Algoworks All Set To Attend French Touch Dreamin’ 2019!

    Video in Events

    French Touch Dreamin’ 2019 is right around the corner and Team Algoworks is going to attend this European Salesforce community-led event which is going to…

    Salesforce Partner, salesforce services, Salesforce Event, Salesforce Consulting, Salesforce Video
    Algoworks Sep 13, 2019
    1,801  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.