Get the Geographical Coordinates of an Address
To get the geographical coordinates of more than one address, use the BatchGeocode() Apex method.
Signature
- maps is the namespace that's available after you install Salesforce Maps.
- API is the class that contains the global methods exposed to developers.
- Geocode() is the method.
Sample Code
Input Format of the Address
Example
Sample Response
Although the return value is an Apex Map<String, Object> object, this JSON response illustrates the essential data you receive in the resulting map.
If you invoke this method within a flow, process builder, or trigger and want to use the data from the JSON response, implement logic to retrieve that data. For example, you want to save the latitude and longitude coordinates from the JSON response to your records.
Sample Response If Not Geocoded
If an address can't be geocoded, you receive this response. Although the return value is an Apex Map<String, Object> object, this JSON response illustrates the essential data you receive in the resulting map.