From 27dae90c91814f97af003e21ce5d331ff4dcfa95 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Thu, 30 Apr 2026 17:42:55 +0200 Subject: [PATCH 1/2] support opening on coordinates via URL's hash --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 32f788b..60a6e1d 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,10 @@ var map = L.map('map', { zoomControl: false, // added manually below tapHold: true }); -if (localStorage.getItem('map.lat') === null) { +const [lat, lng] = window.location.hash.substring(1).split(","); +if (lat != undefined && lng != undefined) { + map.setView([lat, lng], localStorage.getItem('map.zoom') || 3); +} else if (localStorage.getItem('map.lat') === null) { map.setView([30, -30], 3); } else { map.setView([localStorage.getItem('map.lat'), localStorage.getItem('map.lng')], localStorage.getItem('map.zoom')); From f1341da986c01064af2a8f66a0f2f57d1c997603 Mon Sep 17 00:00:00 2001 From: Nico de Haen Date: Wed, 6 May 2026 18:05:53 +0200 Subject: [PATCH 2/2] fix: validate hash params --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 60a6e1d..e5e1ad6 100644 --- a/index.js +++ b/index.js @@ -6,9 +6,11 @@ var map = L.map('map', { zoomControl: false, // added manually below tapHold: true }); -const [lat, lng] = window.location.hash.substring(1).split(","); -if (lat != undefined && lng != undefined) { - map.setView([lat, lng], localStorage.getItem('map.zoom') || 3); +const hashParts = window.location.hash.substring(1).split(","); +const hashLat = parseFloat(hashParts[0]); +const hashLng = parseFloat(hashParts[1]); +if (!isNaN(hashLat) && !isNaN(hashLng)) { + map.setView([hashLat, hashLng], localStorage.getItem('map.zoom') || 3); } else if (localStorage.getItem('map.lat') === null) { map.setView([30, -30], 3); } else {