Add secure check to set map bounds with narrative

This commit is contained in:
Franc Camps-Febrer
2019-01-08 17:52:09 +01:00
committed by Lachlan Kermode
parent b84e59cd28
commit aa3da2d744

View File

@@ -52,10 +52,12 @@ function updateNarrative(appState, action) {
if (stepTime < minTime) minTime = stepTime;
if (stepTime > maxTime) maxTime = stepTime;
if (+step.longitude < cornerBound0[1]) cornerBound0[1] = +step.longitude;
if (+step.longitude > cornerBound1[1]) cornerBound1[1] = +step.longitude;
if (+step.latitude < cornerBound0[0]) cornerBound0[0] = +step.latitude;
if (+step.latitude > cornerBound1[0]) cornerBound1[0] = +step.latitude;
if (!!step.longitude && !!step.latitude) {
if (+step.longitude < cornerBound0[1]) cornerBound0[1] = +step.longitude;
if (+step.longitude > cornerBound1[1]) cornerBound1[1] = +step.longitude;
if (+step.latitude < cornerBound0[0]) cornerBound0[0] = +step.latitude;
if (+step.latitude > cornerBound1[0]) cornerBound1[0] = +step.latitude;
}
});
minTime = new Date(minTime.getTime() - Math.abs((maxTime - minTime) / 10));
@@ -71,7 +73,7 @@ function updateNarrative(appState, action) {
filters: {
...appState.filters,
timerange: [minTime, maxTime],
mapBounds: [cornerBound0, cornerBound1]
mapBounds: (action.narrative) ? [cornerBound0, cornerBound1] : null
}
}
}