Ionic geolocaion incorrect in ios


#1

this.geolocation.getCurrentPosition().then((resp) => {
resp.coords.latitude
resp.coords.longitude
}).catch((error) => {
console.log(‘Error getting location’, error);
});

in my app always display wrong location of ios but android app it display correct.


#2

Same issue here. The plugin gives me coordinates in San Francisco, CA. I am located in Ohio.


#3

How are you testing? What is your ionic info output?


#4

I’m testing with real device always it display 200m-300m away from current position
this is ionic info output
cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

System:

Node : v8.2.1
npm  : 5.3.0 
OS   : Linux 4.4

#5

Hi Sujan, thanks for your help. The inaccurate location comes when testing on on a Macbook Pro with Mac OS Sierra emulator. After building to a mobile device, the location is accurate. Thanks!
Ionic Info:

cli packages: (/Users/josterfeld/.nvm/versions/node/v6.11.1/lib/node_modules)

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3 ios 4.5.1
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 25.2.5
ios-deploy        : 1.9.1 
ios-sim           : 5.0.13 
Node              : v6.11.1
npm               : 3.10.10 
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b 

Misc:

backend : legacy

#6

Is Google Maps or Apple Maps more accurate?


#7

That was what I was going for :wink: Great it works for you now.


#8

if you are testing with emulator your current location not taken by emulator it only take location that provided to emulator


#9

this.geolocation.getCurrentPosition({enableHighAccuracy:true}).then((position) => {

let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

let mapOptions = {
center: latLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};

this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);

this.marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter()
});

let content = “

Your location

”;

this.addInfoWindow(this.marker,content);
}

this is my code it display correctly in android but ios always away 200m - 500m away from my current location


#10

Yes, it’s working on mobile devices, so I’m happy- false alarm. Thank you for your help!


#11

please guys give me a help for this issue.


#12

hey, have you get any solution for this? @manjulaucsc