0

I have a custom field which is of Geolocation type. I just need to display the corresponding address information on the page. For ex, the field name is branch_location_id which contains the Lat Long values. I just need to display the Branch address (based on that ID). The user need not edit, just for display purpose only. Please help.

  • So, you are going to be using the lat/long coordinates to try to determine the street address at those coordinates? – Mark Pond Oct 5 '18 at 17:25
  • Yes, I need the street address to be displayed based on the lat/long. Can I use a formula field? Thanks for your help. – FSL Developer Oct 5 '18 at 17:50
1

I don't think this would be that straightforward as you are thinking. We cannot achieve it using Point and Click.

You need to make a call out to any of the geocoding services (ex: Google Reverse GeoCoding) to get the address and to populate in that field. You can mark that field as read-only in Layout to restrict any update.

  • That's a bummer. I was hoping some formula field use to get this address. Again, I do not see to show the address on a Map, just a read-only 'address' on the lay out. – FSL Developer Oct 5 '18 at 18:24
0

The Google Maps Geocoding API is exactly what you want to be using here. You're going to need to pass the Google API your Geolocation via an HTTPS callout, and then extract the address from the response, and display that information on your VF page. There's other alternatives (ArcGIS for example), but imo the Google Maps API is easiest to use. For example:

https://maps.googleapis.com/maps/api/geocode/jsonlatlng=YOUR_LAT,YOUR_LONG&key=YOUR_API_KEY

This will return a JSON object for you to parse, including the address. You'd likely need to set up an account with google for this. You can make calls to this API in the Apex Controller for your VFP (You'll need this HTTP Request Class) or you could write a script to do this for all your data and execute that from the dev console.

  • This answer is certainly better than your previous; link only answers are usually deleted. In the future (if such a scenario happens again), it would be better to edit and unddlete your post. – Adrian Larson Oct 5 '18 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.