In iOS, there is no problem finding GPS coordinates. It works great.
On the Android side, it is unstable like iOS. This problem is both in the real device and in the emulator. Sometimes he can find a place, but sometimes not. Looking for 3 days, but did not find a solution.
When my application cannot find my location, I tried using the Google Maps application, it works like a charm.
Here is my code for iOS and Android;
getCurrentPosition() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({ initialPosition: position });
alert(JSON.stringify(position))
var coords = new Coords();
coords.Latitude = position.coords.latitude;
coords.Longitude = position.coords.longitude;
this.getPharmaciesByCoordinates(coords);
},
(error) => alert(error.message),
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
);
this.watchID = navigator.geolocation.watchPosition((position) => {
this.setState({ initialPosition: position });
},
(error) => alert(error.message),
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
);
}
Any solutions are welcome.
thank
source
share