Skip to content

Mindgamesnl/web-gps

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

web-gps

A small utility to track real time distance to locations or markers.

Example code:

<script src="bundle.js"></script>

<script>
    function onUpdate(trackers) {
        // clear div
        document.getElementById("results").innerHTML = "";

        for (const tracker of trackers) {
            document.getElementById("results").innerHTML += "<b>" + tracker.tracker + "</b>: " + tracker.meters + "<br />";
        }
    }

    function onError() {
        alert("Something fucked up!");
    }

    console.log('start')
    const webGPS = new WebGPS(onUpdate, onError);

    // register a few sample locations from my local area
    webGPS.trackLocation("Hilfertshof", 52.224827, 5.176331);
    webGPS.trackLocation("Beeld en geluid", 52.235663, 5.172540);
    webGPS.trackLocation("ROC", 52.216036, 5.188179);
    webGPS.trackLocation("Scouting", 52.235801, 5.200051);
</script>
<div id="results"></div>

outputs something like this, with the location names and real time distance in meters

Hilfertshof: XXXX.4008160069366
Beeld en geluid: XXX.6356992816116
ROC: XXXX.1884711210037
Scouting: XXXX.2516424361834

Xed some values out to protect my own privacy.

About

A small library to track distances between your current location and a set of Lat/Lon markers in real-time, from the browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published