Lobster_Shell__c.Name - is the name of the item Lobster_Shell__c.Longitude__c - is the Longtitude value Lobster_Shell__c.Latitude__c - is the Latitude value At present the developer error console on chrome says something like - js:51 InvalidValueError: in property location: not a LatLng or LatLngLiteral: not an Object Does anyone know whats going wrong here or what the correct code would be so i can get this working? -thanks,", "answerCount": 1, "upvoteCount": 0, "datePublished": "2018-11-22T10:45:38.000Z", "author": { "@type": "Person", "name": "Lewis Davies", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DrPMeQAN", "affiliation": { "@type": "Organization", "name": "Lobster Pictures" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Hi Lewis,   In case you don't receive a response here, may I also suggest joining the developer's forum below to collaborate with the experts on best practice and advice.   https://developer.salesforce.com/forums?dc=Apex_Code_Development#!/feedtype=RECENT&criteria=ALLQUESTIONS&   Thanks,   Bhavin    ", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A97QkSAJ", "datePublished": "2019-02-11T20:41:58.000Z", "author": { "@type": "Person", "name": "Bhavin Patel", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DOBa3QAH", "affiliation": { "@type": "Organization", "name": "Salesforce" } } } ] } } Skip to main content
Hi all,

 

Im really hoping someone can help as Ive been scratching my head obver this one for days.

 

Ive successfully added a gogole maps integration to an object using the below guide -

 

https://eshopsync.com/integrate-google-map-api-salesforce-2/

 

This worked great on my account page and would geocode a cusatomer address information perfectly.

 

I then had a requirement to add a map to a custom object that would geocode the longtitude and latitude values present on the object. However this doesnt appear to be working.

 

Below is the code ive used (blanked out google api key)

 

<apex:page standardController="Lobster_Shell__c">

 

<head>

 

<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXX"></script>

 

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

 

<script type="text/javascript">

 

$(document).ready(function() {

 

var myOptions={ zoom: 15,mapTypeId: google.maps.MapTypeId.ROADMAP,mapTypeControl: false };

 

var map;

 

var marker;

 

var geocoder = new google.maps.Geocoder();

 

var latlng="{!Lobster_Shell__c.Latitude__c},{!Lobster_Shell__c.Longitude__c}";

 

var infowindow = new google.maps.InfoWindow({

 

content: "<b>{!Lobster_Shell__c.Name}</b><br>{!Lobster_Shell__c.Latitude__c}<br>{!Lobster_Shell__c.Longitude__c}"

 

});

 

 

 

geocoder.geocode( {location: latlng}, function(results, status) {

 

if (status == google.maps.GeocoderStatus.OK&&results.length) {

 

if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

 

 

 

//create map

 

map = new google.maps.Map(document.getElementById("map"), myOptions);

 

 

 

//center map

 

map.setCenter(results[0].geometry.location);

 

 

 

//create marker

 

marker = new google.maps.Marker({

 

position: results[0].geometry.location,

 

map: map,

 

title: "{!Lobster_Shell__c.Name}"

 

});

 

        

 

//add listeners

 

google.maps.event.addListener(marker, 'click', function() {

 

infowindow.open(map,marker);

 

});

 

google.maps.event.addListener(infowindow, 'closeclick', function() {

 

map.setCenter(marker.getPosition());

 

});

 

}

 

} else {

 

$('#.map').css({'height' : '15px'});

 

$('#.map').html("Oops! {!Lobster_Shell__c.Name}'s address could not be found, please make sure the address is correct.");

 

resizeIframe();

 

}

 

});

 

 

 

function resizeIframe() {

 

var me = window.name;

 

if (me) {

 

var iframes = parent.document.getElementsByName(me);

 

if (iframes&&iframes.length == 1) {

 

height = document.body.offsetHeight;

 

iframes[0].style.height = height + "px";

 

}

 

}

 

}

 

});

 

</script>

 

<style>

 

#.map {

 

font-family: Arial;

 

font-size:12px;

 

line-height:normal !important;

 

height:450px;

 

background:transparent;

 

}

 

</style>

 

</head>

 

<body>

 

<div id="map"></div>

 

</body>

 

</apex:page>

 

Lobster_Shell__c.Name - is the name of the item

 

Lobster_Shell__c.Longitude__c - is the Longtitude value

 

Lobster_Shell__c.Latitude__c - is the Latitude value

 

At present the developer error console on chrome says something like - js:51 InvalidValueError: in property location: not a LatLng or LatLngLiteral: not an Object

 

Does anyone know whats going wrong here or what the correct code would be so i can get this working?

 

-thanks,

 

 
1 件の回答