Skip to content

Support to supply desired accuracy #25

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [1.1.0]

* Introduced the option to supply a desired accuracy.

> **Important:**
>
>This introduces a breaking change, the `getPosition` and `onPositionChanged` properties have been replaced by methods (`getPosition([LocationAccuracy desiredAccuracy = LocationAccuracy.Best])` and `getPositionStream([LocationAccuracy desiredAccuracy = LocationAccuracy.Best])` respectively) accepting a parameter to indicate the desired accuracy.
* Updated the Android part to make use of the [LocationManager](https://developer.android.com/reference/android/location/LocationManager) instead of the [FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient)
* Improved support for handling position requests that happen in rapid succession.

## [1.0.0]

* Updated documentation
Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flutter Geolocator Plugin

A Flutter plugin which provides easy access to the platform specific location services ([FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient) on Android and [CLLocationManager](https://developer.apple.com/documentation/corelocation/cllocationmanager) on iOS).
A Flutter plugin which provides easy access to the platform specific location services ([LocationManager](https://developer.android.com/reference/android/location/LocationManager) on Android and [CLLocationManager](https://developer.apple.com/documentation/corelocation/cllocationmanager) on iOS).

Branch | Build Status
------- | ------------
Expand Down Expand Up @@ -53,22 +53,36 @@ To query the current location of the device simply make a call to the `getPositi

``` dart
import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/location_accuracy.dart';
import 'package:geolocator/models/position.dart';

Position position = await new Geolocator.getPosition;
Position position = await new Geolocator().getPosition(LocationAccuracy.High);
```

To listen for location changes you can subscribe to the `onPositionChanged` stream:

``` dart
import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/location_accuracy.dart';
import 'package:geolocator/models/position.dart';

Geolocator geolocator = new Geolocator();
StreamSubscription<Position> positionStream = geolocator.onPositionChanged.listen(
StreamSubscription<Position> positionStream = geolocator.getPositionStream(LocationAccuracy.High).listen(
(Position position) {
print(_position == null ? 'Unknown' : _position.latitude.toString() + ', ' + _position.longitude.toString());
});
```

See also the [example](example/lib/main.dart) project for a complete implementation.

### Location accuracy

The table below outlines the accuracy options per platform:

| | Android | iOS |
|------------|-----------:|------:|
| **Lowest** | 500m | 3000m |
| **Low** | 500m | 1000m |
| **Medium** | 100 - 500m | 100m |
| **High** | 0 - 100m | 10m |
| **Best** | 0 - 100m | ~0m |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.baseflow.flutter.plugin.geolocator;

public enum GeolocationAccuracy {
Lowest, Low, Medium, High, Best
}
Loading