diff --git a/index.js b/index.js index 32f788b..e5e1ad6 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,12 @@ var map = L.map('map', { zoomControl: false, // added manually below tapHold: true }); -if (localStorage.getItem('map.lat') === null) { +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 { map.setView([localStorage.getItem('map.lat'), localStorage.getItem('map.lng')], localStorage.getItem('map.zoom'));