Salesforce Geolocation Field
Contents
[NOTE] Updated March 9, 2020. This article may have outdated content or subject matter.
Geolocation is a technology that uses data acquired from an individual’s computer or mobile device to identify or describe the user’s actual physical location using longitude and latitude values. Salesforce allows its users to accomplish this feat by giving the ability to create geolocation fields, Geolocation field includes latitude and longitude values.
Latitude and longitude Refresher
Are coordinate systems employing the position or location of any place on Earth’s surface, which can be determined and described. Latitude is a measurement on a globe or map of location north or south of the Equator. Longitude is a measurement of location east or west of the prime meridian at Greenwich, the specially designated imaginary north-south line that passes through both geographic poles and Greenwich, London.
Geolocation Field
The Geolocation field type is a native field type that can be used to encode locations with geolocation coordinates.
Query Geolocation Fields
use the following format to access Geolocation latitude and longitude values. Assume that a Geolocation field named Location was created on the Account object.
Note that the compound field type introduces a new suffix to custom fields:
__s
(for ‘subfield’). A compound custom geolocation field calledmyLocation__c
will have the subfieldsmyLocation__latitude__s
andmyLocation__longitude__s
.
|
|
To access individual fields in APEX use the following syntax.
|
|
Geolocation Field Standard Validations
Geolocation fields only accept valid location pairs.
- Latitudes must be between -90 and +90 degrees.
- Longitudes must be between -180 and +180 degrees.
Geolocation Field Limitations
Geolocation is a compound field that counts toward your org’s limits as three custom fields.
- One for Latitude
- One for Longitude
- One for internal use
Calculating Distances APEX
Developers can opt to use the Location utility class, it contains methods for accessing the component fields of geolocation compound fields.
Author Remario Richards
Modified March 09, 2020