stopWatchingPosition(watchId)

Unsubscribes from location updates for the mobile device.

This function will be retired in a future release. From feedback, we’ve determined that the limitations of the API render it unsuitable for many customer use cases. Additional Android and iOS platform constraints require us to fully reevaluate our approach. We’re exploring the possibility of replacing this API in a future release.

Note

Syntax 

1import { getLocationService } from 'lightning/mobileCapabilities';
2stopWatchingPosition(watchId: number): void;

Parameters 

  • watchId—(Required) An integer identifier for an active location subscription, returned by a call to startWatchingPosition().

Returns 

None.

Usage 

This function ends an existing subscription to location updates.

1stopTracking() {
2  let locationService = getLocationService();
3  locationService.stopWatchingPosition(this.myLocationWatchId);
4}

Calling stopWatchingPosition() releases resources used to track the current location. You can’t reactivate a watch that’s been stopped. Create a new location subscription with startWatchingPosition() instead.

See Also