[Question]: i am trying to call _storeAttendance(action); based on distance but however the distance is wrong even though the location is same
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
Future<void> getCurrentPos(String action) async {
currentPos = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.medium);
print("latitude: ${currentPos.latitude} , target latitude : ${targetLatitude}");
print("longitude: ${currentPos.longitude}, target longitude : ${targetLongitude}");
double distance = Geolocator.distanceBetween(
currentPos.latitude,
currentPos.longitude,
targetLatitude,
targetLongitude,
);
print("the distance is ${distance}");
if (distance <= 100) {
await _storeAttendance(action);
} else {
_showResultDialog("Failed", "You are not within the required distance to check in/out.");
}
}
here is the console prints :
I/flutter (13227): latitude: 20.9931481 , target latitude : 20.9911605 I/flutter (13227): longitude: 75.5525976, target longitude : 75.5515482 I/flutter (13227): the distance is 246.6792033217311
Version
12.0.0
I am experiencing the same issue. There is even a significant difference in the distanceBetween values between Android and iOS devices. On Android, the distance is reported as 18 meters, while on iOS, it is reported as 47 meters.
Dear @devlprRohit,
I can't see that your current location and target location are the same. Furthermore, please give some more context about the issue. How do you know that the distance is wrong? Your location accuracy is medium. Have you tried playing around with this and did you find different answers?
Dear @eunseoDev,
I appreciate your effort, but your issue seems like a different issue. based on your input I cannot help you. Please file a separate issue with clear steps to reproduce. The plugin uses the different api's of iOs and Android I can expect that there is a difference in accuracies.
Kind regards,
Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.