flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Bug]: Current Location latitute longitude is different from google map my location

Open charulbudania07 opened this issue 6 months ago • 1 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [ ] Android
  • [x] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Steps to reproduce

Integrated the google map Try to get the current location Received latitude longitude are slightly different from the blue dot of Google Maps current location

Expected results

need to get exact current location

Actual results

Different latitudes and longitude received from get current location

Code sample

GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: CameraPosition( target: LatLng(provider.currentPosition!.latitude, provider.currentPosition!.longitude), zoom: 16, ), myLocationEnabled: true, myLocationButtonEnabled: false, markers: provider.markers, onCameraMove: provider.onCameraMove, onCameraIdle: provider.onMapIdle, ), ), Future getCurrentLocation() async { bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); if (!serviceEnabled) return;

LocationPermission permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
  permission = await Geolocator.requestPermission();
  if (permission == LocationPermission.deniedForever) return;
}

Position position = await Geolocator.getCurrentPosition(
    desiredAccuracy: LocationAccuracy.high);

_currentPosition = position;
await loadMarkerIcons(); // await here to ensure icons are loaded

notifyListeners();

}

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

geolocator: ^10.1.0

Flutter Doctor output

Doctor output
[Paste your output here]

charulbudania07 avatar Jun 03 '25 10:06 charulbudania07

Dear @charulbudania07,

We are not the maintainers of GoogleMap, however, the location that you received should be ALMOST the same, but it is possible that it is not EXACTLY the same. It works like this. First of all there may be a time difference between the two location fetches. And since locations are always determined with a little accuracy-uncertainty it is possible that there is a little difference. You can lower the difference by playing with the settings. The location itself is fetched from your device and your OS determines the lat and lon. We only pass it through to the user. So my suggestion is to either accept the current difference or lower the difference by playing around with the settings. For example maybe upgrade the settings to LocationAccuracy.best.

 /// Location is accurate within a distance of ~0m on iOS and between 0m and
  /// 100m on Android.
  ///
  /// On Android, corresponds to
  /// [PRIORITY_HIGH_ACCURACY](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_high_accuracy).
  best, 

But also notice that it might take longer or more resources (like battery) to determine such a location.

Kind regards,

TimHoogstrate avatar Jun 03 '25 13:06 TimHoogstrate

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.

github-actions[bot] avatar Jun 17 '25 13:06 github-actions[bot]