I am working on an angular 6 app and I need to track a location of the device after every 15 minutes. I need to also check that the location should not be same as last recorded location and it should be different and more than 100 meters than the previous recorded location coordinates.
Any example for doing this kind of stuff would be good help.
I am using window.navigator.geolocation.getCurrentPosition
for getting location after every 5 minutes and I am getting the data but want to avoid the duplication of the data and the data should be more than 100 meters apart.
Here is the code
handleLocationError (error) {
console.log(error);
}
getLocationVal() {
if (window.navigator.geolocation) {
window.navigator.geolocation.getCurrentPosition(
(position) => {
console.log(position.coords.latitude);
},
(error) => {
console.log(error);
},
{ maximumAge: 500, timeout: 0 , enableHighAccuracy: true}
);
}
}
startTracking() {
this.subscription = timer(0, 10000).pipe().subscribe(
result => this.getLocationVal()
);
}