From 18fd80ebb77b75622fb60bfa5ec64878a0c7bdc4 Mon Sep 17 00:00:00 2001 From: mmd-osm Date: Tue, 21 Jan 2025 18:08:50 +0100 Subject: [PATCH] Consistent usage of layer information in _osm_location cookie Fixes #3971 --- app/assets/javascripts/osm.js.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index e9c09c79f..3edd9b451 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -80,7 +80,7 @@ OSM = { }, mapParams: function (search) { - var params = OSM.params(search), mapParams = {}, loc, match; + var params = OSM.params(search), mapParams = {}, match; if (params.mlon && params.mlat) { mapParams.marker = true; @@ -101,6 +101,8 @@ OSM = { var hash = OSM.parseHash(location.hash); + const loc = Cookies.get('_osm_location')?.split("|"); + // Decide on a map starting position. Various ways of doing this. if (hash.center) { mapParams.lon = hash.center.lng; @@ -119,8 +121,7 @@ OSM = { mapParams.lon = parseFloat(params.mlon); mapParams.lat = parseFloat(params.mlat); mapParams.zoom = parseInt(params.zoom || 12); - } else if (loc = Cookies.get('_osm_location')) { - loc = loc.split("|"); + } else if (loc) { mapParams.lon = parseFloat(loc[0]); mapParams.lat = parseFloat(loc[1]); mapParams.zoom = parseInt(loc[2]); -- 2.39.5