save map location per path

this is useful when multiple receivers are viewable at different paths
on the same website
This commit is contained in:
Matthias Wirth
2025-11-10 08:50:51 +00:00
parent af2979916d
commit 67a890c3b2
2 changed files with 20 additions and 9 deletions

View File

@@ -179,6 +179,17 @@ if (0 && window.self != window.top) {
} }
} }
const lopaStore = new Proxy(loStore, {
get(loStore, key) {
key = String(window.location.origin) + String(window.location.pathname) + key;
return loStore[key];
},
set(loStore, key, value) {
key = String(window.location.origin) + String(window.location.pathname) + key;
return loStore[key] = value;
},
});
let firstError = true; let firstError = true;
if (usp.has('showerrors') || usp.has('jse')) { if (usp.has('showerrors') || usp.has('jse')) {
window.onerror = function (msg, url, lineNo, columnNo, error) { window.onerror = function (msg, url, lineNo, columnNo, error) {

View File

@@ -2788,10 +2788,10 @@ function showHideButtons() {
// Initalizes the map and starts up our timers to call various functions // Initalizes the map and starts up our timers to call various functions
function initMap() { function initMap() {
CenterLon = Number(loStore['CenterLon']) || DefaultCenterLon; CenterLon = Number(lopaStore['CenterLon']) || DefaultCenterLon;
CenterLat = Number(loStore['CenterLat']) || DefaultCenterLat; CenterLat = Number(lopaStore['CenterLat']) || DefaultCenterLat;
//console.log("initMap Centerlat: " + CenterLat); //console.log("initMap Centerlat: " + CenterLat);
g.zoomLvl = Number(loStore['zoomLvl']) || DefaultZoomLvl; g.zoomLvl = Number(lopaStore['zoomLvl']) || DefaultZoomLvl;
g.zoomLvlCache = g.zoomLvl; g.zoomLvlCache = g.zoomLvl;
// always hide this, it really only shows the number of positions saved // always hide this, it really only shows the number of positions saved
@@ -4708,9 +4708,9 @@ function resetMap() {
CenterLat = DefaultCenterLat; CenterLat = DefaultCenterLat;
} }
// Reset loStore values and map settings // Reset loStore values and map settings
loStore['CenterLat'] = CenterLat lopaStore['CenterLat'] = CenterLat
loStore['CenterLon'] = CenterLon lopaStore['CenterLon'] = CenterLon
//loStore['zoomLvl'] = g.zoomLvl = DefaultZoomLvl; //lopaStore['zoomLvl'] = g.zoomLvl = DefaultZoomLvl;
// Set and refresh // Set and refresh
//OLMap.getView().setZoom(g.zoomLvl); //OLMap.getView().setZoom(g.zoomLvl);
@@ -5650,7 +5650,7 @@ function changeZoom(init) {
if (!init && Math.abs(g.zoomLvl-g.zoomLvlCache) < 0.4) if (!init && Math.abs(g.zoomLvl-g.zoomLvlCache) < 0.4)
return; return;
loStore['zoomLvl'] = g.zoomLvl; lopaStore['zoomLvl'] = g.zoomLvl;
g.zoomLvlCache = g.zoomLvl; g.zoomLvlCache = g.zoomLvl;
if (!init && showTrace) if (!init && showTrace)
@@ -5712,8 +5712,8 @@ function changeCenter(init) {
return; return;
} }
loStore['CenterLon'] = CenterLon = center[0]; lopaStore['CenterLon'] = CenterLon = center[0];
loStore['CenterLat'] = CenterLat = center[1]; lopaStore['CenterLat'] = CenterLat = center[1];
if (!init) { if (!init) {
updateAddressBar(); updateAddressBar();