简体   繁体   中英

Flutter geolocator package is giving negative latitude on IOS app and correct coordinates on Android

double lat;
double lon;

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

lat = position.longitude;
lon = position.latitude;

Im trying to get the device location and i have the same project building the IOS and Android App but for IOS im getting the GPS location as 37.785834,-122.406417 and android 35.6496833,139.7517317 which is the correct.

if i change the lat = -(position.longitude); then it makes the android app gives the negative latitude. any way to avoid this without having separate projects for each apps

Make sure you are using real device on the iOS part.

The Geolocation shown on Simulator is a preset value which can be modified via the iOS Simulator menu, go to Debug -> Location -> Custom Location . There you can set the latitude and longitude and test the app accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM