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
Michael Hedrick 2Michael Hedrick 2 

Save latitude and longitude to record

Hello,
Been trying to figure out how to save the latitude and latitude of the users current location when they save a custom record via a visualforce page.  I was able to use 
document.getElementById('startLat').value=startPos.coords.latitude;

and this would grab the latitude but I have not been able to save the value to the record. 

Is there a better way to aquaire the Lat and long of a users current location when the record is created and then saving the lat and long to the custom record.  
Thanks
Best Answer chosen by Michael Hedrick 2
Maharajan CMaharajan C
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000IItNQAW

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Michael,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

https://www.thephani.com/how-to-save-current-location-using-visualforce-pages/

https://salesforce.stackexchange.com/questions/138429/how-to-get-current-user-geo-locationlongitude-latitude

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Michael Hedrick 2Michael Hedrick 2
Hello Khan,
Thank you for teh reply.  I am actually suing something similiar to your first example and I am able to retrieve the lat and long but unable to pass the values to the custom record.
The second example is unclear to me.  Are the new fields shown in step 2.  !latt and !longt ?
Are they actually geo code fields or number fields with decimals?  Not sure where these fields are defined.

Thanks
 
Maharajan CMaharajan C
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000IItNQAW
This was selected as the best answer