Newer Version Available
Get the Geographical Coordinates of Addresses in Batch
The BatchGeocode() Apex method
takes one or more addresses and returns their geographical coordinates and formatted
addresses.
Signature
Where,
- maps is the namespace that's available after you install Salesforce Maps.
- API is the class that contains the global methods exposed to developers.
- BatchGeocode() is the method.
Sample Code
This code returns the geographical coordinates of the White House and Washington Monument. The output also returns the formatted address and adds missing information, such as postal code and country, if available.
Input Format of an 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.
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.