npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordova-plugin-geolocation-plus

v0.0.1

Published

Cordova geolocation plugin that gives more control over accuracy and OS configuration

Readme

cordova-plugin-geolocation-plus

Advanced Cordova geolocation plugin for Android and iOS. This plugin exposes the native APIs more explicitly than the standard browser geolocation API. This is done to give better control over accuracy, frequency of updates and battery management to the programmer. The plugin relies on LocationManager in Android (which works also AOSP, instead of FusedLocationProviderClient) and CLLocationManager in iOS.

This is has been developed with lots of help from Claude, but has been reviewed and commented manually line-by-line and corrected/steered when neecessary.

Install

cordova plugin add cordova-plugin-geolocation-plus

JS API

The plugin is exposed at:

cordova.plugins.geolocationPlus;

isLocationServiceEnabled(options?)

Returns a promise that resolves with the current location service state.

cordova.plugins.geolocationPlus
  .isLocationServiceEnabled()
  .then(function (result) {
    console.log(result);
  });

Current native return value: true if the location service is running and false otherwise.

If the native check throws an exception, the promise is rejected and the rejection reason contains the native exception message.

Supported options:

  • provider - Android-only check against a specific provider name. See below for possible values.

requestPermissions(options?)

Requests OS location permission and resolves with the permission state after the request completes.

cordova.plugins.geolocationPlus
  .requestPermissions({ authorization: "whenInUse" })
  .then(function (result) {
    console.log(result);
  });

Supported options:

  • authorization - preferred permission scope, it can be whenInUse (default) or always
  • scope - alias for authorization

Return values: { granted : true, status: 'denied' }

The status on Android is either granted or denied. On iOS it can be notDetermined (user has not chosen whether the app can use location services), restricted (app is not authorized to use location services), denied (user denied the use of location services), authorizedAlways (app can start location services at any time), authorizedWhenInUse (app can start location services while it is in use).

Android adds 2 boolean properties: fineGranted and coarseGranted that indicate which accuracy the app is allowed to use.

hasPermissions(options?)

Queries whether location permission has already been granted.

cordova.plugins.geolocationPlus.hasPermissions().then(function (result) {
  console.log(result);
});

See requestPermissions for returned values.

getCurrentPosition(options?)

Gets one location fix and resolves once with the position. This does not start a continuous watch.

cordova.plugins.geolocationPlus
  .getCurrentPosition({
    provider: "best",
    desiredAccuracy: 10,
  })
  .then(function (position) {
    console.log(position);
  });

Supported options:

  • provider: Android-only gets the location from a specific provider. See below for possible values.
  • desiredAccuracy: iOS-only is the desired accuracy of the location. See below for possible values.

The position object returned is explained below.

startPositionUpdates(positionCallback, options?)

Starts continuous location updates. Only one upate callback can be started by the app at any time.

cordova.plugins.geolocationPlus
  .startPositionUpdates(
    function (position) {
      console.log(position);
    },
    {
      distanceFilter: 5,
      provider: "best",
      minTime: 2000,
      desiredAccuracy: 10,
    },
  )
  .then(function () {
    console.log("watch started");
  });

Returns a Promise that resolves when updates are started. Only one active callback can exist at a time. If startPositionUpdates is called again before stopPositionUpdates, the Promise is rejected.

Supported options:

  • distanceFilter: minimum distance between location updates in meters.
  • provider: Android-only gets the location from a specific provider. See below for possible values.
  • desiredAccuracy: iOS-only is the desired accuracy of the location. See below for possible values.
  • minTimeMs: Android-only minimum time interval between location updates in milliseconds.

stopPositionUpdates()

Stops continuous location updates.

cordova.plugins.geolocationPlus.stopPositionUpdates();

Position object

The plugin returns location data in this shape:

{
  provider: 'gps',
  timestamp: 1710000000000,
  coords: {
    latitude: 0,
    longitude: 0,
    accuracy: 10,
    altitude: 0,
    altitudeAccuracy: 5,
    heading: 0,
    speed: 0
  }
}

Some fields may be null when the platform cannot provide them. timestamp is in milliseconds since epoch.

Android-only provider parameter

This indicates the location provider name to use (string), common values include best, gps, network, passive and fused. See LocationManager for details. Default: best enabled provider, falling back to network, then gps, then passive.

iOS-only desiredAccuracy parameters

It specifies the accuracy in meters, and can also be mapped to categories, see CLLocationAccuracy for details. Default: kCLLocationAccuracyBest.

Example

document.addEventListener("deviceready", function () {
  var geo = cordova.plugins.geolocationPlus;

  geo
    .hasPermissions()
    .then(function (state) {
      if (!state.granted) {
        return geo.requestPermissions({ authorization: "whenInUse" });
      }
    })
    .then(function () {
      return geo.getCurrentPosition({
        provider: "best",
        desiredAccuracy: 10,
        distanceFilter: 0,
      });
    })
    .then(function (position) {
      console.log(position);
    })
    .catch(function (error) {
      console.error(error);
    });
});