-3

I have google map on a webpage which shows user location on it. It asks user's permission to grab its location and then loads map and show a marker there. It works well obviously when you are siting in a room and open it. But what if I am using mobile and walking on the road or sitting in a bus. How to update my position on map then? If you happen to see on google map in a bus, it shows your position (marker) moving along the bus. So how can we get user location on a still map without refreshing page and update its location along the bus?

Thank you!

1 Answers1

-1

Change the method you're using to have the browser access the user's location from navigator.geolocation.getCurrentPosition to navigator.geolocation.watchPosition. This will let you monitor their location as it changes instead of just getting it once.

Google probably would have helped you find this simply enough.

Real time GPS Tracker on JUST HTML / JS and Google Maps to be run on a handphone? Is it possible?

Community
  • 1
  • 1
Nick Albrecht
  • 16,607
  • 10
  • 66
  • 101