I have added Latitude and Longitude fields in my Leads module. The way it should work is - whenever the editview is opened, the latitude and longitude fields should get populated automatically through Javascript functions.
I have done the following but it doesn’t seem to work -
- added the following to custom/modules/Leads/metadata/editviewdefs.php
'includes'=> array(
array('file'=>'custom/modules/Leads/latlong.js'),
),
- Created a js file named latlong.js in ‘custom/modules/Leads/’ and put the following code there -
function initGeolocation(){
if( navigator.geolocation ){
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition( success, fail );
}
else{
alert("Sorry, your browser does not support geolocation services.");
}
}
function success(position){
document.getElementById('jjwg_maps_lng_c').value = position.coords.longitude;
document.getElementById('jjwg_maps_lat_c').value = position.coords.latitude;
}
function fail(){
// Could not obtain location
}
- Did Quick Repair and Rebuild and opened the edit view for Leads module.
But it doesn’t work. The latitude and longitude fields are still populated with a default value of 0.00000000
Can anyone tell me what am I doing wrong? I have just started working on SuiteCRM. So would need a little helping hand here.
Thanks.