flutter-geolocator
flutter-geolocator copied to clipboard
Inaccurate Location Tracking: Randomly Drifting GPS Points
Please check the following before submitting a new issue.
- [X] I have searched the existing issues.
- [X] I have carefully read the documentation.
Please select for which platform(s) you need help
- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
Your question
I'm developing a Flutter application to track the user's location every 30 seconds and generate a route.
I've encountered an issue where the package occasionally records GPS coordinates that are significantly far from the device's actual location, causing unexpected deviations in the generated route. These inaccurate readings seem to occur randomly and then correct themselves after a short period.
final LocationSettings locationSettings = AndroidSettings(
intervalDuration: const Duration(seconds: 30),
accuracy: LocationAccuracy.bestForNavigation,
foregroundNotificationConfig: const ForegroundNotificationConfig(
// Explain to the user why we are showing this notification.
notificationText:
'App will continue to receive your location even when you arent'
' using it',
// Tell the user what we are doing.
notificationTitle: 'Running in Background',
// Give the notification an amber color.
color: Colors.amber, setOngoing: true,
),
);
Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position position) async {
await BackGpsRepository().checkAndSend(position);
},
);
Expected Behavior: The package should consistently provide accurate GPS coordinates, allowing for the generation of a smooth and realistic route.
Actual Behavior: The package intermittently records GPS coordinates that are significantly off, resulting in a distorted route with unexpected jumps.
Additional Information:
Package Version: 13.0.1
Flutter Version: 3.22.3
Affected Devices: g54 Motorola
Operating Systems: Android
Permissions in AndroidManifest:
In this case i stay on the same position and randomly throw a position far away and comeback later.
Version
13.0.1
Please check the following before submitting a new issue.
- [x] I have searched the existing issues.
- [x] I have carefully read the documentation.
Please select for which platform(s) you need help
- [x] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
Your question
I'm developing a Flutter application to track the user's location every 30 seconds and generate a route.
I've encountered an issue where the package occasionally records GPS coordinates that are significantly far from the device's actual location, causing unexpected deviations in the generated route. These inaccurate readings seem to occur randomly and then correct themselves after a short period.
final LocationSettings locationSettings = AndroidSettings( intervalDuration: const Duration(seconds: 30), accuracy: LocationAccuracy.bestForNavigation, foregroundNotificationConfig: const ForegroundNotificationConfig( // Explain to the user why we are showing this notification. notificationText: 'App will continue to receive your location even when you arent' ' using it', // Tell the user what we are doing. notificationTitle: 'Running in Background', // Give the notification an amber color. color: Colors.amber, setOngoing: true, ), ); Geolocator.getPositionStream(locationSettings: locationSettings).listen( (Position position) async { await BackGpsRepository().checkAndSend(position); }, );Expected Behavior: The package should consistently provide accurate GPS coordinates, allowing for the generation of a smooth and realistic route.
Actual Behavior: The package intermittently records GPS coordinates that are significantly off, resulting in a distorted route with unexpected jumps.
Additional Information:
Package Version: 13.0.1 Flutter Version: 3.22.3 Affected Devices: g54 Motorola Operating Systems: Android Permissions in AndroidManifest:
In this case i stay on the same position and randomly throw a position far away and comeback later.
Version
13.0.1
Any answers? To solve it , I got the same issue
Please check the following before submitting a new issue.
- [x] I have searched the existing issues.
- [x] I have carefully read the documentation.
Please select for which platform(s) you need help
- [x] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
Your question
I'm developing a Flutter application to track the user's location every 30 seconds and generate a route. I've encountered an issue where the package occasionally records GPS coordinates that are significantly far from the device's actual location, causing unexpected deviations in the generated route. These inaccurate readings seem to occur randomly and then correct themselves after a short period.
final LocationSettings locationSettings = AndroidSettings( intervalDuration: const Duration(seconds: 30), accuracy: LocationAccuracy.bestForNavigation, foregroundNotificationConfig: const ForegroundNotificationConfig( // Explain to the user why we are showing this notification. notificationText: 'App will continue to receive your location even when you arent' ' using it', // Tell the user what we are doing. notificationTitle: 'Running in Background', // Give the notification an amber color. color: Colors.amber, setOngoing: true, ), ); Geolocator.getPositionStream(locationSettings: locationSettings).listen( (Position position) async { await BackGpsRepository().checkAndSend(position); }, );Expected Behavior: The package should consistently provide accurate GPS coordinates, allowing for the generation of a smooth and realistic route. Actual Behavior: The package intermittently records GPS coordinates that are significantly off, resulting in a distorted route with unexpected jumps. Additional Information: Package Version: 13.0.1 Flutter Version: 3.22.3 Affected Devices: g54 Motorola Operating Systems: Android Permissions in AndroidManifest: In this case i stay on the same position and randomly throw a position far away and comeback later.
Version
13.0.1
Any answers? To solve it , I got the same issue
I think is something with the battery optimization of the device but im not sure
Any answers? To solve it, the same issue occurred in my application while using map navigation.
I got same issue, plz help
are you guys also using mapbox?
are you guys also using mapbox?
Yes ,
common guys, is there any super hero to solve this?
you should creating your own algorithm that uses the previous, current, and incoming GPS points (latitude and longitude) to reduce GPS drifting. It works by analyzing movement patterns between these points and detecting unrealistic jumps or sharp changes in direction or speed.
The idea is to filter out sudden spikes caused by weak GPS signals—like when you’re standing still but your location keeps jumping around. The algorithm checks the distance, speed, and angle between points. If something seems off like that big jump that doesn’t make sense, it ignores will not put it in polylines.
Actually, it turns out, it's pretty simple than one might think. You just need to skip the lower accuracy gps data, and that's it. It took me weeks to realize this. If you're gonna draw with that info to map, you can use kalvin(I'm not sure if this is a correct spelling) formula for GPS. You can create one with GPT
Any answers? To solve it, the same issue occurred in my application while using map navigation.
How do you define what is low accuracy? 2 meters? Or you let the user configure that?
How do you define what is low accuracy? 2 meters? Or you let the user configure that?
The Position object includes an accuracy in meters—use this to create a condition that disqualifies any newly emitted object if the accuracy isn’t sufficient.
Dear @Gonn01 and other members of this thread,
This happens because the Android OS uses several other sensors like WIFI or Cellular connections to determine your location. If it is "unable" to fetch a location (for example) via GPS (or for efficiency reasons) it could be possible that the OS determines a location via a wifi point. The location of this wifi point could be inaccurate, however it could also be the "best possible" option when you are for example indoors. By setting the forceLocationManager: true in the AndroidSettings, you basically force the OS to use the old location manager that uses the GPS. That way it could be possible to fetch more accurate locations... HOWEVER, indoor you could have some issues on determining the location when you use GPS. So I would suggest trying this to see if it improves (outside).
Kind regards,
I am also having this issue in outdoors.
I updated my code to add a filter based on the accuracy as mentioned here in this thread, but I have no feedbacks from my users yet if it worked or not.
One user who reported that was using an iPhone 15.
@steinmetz,
What would you expect? Try to set the accuracy to .best and forceLocationManager: true. Phone with open sky, batteries charged. That would be the best possible location you can determine by gps with an on board gps chip. It looks like something is happening externally when the locations start to become inaccurate.
Kind regards,
Hi @TimHoogstrate
Hope you are doing well.
Please find attached video it's a real world use case where a driver is moving from Qatri Brothers building to Hamad international Airport the total distance is 9.6 KM but it turned 19 Km because there are some points that are fired randomly. it's not a single case i've lot more.
https://drive.google.com/file/d/1MBRSj5WXmMGxgtssh9INLTe0z1Vu3dr9/view?usp=sharing
Actually, it turns out, it's pretty simple than one might think. You just need to skip the lower accuracy gps data, and that's it. It took me weeks to realize this. If you're gonna draw with that info to map, you can use kalvin(I'm not sure if this is a correct spelling) formula for GPS. You can create one with GPT
Does it return low accuracy data in getPositionStream even we set accuracy to high & best ?
Hope you are doing well.
Please find attached video it's a real world use case where a driver is moving from Qatri Brothers building to Hamad international Airport the total distance is 9.6 KM but it turned 19 Km because there are some points that are fired randomly. it's not a single case i've lot more.
https://drive.google.com/file/d/1MBRSj5WXmMGxgtssh9INLTe0z1Vu3dr9/view?usp=sharing
Hi there, when using the [location updates stream], filter it like this: [location updates stream].where((e)=>//set accuracy filter just like this, to your liking). And your problem is solved. Also you can make the updates a bit more frequent, as the filter above will skip some updates. I have been in your situation, and this is what I learnt. The interesting thing is, there is no well known tutorial for this way of fixing the problem. @steinmetz @qky1412 @TimHoogstrate @NhaPCS @Ahmed-Makled
