Hello dear community,
I’m seeing different results on each IONIC SERVE I run, when implementing the Geolocation function WatchPosition in the brackets after the Constructor in app.component.ts.
Sometimes it runs and sometimes dont. On Android it works perfectly, while on iOS it doesn’t work at all. And in the IONIC SERVE version it’s shifty.
I’ve also tried to put it in the brackets after the constructor in a provider, but then it’s also acting kind of cracy.
This is the piece of code I’m implementing:
let options = {
enableHighAccuracy: true,
timeout: 8000,
maximumAge: 7000,
};
let watch = this.geolocation.watchPosition(options);
watch.subscribe((data) => {
this.userLocation = {lat: data.coords.latitude, lng: data.coords.longitude};
// data can be a set of coordinates, or an error (if an error occurred).
this.events.publish('theNewLocationFromOnLocate', [data.coords.latitude, data.coords.longitude]);
console.log("Location from LocationsProvider ", data.coords.latitude, ' ', data.coords.longitude);
});
Hoping for an answer…