All Projects → NativeScript → Nativescript Geolocation

NativeScript / Nativescript Geolocation

Licence: apache-2.0
Geolocation plugin to use for getting current location, monitor movement, etc

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Nativescript Geolocation

Android Runtime
Android runtime for NativeScript (based on V8)
Stars: ✭ 399 (+214.17%)
Mutual labels:  nativescript, mobile
Nativescript Cli
Command-line interface for building NativeScript apps
Stars: ✭ 977 (+669.29%)
Mutual labels:  nativescript, mobile
Docs
Documentation, API reference, and code snippets for NativeScript
Stars: ✭ 442 (+248.03%)
Mutual labels:  nativescript, mobile
Audio recorder
Stars: ✭ 156 (+22.83%)
Mutual labels:  plugin, mobile
Swipe
A plugin for Unreal Engine 4 that exposes swipes on mobile devices as events in blueprint.
Stars: ✭ 91 (-28.35%)
Mutual labels:  plugin, mobile
Luaviewsdk
A cross-platform framework to build native, dynamic and swift user interface - 强大轻巧灵活的客户端动态化解决方案
Stars: ✭ 3,586 (+2723.62%)
Mutual labels:  nativescript, mobile
Metrica Plugin Xamarin
Xamarin plugin for Yandex AppMetrica SDK
Stars: ✭ 12 (-90.55%)
Mutual labels:  plugin, mobile
Gmscore
Free implementation of Play Services
Stars: ✭ 4,356 (+3329.92%)
Mutual labels:  geolocation, mobile
Nativescript Angular
Integrating NativeScript with Angular
Stars: ✭ 1,203 (+847.24%)
Mutual labels:  nativescript, mobile
Framework7 Plugin 3d Panels
Framework7 plugin to add 3d effect for side panels
Stars: ✭ 56 (-55.91%)
Mutual labels:  plugin, mobile
Angular Seed Advanced
Advanced Angular seed project with support for ngrx/store, ngrx/effects, ngx-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
Stars: ✭ 2,279 (+1694.49%)
Mutual labels:  nativescript, mobile
Nativescript Ui Feedback
This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Stars: ✭ 110 (-13.39%)
Mutual labels:  nativescript, mobile
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (+411.02%)
Mutual labels:  plugin, mobile
Nativescript Fresco
This repository holds the NativeScript plugin that exposes the functionality of the Fresco image library to NativeScript developers.
Stars: ✭ 51 (-59.84%)
Mutual labels:  nativescript, mobile
Mln
高性能、小巧、易上手的移动跨平台开发框架. A framework for building Mobile cross-platform apps with Lua
Stars: ✭ 1,343 (+957.48%)
Mutual labels:  nativescript, mobile
Push Plugin
Contains the source code for the Push Plugin.
Stars: ✭ 122 (-3.94%)
Mutual labels:  nativescript, mobile
Sounds Webpack Plugin
🔊Notify or errors, warnings, etc with sounds
Stars: ✭ 125 (-1.57%)
Mutual labels:  plugin
Awesome Mobile Security
An effort to build a single place for all useful android and iOS security related stuff. All references and tools belong to their respective owners. I'm just maintaining it.
Stars: ✭ 1,837 (+1346.46%)
Mutual labels:  mobile
Fastapi login
FastAPI-Login tries to provide similar functionality as Flask-Login does.
Stars: ✭ 123 (-3.15%)
Mutual labels:  plugin
Http Request Plugin
This plugin does a request to an url with some parameters.
Stars: ✭ 124 (-2.36%)
Mutual labels:  plugin

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 "tns-core-modules/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

Property Default Description
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

Property Default Description
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.
updateDistance No filter Update distance filter in meters. Specifies how often to update the location. Read more in Apple document and/or Google documents
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.
iosAllowsBackgroundLocationUpdates false If enabled, UIBackgroundModes key in info.plist is required (check the hint below). Allow the application to receive location updates in background (ignored on Android). Read more in Apple document
iosPausesLocationUpdatesAutomatically true Allow deactivation of the automatic pause of location updates (ignored on Android). Read more in Apple document

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

Method Returns Description
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, iosOpenSettingsIfLocationHasBeenDenied?: boolean) Promise<void> Ask for permissions to use location services. The options are applicable only for iOS. When always is true, it opens a custom prompt message and the following keys are required: NSLocationAlwaysAndWhenInUseUsageDescription (iOS 11.0+) OR NSLocationAlwaysUsageDescription (iOS 8.0-10.0) and NSLocationWhenInUseUsageDescription. Read more about request always usage . When iosOpenSettingsIfLocationHasBeenDenied is true, the settings app will open on iOS so the user can change the location services permission.
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.

Known Issues

Version Conflicts – Google Play Services

If you have installed multiple plugins that use the Google Play Services you might run into version conflicts. For example, you may encounter the error below when using the nativescript-google-maps-sdk plugin:

Cannot enable the location service. Error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbck;

In order to fix this you might pin the version number in your app/App_Resources/Android/before-plugins.gradle file (if the file does not exist, just create it):

android {  
  // other stuff here

  project.ext {
    googlePlayServicesVersion = "16.+"
  }
}

Contribute

We love PRs! Check out the contributing guidelines. If you want to contribute, but you are not sure where to start - look for issues labeled help wanted.

Get Help

Please, use github issues strictly for reporting bugs or requesting features. For general questions and support, check out Stack Overflow or ask our experts in NativeScript community Slack channel.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].