kack kack - 1 year ago 40
jQuery Question

geolocation API is always track my location or not?

Now I am using

geolocation API
for get current location of user, but once I am allowed share my location then it will not asked again. But if my location will change then
geolocation API
give me old location or new location?

Answer Source

Finally, Got it my answer, if you want to track location then need to use watchPosition

Please find below code for track your location

var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;