Search code examples
google-mapsgeolocation

Get current position in Google Maps JavaScript API v3 and get the dot to follow me without user interaction


I am assuming this is not possible or advisable due to the nature of the web but I will ask anyway.

I know I can get a user's current location and centre on a map using the Google Maps JavaScript API v3. I can even get it to show a dot for where the user is currently located.

What I really want to know, and my client is asking for this, is can I get the dot to follow the user around without user interaction (ie.. the user does not interact with the device, the dot just moves when the user moves.)? All I can think of is that I would need to add a timer event to continuously check the current location and update the dot. I don't feel this would be best practice.

I have found lots of posts on how to do this in an android or IOS device but not on the web.

Any pointers and info will be greatly appreciated.

thanks Russ


Solution

  • This is exactly what you need 1

    The working example is here: 2

    Good Luck :) UPDATED: The Links are now pointing to the new location on git hub