don't get data while panning / zooming

during this time the map doesn't update anyhow
let's wait until the user is done, then immediately get the correct
viewbox of data
This commit is contained in:
Matthias Wirth
2022-07-12 21:24:24 +02:00
parent ea9ac54751
commit 81f62475f5

View File

@@ -303,8 +303,15 @@ function fetchData(options) {
return;
let currentTime = new Date().getTime();
if (!options.force && (currentTime - lastFetch < refreshInt() || pendingFetches > 0)) {
return;
if (!options.force) {
if (
currentTime - lastFetch < refreshInt()
|| pendingFetches > 0
|| OLMap.getView().getInteracting()
|| OLMap.getView().getAnimating()
) {
return;
}
}
if (debugFetch)
console.log((currentTime - lastFetch)/1000);
@@ -2516,6 +2523,7 @@ function initMap() {
case "e":
zoomIn();
break;
case "ArrowUp":
case "w":
oldCenter = OLMap.getView().getCenter();
extent = OLMap.getView().calculateExtent(OLMap.getSize());
@@ -2523,6 +2531,7 @@ function initMap() {
OLMap.getView().setCenter(newCenter);
toggleFollow(false);
break;
case "ArrowDown":
case "s":
oldCenter = OLMap.getView().getCenter();
extent = OLMap.getView().calculateExtent(OLMap.getSize());
@@ -2530,6 +2539,7 @@ function initMap() {
OLMap.getView().setCenter(newCenter);
toggleFollow(false);
break;
case "ArrowLeft":
case "a":
oldCenter = OLMap.getView().getCenter();
extent = OLMap.getView().calculateExtent(OLMap.getSize());
@@ -2537,6 +2547,7 @@ function initMap() {
OLMap.getView().setCenter(newCenter);
toggleFollow(false);
break;
case "ArrowRight":
case "d":
oldCenter = OLMap.getView().getCenter();
extent = OLMap.getView().calculateExtent(OLMap.getSize());