For the complete documentation index, see llms.txt. This page is also available as Markdown.

Location

Permission settings are required

getCurrentLocationYou need to set location permission before using it. Please check the permission setup guide first.


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 · object

    An options object used when retrieving location information.

    • options.accuracy · Required · Accuracy

      It is the accuracy level for location information. For detailed values, please refer to the type below. Accuracy type below.

Return value

  • Promise<Location>

    Returns an object containing the device's location information. For details, see the Location below. Location type below.

Permission methods

  • getCurrentLocation.getPermission

    Returns the current status of location permission. allowed · denied · notDetermined · osPermissionDenied returns one of

  • getCurrentLocation.openPermissionDialog

    Shows a dialog to request location permission again. If allowed allowed, if denied deniedis 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) => void

    Callback function called when location information changes.

  • onError · Required · (error: unknown) => void

    Callback function called when location detection fails.

  • options · Required · StartUpdateLocationOptions

    Configuration object needed for location detection.

    • options.accuracy · Accuracy

      Sets the location accuracy.

    • options.timeInterval · number

      The minimum interval for updating location information. Unit is milliseconds (ms).

    • options.distanceInterval · number

      Sets 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?