I am developing a map where I track user’s location via navigator.geolocation.watchPosition
towards it’s destination. Now what i want is to track location of the user in real-time when he has logged in to the web portal for this i am using watch position which help me update the latest location of user momentarily. The Issue is am facing is when the user changes the tab, or moves the tab in the background, or when the browser becomes inactive watchPosition
stops fetching the location due to which i am unable to update location on real-time basis. For this I tried using navigator.geolocation.getCurrentPosition
as well but what i experienced is that although the getCurrentPosition
api was being triggered it wasn’t returning the location but as soon as i moved back to the tab i started receiving the positions.
I had looked into some possible solutions via service-worker
but due to it’s limitation we won’t be able to fetch location through it.
It would be great if someone could suggest a possible solution for my problem?