No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Geolocation Compound Fields
Geolocation fields are accessible in the SOAP and REST APIs
as a Location, a structured compound data type,
as well as individual latitude and longitude elements.
Using API 26.0 and later,
geolocation fields are available in the SOAP and REST APIs as a compound field of type
Location, a structured data type that contains the following fields.
- latitude
- longitude
Geolocation fields are provided on many standard objects, such as Account, Contact, Quote, and User, as part of their address field or fields. Geolocation fields can also be added as custom fields to standard or custom objects.
Retrieving Compound Geolocation Fields
Using compound fields can simplify code that works with geolocations, especially for SOQL queries. SOQL
SELECT clauses can reference geolocations directly,
instead of the individual component
fields.
1SELECT location__c
2FROM Warehouse__cTo write code that’s compatible with API versions before 26.0, as well
as API 26.0 and above, use the
individual latitude and longitude
fields.
1SELECT location__latitude__s, location__longitude__s
2FROM Warehouse__cReturned Geolocation Data Types
Compound geolocation field values are returned as a structured data type, Location. Code that works with compound geolocation fields needs to reference the individual components of the returned value. See the sample code in Address Compound Fields.
In API versions below 30.0, SOAP calls return compound geolocation field values as strings,
instead of a structured data type, for backwards compatibility. The string value format
is:
A
regular expression to parse out the latitude and longitude values might look like
The
first capture is the latitude, and the third is the longitude. You might need to cast the
results to numbers, depending on how you plan to use it.
1API location: [latitudeValue longitudeValue]1API location: \[([-+]?\d{1,2}([.]\d+)?) ([-+]?\d{1,3}([.]\d+)?)]