diff --git a/map.js b/map.js index 6603920c..9d2e47dc 100644 --- a/map.js +++ b/map.js @@ -13,6 +13,10 @@ function initMap() { "map": null, // The selected (or initial) municipality: "activeMunicipality": "Hoorn", + // The selected (or initial) period: + "period": "14d", + // Indicates the status of the period filter: + "isHistoryActive": false, // The zoom level when starting the app: "initialZoomLevel": 16, // The marker objects of the municipalities: @@ -25,8 +29,6 @@ function initMap() { "publicationsArray": [], // Backup of the recent publications, because loading them again is slow: "publicationsArrayBackup": [], - // Indicates the status of the time filter: - "isHistoryActive": false, // Indicates if all parts are loaded: "isFullyLoaded": false, // Order of different license markers, newest on top. Set to some high number: @@ -54,6 +56,15 @@ function initMap() { console.log("Adjusted municipality from URL: " + municipalityParam); } center = Object.assign({}, municipalities[appState.activeMunicipality].center); + if (periodParam) { + const period = periods.find(function (p) { + return p.key === periodParam; + }); + if (period !== undefined) { + appState.period = period.key; + console.log("Adjusted period " + period.key + " from URL"); + } + } if (zoomParam && centerParam) { zoomParam = parseFloat(zoomParam); if (zoomParam > 14 && zoomParam < 20) { @@ -691,20 +702,14 @@ function initMap() { const result = { "elm": document.getElementById("idCbxPeriod"), - "period": "14d", - "periodToShow": "14d", - "isHistory": false + "period": appState.period, + "isHistory": isHistoricalPeriod(appState.period) }; - if (result.elm === null) { - return result; // Default when loading - } // If this is an historical period, default to 'all': - result.period = result.elm.value; - if (isHistoricalPeriod(result.elm.value)) { + if (result.isHistory) { result.periodToShow = "all"; - result.isHistory = true; } else { - result.periodToShow = result.elm.value; + result.periodToShow = appState.period; } return result; } @@ -811,6 +816,7 @@ function initMap() { markerObject.marker.setVisible(isMarkerVisible(markerObject.age, periodFilter.periodToShow)); }); } + updateUrl(appState.map.getZoom(), appState.map.getCenter()); } /*