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
MattiasNordin.ax607MattiasNordin.ax607 

Updated google maps lat lang on save button (execute javascript)

 

I would like to add a custom build google maps application in sales force. I need my accounts to have the google maps lat lang data stored in a field. The following javascript function returns that data. How can i embed this script and have it executed everytime an account is saved?

 

 

[code] 

<script>

var geocoder;
function funReturnCoordFromAddress(address) {
 if (geocoder) {
  geocoder.geocode(
   {'address': address}, function(results, status){
   if (status == google.maps.GeocoderStatus.OK) {
    
    map.setCenter(results[0].geometry.location);
    
    var marker = new google.maps.Marker({
     map: map, 
     position: results[0].geometry.location
    });
   
    
    //alert(results[0].geometry.location)
    
    document.getElementById("target").value = results[0].geometry.location
    //return results[0].geometry.location
 
   }else{
    alert("Geocode was not successful for the following reason: " + status);
   }
  });
    }

}


</script>

[/code]