How do I use GPS Location in my WEB application?

6

I'm creating an application and found a barrier, this application is for restaurants to monitor deliveries and likewise the user, also do it, I was doing through checkUp's whenever he stops, like in the post office, only that I realized that the deliverer would have to stop to checkup each delivery to be able to update the site where the service status would be, and that the monitoring could be in conflict with 'user errors'. Sorry for the long introduction, but I wanted to explain my problem so that you understand what I'm looking for, well, so I need to know if there's any way I can find the location of an individual (deliverer), if possible, also define route and how I would do it. Thank you in advance.

    
asked by anonymous 30.03.2016 / 12:58

1 answer

1

You can do this with JS, it would look something like this: link (see working here)

var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;  
}

Then you can think about how to always keep updating the delivery position

    
12.04.2016 / 15:19