From f28847ab4d70d5a2f396f4f11e4854e3679c10a4 Mon Sep 17 00:00:00 2001 From: Logan B <3870583+thinkpoop@users.noreply.github.com> Date: Sat, 21 Dec 2024 20:21:44 -0600 Subject: [PATCH 1/4] [mylocation] fix saving without lon; center map on marker --- apps/mylocation/interface.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/mylocation/interface.html b/apps/mylocation/interface.html index 1bd3129ee4..76265ecb1e 100644 --- a/apps/mylocation/interface.html +++ b/apps/mylocation/interface.html @@ -76,6 +76,8 @@ map.removeLayer(marker); } marker = new L.marker(latlon).addTo(map); + map.setView(latlon); // center on the marker + document.getElementById("select-hint").style.display="none"; document.getElementById("select").style.display=""; } @@ -84,10 +86,16 @@ setPosition(e.latlng); }); - document.getElementById("select").addEventListener("click", function() { - let settings = {}; // {"lat":48.8566,"lon":2.3522,"location":"Paris"} - settings.lat = latlon.lat; - settings.lon = latlon.lng; + function convertMapToFile(map) { + return {lat: map.lat, lon: map.lng}; + } + + function convertFileToMap(file) { + return {lat: file.lat, lng: file.lon}; + } + + document.getElementById("select").addEventListener("click", function(e) { + let settings = convertMapToFile(latlon); // {"lat":48.8566,"lon":2.3522,"location":"Paris"} settings.location = "custom"; Util.showModal("Saving..."); Util.writeStorage("mylocation.json", JSON.stringify(settings), ()=>{ @@ -101,7 +109,7 @@ Util.readStorageJSON("mylocation.json", function(data) { if (data===undefined) return; // no file try { - setPosition(data); + setPosition(convertFileToMap(data)); } catch (e) { console.error(e); } From 8425b448d12e17e791301935a9467d3cad6658b6 Mon Sep 17 00:00:00 2001 From: Logan B <3870583+thinkpoop@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:01:12 -0600 Subject: [PATCH 2/4] [mylocation] add locate & find marker buttons --- apps/mylocation/interface.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/mylocation/interface.html b/apps/mylocation/interface.html index 76265ecb1e..b989037a0c 100644 --- a/apps/mylocation/interface.html +++ b/apps/mylocation/interface.html @@ -2,6 +2,7 @@
+