Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Can I change the Google Map Marker Color in the Apex Code?

Asked by Amit Verma Apr 24, 2021 1.2K views 1 answer
Share

About this question

I want to be able to change the "Nearby Accounts" that will pop up when you click on the button "Show Nearby Accounts" to be a different color than the account that you are originally looking at. Is this possible?

 [removed][removed] <style> body, html { height: 100%; width: 100%; } #nearbyAccountsPage, .ui-content, #map_canvas { width: 100%; height: 100%; padding: 0; } </style> [removed] var map; var lat = {!account.Geolocation__Latitude__s}; var lng = {!account.Geolocation__Longitude__s}; var accountName = "{!account.Name}"; var accountbillingstreet = "{!account.billingstreet}"; var accountbillingcity = "{!account.billingcity}"; var accountbillingstate = "{!account.billingstate}"; var accountbillingpostalcode = "{!account.billingpostalcode}"; $[removed]('pageshow', '#nearbyAccountsPage', function() { initGmap(); }); function initGmap() { var latlng = new google.maps.LatLng(lat, lng); var mapOptions = { center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, zoom: 13, // The following options are added to optimize for mobile screens. mapTypeControl: false, streetViewControl: false, scaleControl: false, rotateControl: false, panControl: false, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL, position: google.maps.ControlPosition.LEFT_TOP } }; map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); createMarkerAndInfoWindow(accountName, latlng); } function createMarkerAndInfoWindow(accountName, latlng) { var marker = new google.maps.Marker({ position: latlng, title: accountName, map: map, }); var infoWindow = new google.maps.InfoWindow({ content: '' + accountName + '' }); google.maps.event.addListener(marker, 'click', function() { infoWindow.open(map, marker); }); } function getNearbyAccounts() { NearbyAccountsController.getNearbyAccounts(lat, lng, function (result, event) { if (event.status) { for (i = 0; i < result xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed>' + acctBillingStreet + '
' + acctBillingCity + ', ' + acctBillingState + ' ' + acctBillingPostalCode, acctLatlng); } } }); } [removed]
' + acctBillingCity + ', ' + acctBillingState + ' ' + acctBillingPostalCode, acctLatlng); } } }); } [removed]
Show Nearby Here is what it looks like now when you click on "Show Accounts." The red dot with the balloon that says United Hospital I want to be red, but all of the accounts surrounding it I want to be a different color. enter image description here
<style> body, html { height: 100%; width: 100%; } #nearbyAccountsPage, .ui-content, #map_canvas { width: 100%; height: 100%; padding: 0; } </style>

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.