Location
1. Get current location
SDK function: getCurrentLocation
A function that retrieves the device's current location information only once. Useful for showing the user's location on a map or searching for nearby stores.
Signature
function getCurrentLocation(options: { accuracy: Accuracy }): Promise<Location>;Parameters
options · Required ·
objectAn options object used when retrieving location information.
options.accuracy · Required ·
AccuracyIt is the accuracy level for location information. For detailed values, please refer to the type below.
Accuracytype below.
Return value
Promise<Location>Returns an object containing the device's location information. For details, see the Location below.
Locationtype below.
Permission methods
getCurrentLocation.getPermission
Returns the current status of location permission.
allowed·denied·notDetermined·osPermissionDeniedreturns one ofgetCurrentLocation.openPermissionDialog
Shows a dialog to request location permission again. If allowed
allowed, if denieddeniedis returned.
Error
If permission is denied GetCurrentLocationPermissionErroroccurs.
Example
2. Track location in real time
SDK function: startUpdateLocation
A function that runs a callback every time the location changes. Use it in a fitness app to record travel distance or to update the location on a map in real time. Tracking stops when you call the returned cleanup function.
Signature
Parameters
onEvent · Required ·
(location: Location) => voidCallback function called when location information changes.
onError · Required ·
(error: unknown) => voidCallback function called when location detection fails.
options · Required ·
StartUpdateLocationOptionsConfiguration object needed for location detection.
options.accuracy ·
AccuracySets the location accuracy.
options.timeInterval ·
numberThe minimum interval for updating location information. Unit is milliseconds (ms).
options.distanceInterval ·
numberSets the location change distance in meters (m).
Return value
() => void
A cleanup function that stops location tracking. Be sure to call it when the component unmounts.
Permission methods
startUpdateLocation.getPermission
Returns the current status of location permission.
startUpdateLocation.openPermissionDialog
Shows a dialog to request location permission again.
Error
If permission is denied StartUpdateLocationPermissionErroroccurs. error instanceof StartUpdateLocationPermissionErrorYou can check it with
Example
Types · Objects
Location accuracy options (Accuracy)
An enum for setting the location accuracy level.
Location information object (Location)
An object that represents location information.
Detailed location coordinate information (LocationCoords)
An object that represents detailed location coordinate information.
Last updated
Was this helpful?