Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-geolocation

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-geolocation

Provides API for getting and monitoring location for NativeScript app.

  • 4.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
decreased by-41.18%
Maintainers
2
Weekly downloads
 
Created
Source

NativeScript Geolocation apple android

npm npm Build Status

Geolocation plugin to use for getting current location, monitor movement, etc.

Installation

In Command prompt / Terminal navigate to your application root folder and run:

tns plugin add nativescript-geolocation

Usage

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.

In short here are the steps:

Import the plugin

TypeScript

import * as geolocation from "nativescript-geolocation";
import { Accuracy } from "ui/enums"; // used to describe at what accuracy the location should be get

Javascript

var geolocation = require("nativescript-geolocation");

Request permissions

geolocation.enableLocationRequest();

Call plugin methods

// Get current location with high accuracy
geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, maximumAge: 5000, timeout: 20000 })

API

Properties

Location
PropertyDefaultDescription
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.
Options
PropertyDefaultDescription
desiredAccuracy?Accuracy.highSpecifies desired accuracy in meters.
updateDistanceiOS - no filterUpdate distance filter in meters. Specifies how often to update the location (ignored on Android).
updateTime1 minuteInterval between location updates, in milliseconds (ignored on iOS).
minimumUpdateTime5 secsMinimum time interval between location updates, in milliseconds (ignored on iOS).
maximumAge-How old locations to receive in ms.
timeout5 minutesHow long to wait for a location in ms.
iosAllowsBackgroundLocationUpdatesfalseIf enabled, UIBackgroundModes key in info.plist is required (check the hint below). Allow the application to receive location updates in background (ignored on Android)
iosPausesLocationUpdatesAutomaticallytrueAllow deactivation of the automatic pause of location updates (ignored on Android)

If iosAllowsBackgroundLocationUpdates is set to true, the following code is required in the info.plist file:

<key>UIBackgroundModes</key>
<array>
   <string>location</string>
</array>

Methods

MethodReturnsDescription
getCurrentLocation(options: Options)PromiseGet current location applying the specified options (if any).
watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options)numberMonitor for location change.
clearWatch(watchId: number)voidStop 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 application for iOS only. Read more about its usage .
isEnabledPromise<boolean>Resolves true or false based on the location services availability.
distance(loc1: Location, loc2: Location)numberCalculate the distance between two locations. Returns the distance in meters.

License

Apache License Version 2.0, January 2004

Keywords

FAQs

Package last updated on 13 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc