From 149ca7efad89d185344e876a0bc485e65e5c1b33 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Tue, 31 Mar 2020 16:26:30 +0100 Subject: [PATCH] return previous extent if extents are approx equal --- src/ol/layer/Graticule.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ol/layer/Graticule.js b/src/ol/layer/Graticule.js index 6fc590283d..3994cd11a1 100644 --- a/src/ol/layer/Graticule.js +++ b/src/ol/layer/Graticule.js @@ -481,13 +481,18 @@ class Graticule extends VectorLayer { */ strategyFunction(extent, resolution) { // extents may be passed in different worlds, to avoid endless loop we use only one - const realWorldExtent = extent.slice(); + let realWorldExtent = extent.slice(); if (this.projection_ && this.getSource().getWrapX()) { wrapExtentX(realWorldExtent, this.projection_); } - if (this.loadedExtent_ && !approximatelyEquals(this.loadedExtent_, realWorldExtent, resolution)) { - // we should not keep track of loaded extents - this.getSource().removeLoadedExtent(this.loadedExtent_); + if (this.loadedExtent_) { + if (approximatelyEquals(this.loadedExtent_, realWorldExtent, resolution)) { + // make sure result is exactly equal to previous extent + realWorldExtent = this.loadedExtent_.slice(); + } else { + // we should not keep track of loaded extents + this.getSource().removeLoadedExtent(this.loadedExtent_); + } } return [realWorldExtent]; }