You need to sign in to do that
Don't have an account?
Heather DeMalio
How to populate the address using reverse geolocation
Hello,
I am looking to populate the address fields by using the longitude and latitude coordinates.
I can look this information up with Google Maps API but I don't know how to get this information into my Salesforce fields,
Here is an example of google link https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&key=AIzaSyB9SidQvZbhRlDax3Vvg8ak0hE0nxk7seo
Can anyone assist?
Thanks
-Heather
I am looking to populate the address fields by using the longitude and latitude coordinates.
I can look this information up with Google Maps API but I don't know how to get this information into my Salesforce fields,
Here is an example of google link https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&key=AIzaSyB9SidQvZbhRlDax3Vvg8ak0hE0nxk7seo
Can anyone assist?
Thanks
-Heather
There are a lot of ins and outs to geocoding and binding the results to a record, and a lot hinges on how your application works. If it's a UI-based application with a map, there are some differences to the patterns you might use to bind these returned values to your salesforce record. In a trigger, there are other considerations around making callouts, in that they have to be asynchronous. But before we get too far ahead, and in the spirit of jumping right in, here's a class you could create and invoke from an anonymous apex window in the console. Depending on the answers to the questions I've just asked, there is quite a bit that you'd have to do to this example to make it production-ready, but the goal here is to give you an idea of how it works. I've commented a bit to give you a sense for what's going on, but it should be enough to get you going - at least until the next question. :-) (NOTE: see the comment below about remote site settings. It will fail unless you've set that up first. Setup --> Security --> Remote Site Settings):
You can call this using the console, like so:
Good luck! Hope this helps.
Dave (monsterloomis)
https://www.salesforcebolt.com/2020/07/Geocoding-and-Reverse-Geocoding-in-Salesforce.html