flutter-geolocator
flutter-geolocator copied to clipboard
[Android] Altitude strange behavior
💬 Questions and Help
Hi all. I don't want to fill a bug issue, as I'm not entirely sure if I'm doing something wrong. I'm developing a GPS tracking app with an altitude chart. I've been testing both, location and geolocator (both really good!) for listening to the location updates as an on screen app/foreground service. While using flutter location library, the altitude readings seem to be more natural, but when I switch to geolocator the altitude values have quite a big jumps. I'm not sure which could be the problem.
Expected behavior
Stable and accurate altitude readings.
Reproduction steps
Those are chart examples from both libraries. It's not the same path, but I've tested both in several occasions and the outcome is similar. Also, the track on the map is precise and it follows the path correctly, there are no jumps in lat and lon coordinates.
location library:

geolocator library:

Configuration
The configuration regarding distanceFilter and intervalDuration is the same for both libraries.
final LocationSettings _locationSettings = AndroidSettings(
accuracy: LocationAccuracy.best,
distanceFilter: 10,
intervalDuration: const Duration(seconds: 5),
foregroundNotificationConfig: ForegroundNotificationConfig(
notificationText: I18n.translate('map_notification_desc'),
notificationTitle: I18n.translate('map_notification_title'),
enableWakeLock: true,
));
Version: 8.2.0
Platform:
- [ ] :iphone: iOS
- [x] :robot: Android
Pixel 6. Android 12.
Hey @CMiguelRB, thanks for reporting your issue. I've looked into it and it's expected behaviour. Since the Location package is making use of NMEA data to get the altitude, the readings are often more accurate. The geolocator plugin is using the GPS data to fetch the altitude, which is less accurate most of the time.
We're planning to implement NMEA soon in the future. We'll keep you up to date!
Hi @florissmit1,
Thanks for the information! I'll keep track, you are doing a great work!
https://github.com/Baseflow/flutter-geolocator/pull/1057 has been created to allow Geolocator to have the same behaviour as the location package by requesting that altitude be reported as MSL.
@mvanbeusekom this can probably be closed?