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
Nick KeehanNick Keehan 

Convert Geolocation to an address String Field

Hi Everyone.

I have a Longitude and Latitude field on a custom object. I am trying to convert the Longitude and Lattitude to a address string in a field.

e.g. -43.5349616 172.6418029
=
String of "219 Tuam Street, Christchurch"

Is this possible? tried the web for this however can only find information on going the other way around street to lat.

Any help would be great
Shun KosakaShun Kosaka
Hi,
How about using Google API?
You can get JSON type address by the longitude and lattitude like below.
http://maps.googleapis.com/maps/api/geocode/json?latlng=-43.5349616,172.6418029

See also,
Google Maps API - Developer Guide : https://developers.google.com/maps/documentation/geocoding/intro?hl=en#ReverseGeocoding
JSON Class - Apex Developer Guide : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm