Provides API for getting and monitoring location for NativeScript app.
Geolocation plugin to use for getting current location, monitor movement, etc.
The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder. In demo folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to demo/app/main-page.ts.
latitude - The latitude of the geolocation, in degrees.
longitude - The longitude of the geolocation, in degrees.
altitude - The altitude (if available), in meters above sea level.
horizontalAccuracy - The horizontal accuracy, in meters.
verticalAccuracy - The vertical accuracy, in meters.
speed - The speed, in meters/second over ground.
timestamp - The time at which this location was determined.
desiredAccuracy? Accuracy.high This will return the finest location available but use more power than any option. Accuracy.any is considered to be about 100 meter accuracy. Using a coarse accuracy such as this often consumes less power.
updateTime 1 minute Interval between location updates, in milliseconds (ignored on iOS). Read more in Google document.
minimumUpdateTime 5 secs Minimum time interval between location updates, in milliseconds (ignored on iOS). Read more in Google document.
maximumAge - How old locations to receive in ms.
timeout 5 minutes How long to wait for a location in ms.
iosOpenSettingsIfLocationHasBeenDenied false Argument on the enableLocationRequest. If true, the settings app will open on iOS so the user can change the location services permission.
getCurrentLocation(options: Options) Promise Get current location applying the specified options (if any). Since version 5.0 of the plugin, it will use requestLocation API for devices using iOS 9.0+. In situation of poor or no GPS signal, but available Wi-Fi it will take 10 sec to return location.
watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options) number Monitor for location change.
clearWatch(watchId: number) void Stop monitoring for location change. Parameter expected is the watchId returned from watchLocation.
enableLocationRequest(always?: boolean) Promise<void> Ask for permissions to use location services. The option always is applicable only for iOS. For a custom prompt message on IOS, the following keys are required. NSLocationAlwaysUsageDescription, NSLocationUsageDescription and NSLocationWhenInUseUsageDescription Read more about its usage .
isEnabled Promise<boolean> Resolves true or false based on the location services availability.
distance(loc1: Location, loc2: Location) number Calculate the distance between two locations. Returns the distance in meters.