function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chandra PrakashChandra Prakash 

Google Map is not working in VisualForce page

Hi,

I have write code for Google Map integration there is Google_map__c is Custom object
i wnat to desplay Google map in Custom object but it not working

below you can see code.

<apex:page standardController="Google_Map__c">

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var map;
var mapOptions = {
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP,mapTypeControl: false
}
var mapMarker;
var geocoder = new google.maps.Geocoder();
var address = "{!SUBSTITUTE(JSENCODE(Google_Map__c.BillingStreet__c),'\r\n',' ')}, " + "{!Google_Map__c.BillingCity__c}, " + "{!Google_Map__c.BillingPostalCode__c}, " + "{!Google_Map__c.BillingCountry__c}";
geocoder.geocode( {address: address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK && results.length)
{
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map = new google.maps.Map(document.getElementById("map"),mapOptions);
map.setCenter(results[0].geometry.location);
mapMarker = new google.maps.Marker({
position: results[0].geometry.location,map: map,title: "{!Google_Map__c.Name} " + address});
}
}
else
document.getElementById("map").innerHTML = "Unable to find or display a map for {!Google_Map__c.Name}'s billing address : " + address;
});
}
</script>
<div id="map" style="width:100%;height:300px"></div>
<script>
initialize();
</script>
</apex:page>


If any buddy done this code please share with me ...
Thanks.
SFDC_DevloperSFDC_Devloper
Hi Prakash,

   I hope below link help you!

https://success.salesforce.com/answers#!/feedtype=SINGLE_QUESTION_DETAIL&dc=All&criteria=BESTANSWERS&id=90630000000guBkAAI (https://success.salesforce.com/answers#!/feedtype=SINGLE_QUESTION_DETAIL&dc=All&criteria=BESTANSWERS&id=90630000000guBkAAI)



Thanks,
Rockzz