From 4164e7c0673e8695e3adc2802d23454465ebc0c7 Mon Sep 17 00:00:00 2001 From: xenDE Date: Sun, 29 Dec 2019 14:57:17 +0100 Subject: [PATCH] webgpsmap: get current position and set marker on map in interval (30s) used the browsers geolocation function to get the current location, show a marker and center the map there. on success (user allows usage of get-current-position) it gets position every 30s and reposition the marker without center the map to the marker. --- pwnagotchi/plugins/default/webgpsmap.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pwnagotchi/plugins/default/webgpsmap.html b/pwnagotchi/plugins/default/webgpsmap.html index 6c401ec1..905a13c0 100644 --- a/pwnagotchi/plugins/default/webgpsmap.html +++ b/pwnagotchi/plugins/default/webgpsmap.html @@ -270,5 +270,16 @@ positionsLoaded = true; drawPositions(); }); + // get current position and set marker in interval + var myLocationMarker = {}; + function onLocationFound(e) { + if (myLocationMarker != undefined) { + mymap.removeLayer(myLocationMarker); + }; + myLocationMarker = L.marker(e.latlng).addTo(mymap); + setTimeout(function(){ mymap.locate(); }, 30000); + } + mymap.on('locationfound', onLocationFound); + mymap.locate({setView: true});