From: mmd-osm Date: Tue, 21 Jan 2025 17:08:50 +0000 (+0100) Subject: Consistent usage of layer information in _osm_location cookie X-Git-Tag: live~2^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/18fd80ebb77b75622fb60bfa5ec64878a0c7bdc4?ds=inline;hp=--cc Consistent usage of layer information in _osm_location cookie Fixes #3971 --- 18fd80ebb77b75622fb60bfa5ec64878a0c7bdc4 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]);