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

    schedule apex

    Schedule Apex in Salesforce | Apex Developer Guide

    Blog in Others, Salesforce Apex

    Schedule Apex in Salesforce If you want to run apex classes at a specific time then we use schedule apex. If you want to schedule…

    Batch Apex, CODING, DML Operations, Execute Method, Public Class
    Kirandeep Aug 24, 2020
    30,221  Views

    Maximizing Efficiency: Exploring Related Lists with PWR Components

    Blog in Others

    Introduction Salesforce, renowned for its CRM capabilities, faces limitations in managing intricate business scenarios, particularly in e-commerce. Traditional Salesforce-related lists struggle with dynamic data and…

    Bundle Compositions, Business Scenario, Commerce Platforms, Complex Scenarios, CRM
    noKodr Mar 7, 2024
    909  Views
    Salesforce Business Process

    Salesforce Business Processes - Learn Here!

    Blog in Salesforce

    Salesforce is a leading customer relationship management (CRM) platform that helps businesses streamline and automate various processes. With its wide range of tools and features,…

    Automation, Business Processes, Collaboration, Collaboration and Communication, Communication
    SELCUK Dec 16, 2022
    1,706  Views

    Popular Salesforce Videos

    Salesforce Certifications 2022 | Which Certifications You Need & Why You Need Them

    Salesforce Certifications 2022 | Which Certifications You Need & Why You Need Them

    Video in Salesforce Certifications

    If you’re looking to start a Salesforce job this year you’re going to need a Salesforce certification. But where do you start, which certification should…

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, Salesforce Careers, Salesforce Certification
    Vivek Feb 3, 2022
    2,233  Views
    Meet the Salesforce Singapore Small Business Relief Grants Recipients

    Meet the Salesforce Singapore Small Business Relief Grants Recipients

    Video in Salesforce Stories

    Small businesses are the heart of our community and the driver of the economy. Salesforce and Singapore Business Federation are pleased to announce the successful…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Community, Salesforce Video
    Nauman Apr 2, 2021
    1,900  Views
    Three Quick Wins With Pardot | Salesforce

    Three Quick Wins With Pardot | Salesforce

    Video in Salesforce Products

    Discover the full suite of B2B marketing automation tools to create meaningful connections, generate more pipeline, and empower sales teams to close more deals. See…

    Salesforce Training, salesforce, Marketing Automation, Salesforce Video, Salesforce Learning
    Pooja Sep 22, 2020
    2,403  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.