How do I use GPS Location in my WEB application?

Asked

Viewed 1,122 times

6

I’m creating an application and I found a barrier, this application is for restaurants to monitor deliveries and in the same way the user, also do it, I was doing by way of checkup’s whenever he stops, as in the post office, only that I realized that the courier would have to stop to check each delivery in order to update the site in the part where the status of the service would be, and out that the monitoring could conflict for 'user errors'. Sorry for the long introduction, but I wanted to explain my problem in a way that you would understand what I am looking for, well, I need to know if there is a way I can search for the location of an individual (courier), if possible, also define route and how I would do it. Thank you very much.

1 answer

1

You can do this with JS, it would be something like this: http://codepen.io/FuckingLunatic/pen/LNQqjm (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;  
}

There with that you can think of how to keep updating always the positioning of the courier

Browser other questions tagged

You are not signed in. Login or sign up in order to post.