Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d3a35ab

Browse files
authored
Merge pull request #147 from denisraison/master
Adding updateDistance option for Android
2 parents 3da7593 + 7a7b512 commit d3a35ab

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, maximumAge: 500
6969
| Property | Default | Description |
7070
| --- | --- | --- |
7171
| 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. |
72-
| updateDistance | iOS - no filter | Update distance filter in meters. Specifies how often to update the location (ignored on Android). Read more in [Apple document](https://developer.apple.com/documentation/corelocation/cllocationmanager/1423500-distancefilter?language=objc) |
72+
| updateDistance | No filter | Update distance filter in meters. Specifies how often to update the location. Read more in [Apple document](https://developer.apple.com/documentation/corelocation/cllocationmanager/1423500-distancefilter?language=objc) and/or [Google documents](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setSmallestDisplacement(float)) |
7373
| updateTime | 1 minute | Interval between location updates, in milliseconds (ignored on iOS). Read more in [Google document](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setInterval(long)).|
7474
| minimumUpdateTime | 5 secs | Minimum time interval between location updates, in milliseconds (ignored on iOS). Read more in [Google document](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setFastestInterval(long)).|
7575
| maximumAge | - | How old locations to receive in ms. |

src/geolocation.android.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function _getLocationRequest(options: Options): any {
104104
let minUpdateTime = options.minimumUpdateTime === 0 ?
105105
0 : options.minimumUpdateTime || Math.min(updateTime, fastestTimeUpdate);
106106
mLocationRequest.setFastestInterval(minUpdateTime);
107+
if (options.updateDistance) {
108+
mLocationRequest.setSmallestDisplacement(options.updateDistance);
109+
}
107110
if (options.desiredAccuracy === Accuracy.high) {
108111
mLocationRequest.setPriority(com.google.android.gms.location.LocationRequest.PRIORITY_HIGH_ACCURACY);
109112
} else {

src/location-monitor.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface Options {
1010
desiredAccuracy?: number;
1111

1212
/**
13-
* Update distance filter in meters. Specifies how often to update. Default on iOS is no filter (ignored on Android)
13+
* Update distance filter in meters. Specifies how often to update. Default is no filter
1414
*/
1515
updateDistance?: number;
1616

0 commit comments

Comments
 (0)