Coder Social home page Coder Social logo

Emit position event only by the time that a distance change was made - not automatically after 5 seconds about cordova-plugin-geolocation HOT 5 OPEN

apache avatar apache commented on May 28, 2024
Emit position event only by the time that a distance change was made - not automatically after 5 seconds

from cordova-plugin-geolocation.

Comments (5)

ctcampbell avatar ctcampbell commented on May 28, 2024 1

I agree on letting your users choose how they want the library to work, not forcing them to make changes to your code if they need higher accuracy than 5m changes. At the least this should be documented.

I also found evidence that distanceFilter has no direct impact on battery life at https://stackoverflow.com/questions/5490707/does-cllocationmanager-distancefilter-do-anything-to-conserve-power

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

Just posting some relevant information for this feature request.

Currently not configurable but this is already done on iOS.

Note distanceFilter which I believe is in meters.

if (enableHighAccuracy) {
__highAccuracyEnabled = YES;
// Set distance filter to 5 for a high accuracy. Setting it to "kCLDistanceFilterNone" could provide a
// higher accuracy, but it's also just spamming the callback with useless reports which drain the battery.
self.locationManager.distanceFilter = 5;
// Set desired accuracy to Best.
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
} else {
__highAccuracyEnabled = NO;
self.locationManager.distanceFilter = 10;
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
}

As for Android, this plugin uses the webview geolocation implementation, which doesn't have a configurable distance filter as far as I can tell. In order to accomplish this, I think the plugin will to use the android location manager directly instead of relying on the browser implementation.

from cordova-plugin-geolocation.

Taxi4you avatar Taxi4you commented on May 28, 2024

Thanks for your reply.
How to enable this for iOS, if I set options object to be:

{
  distanceFilter: NUMBER
}

Is this the proper way?

**

For Android, when will this be available, is there any roadmap for doing so?

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

How to enable this for iOS

The plugin has the value hard coded to be 5 meters when high accuracy is enabled, or 10 meters otherwise.

For Android, when will this be available, is there any roadmap for doing so?

Sorry, I'm not the person that can answer that question. Obviously moving from the browser implementation to a custom implementation that uses Android's geolocation APIs directly is a significant change...

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 28, 2024

For the record, I'm having a quick scan through Android Location documentation and it doesn't look like they have a distance filter concept either. Their battery saving recommendations makes no mention of a distance filter and their API reference seems to lack a distance filter setting. So I'm not sure if this is even possible on Android. Distance filter might be an iOS concept only.

Personally I think the distanceFilter for iOS should be configurable. The defaults can be left as is if not explicitly set by the app. For android, the API/config properties would have to be ignored as Android seems to have a different philosophy on achieving conservative battery status when using geolocation.

from cordova-plugin-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.