You need to sign in to do that
Don't have an account?
Rocks_SFDC
How to get the Latitude and Longitude of a Current Location
Hi Team,
How can we get the lat and long of a current address automatically by using apex code.
Do we have any standard methods to retrieve those valuse.
Thanks,
Anil
Hi Anil,
Refer section 'Accessing Geolocation via Apex and Visualforce' in following link, which explains with code snippets:
http://blogs.developerforce.com/developer-relations/2012/10/winter-13-using-apex-and-soql-with-geolocation.html
Hi Vinita,
Thank you for your response.
How can we get the current location coordinates by using apex code.
Thanks,
Anil
You can't, because Apex runs on the Salesforce server and doesn't know where you are. You have to do it via the user's device using javascript. There's an example in the link posted above for Visualforce, I guess you could also do this via a sidebar component if that made any sense for your scenario.
Hi,
If you define current location in a field with type geolocation, then you can query on this field in your apex code for the cordinates Location__latitude__s and Location__longitude__s.
Ex: SELECT Location__latitude__s, Location__longitude__s, name FROM Account where Location_c='abc';
Here location field is of type geolocation.
Location__Latitude__s
Location__Longitude__s
Don't ask how long I spent debugging that one :-)