From 81f62475f5afabbe0da47ba1fe0d86df1c3dfd90 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Tue, 12 Jul 2022 21:24:24 +0200 Subject: [PATCH] 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 --- html/script.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/html/script.js b/html/script.js index e622e37..3760467 100644 --- a/html/script.js +++ b/html/script.js @@ -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());