The Location
API provides methods to access the device's current location, reverse-geocode coordinates into address information, and pick locations using the iOS built-in map. This API supports setting location accuracy and working with geolocation data in your app.
Location
The Location
class enables you to interact with the device's location services. Use this API to get the current location, reverse-geocode coordinates, or allow users to select a location on a map.
Location.setAccuracy(accuracy: LocationAccuracy): Promise<void>
Sets the accuracy level of the location data that the app requests.
accuracy
: The desired accuracy level, such as high
or low
. (Refer to the LocationAccuracy
documentation for possible values.)Location.requestCurrent(): Promise<LocationInfo | null>
Requests a one-time retrieval of the user’s current location.
LocationInfo
object containing the latitude, longitude, and other location details, or null
if the location could not be retrieved.Location.pickFromMap(): Promise<LocationInfo | null>
Presents the iOS built-in map interface to let the user pick a location.
LocationInfo
object with the selected location's details, or null
if the user cancels the selection.Location.reverseGeocode(options: { latitude: number; longitude: number; locale?: string }): Promise<LocationPlacemark[] | null>
Submits a reverse-geocoding request for the specified coordinates to retrieve address information.
latitude: number
: The latitude in degrees.longitude: number
: The longitude in degrees.locale?: string
: The locale for the returned address information. Specify null
to use the user’s default locale.LocationPlacemark
objects representing address details, or null
if the reverse-geocoding fails.LocationInfo
Represents the location data retrieved from the device or user selection.
latitude: number
: The latitude of the location.longitude: number
: The longitude of the location.altitude?: number
: The altitude of the location, if available.horizontalAccuracy?: number
: The horizontal accuracy of the location data.verticalAccuracy?: number
: The vertical accuracy of the location data.timestamp: Date
: The timestamp when the location data was retrieved.LocationPlacemark
Represents the address details for a specific location.
name?: string
: The name of the place (e.g., landmark name).thoroughfare?: string
: The street name.subThoroughfare?: string
: The street number.locality?: string
: The city name.subLocality?: string
: The district or neighborhood.administrativeArea?: string
: The state or province.subAdministrativeArea?: string
: The county or other subdivision.postalCode?: string
: The postal or ZIP code.country?: string
: The country name.isoCountryCode?: string
: The ISO country code.LocationAccuracy
Defines the desired accuracy level for location data.
"high"
, "medium"
, "low"
.Location
API.