Please help. getCurrentPosition does not work in one of project, it is so strange issue.
I have a project which is using same way as following, that project can get user location, but in this project, it does not work, on the console, I only can see ’ get user location …’ as the first line output, after that there is no any output even error message.
I have install the plugin and add provider in app.module.ts. Any ideas where is wrong? thanks
ionViewDidLoad() {
this.loadMap();
}
loadMap() {
console.log(‘get user location …’);
this.geolocation.getCurrentPosition().then((position) => {
let latLng = {lat:position.coords.latitude, lng:position.coords.longitude};
console.log('lat lng is '+latLng);
let mapOptions = {
center: latLng,
zoom: 15
}
}, (err) => {
console.log(err);
});
}
It should also prompt the user to agree to share their location if they haven’t agreed for this site yet. You won’t get a result until after they’ve agreed.
Yes, When I open the application on device, it prompt me to ‘allow xxxxxx’, I choosed ‘Yes’, but after that does not get any result , even did not fire getCurrentPosition operation at all.
Same issue here. had to increase the timeout to 10 seconds to get the geolocation.
different devices show different duration for getting the value. before I updated all plugin/packages versions, I got the location much faster.
sir i tried ur code but getCurrentPosition not fire in some Android devices specially in the Oppo F11 pro devices
and i tested in 4 Different android devices but only not working in Oppo F11 pro tell me what i do.