Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periods #4

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -811,6 +816,7 @@ function initMap() {
markerObject.marker.setVisible(isMarkerVisible(markerObject.age, periodFilter.periodToShow));
});
}
updateUrl(appState.map.getZoom(), appState.map.getCenter());
}

/*
Expand Down