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, 2 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

    • 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

    experience cloud

    All You Need to Know About Salesforce Experience Cloud

    Blog in Salesforce Products

    In April 2021, Salesforce decided to change its Community Cloud for a more modern service. The need to move over to the digital world has…

    Applications, Boost Sales, Business Flows, Business Process, Campaigns
    SkyPlanner Apr 5, 2022
    3,452  Views

    Introduction to Salesforce Experience Cloud

    Blog in Salesforce

    We now live in a fast-moving digital era, where businesses compete for top-notch customer experience on various points of service in operation. In this industry,…

    Business Goals, Cloud Computing, CRM, CRM Analytics, CRM Solutions
    TechForce Jun 18, 2024
    687  Views

    A Comprehensive Guide for Small and Medium Businesses on Data Migration to Salesforce

    Blog in Others

    This article is tailored for businesses that embark on a journey toward digital transformation and navigate the complex path of migrating to the cloud, prompted…

    Custom Objects, Data Analysis, Data Cleaning, Data Cleanup, Data Discrepancies
    Vimera | Andersen Apr 4, 2024
    676  Views

    Popular Salesforce Videos

    Introduction to Salesforce CTA Exam

    Introduction to Salesforce CTA Exam

    Video in Salesforce Certifications

    The average salary for a Technical Architect is $118,324 per year in the United States. Do you also want to become Technical Exam by cracking…

    Salesforce Training, Salesforce Tutorial, Salesforce Certification, salesforce, Salesforce Video
    S2 Jan 25, 2022
    1,974  Views
    Salesforce Winter '21 Highlights

    Salesforce Winter '21 Highlights

    Video in Salesforce Stories

    Even in these unprecedented times when the world is struggling with a major pandemic that has brought everything to a standstill, Salesforce has strived hard…

    salesforce, User Experience, Salesforce Video, Salesforce Learning, Salesforce Release
    Rupal Kakkar Oct 8, 2020
    1,881  Views
    Salesforce Platform Quick Tip: How to Use Einstein Search

    Salesforce Platform Quick Tip: How to Use Einstein Search

    Video in Salesforce Training

    Want to improve your searches in Salesforce, and make them faster and more intuitive? In part one of this 2 part series, Trailblazer and Salesforce…

    Salesforce Training, Salesforce Tutorial, Salesforce Administrator, salesforce platform, Salesforce Einstein
    Prafull Oct 22, 2021
    1,806  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.