From 2537da690af03614788afcf80c681de7c6183b0d Mon Sep 17 00:00:00 2001 From: Edward Nash Date: Mon, 30 Mar 2020 07:15:03 +0200 Subject: [PATCH] Add check that Position is set in panIntoView() * If panIntoView is an API method, it may now be called when the position of the overlay has not yet been set. * Adds a check for a set position to the panIntoView() method, and removes the now unneccessary check in handlePositionChanged() --- src/ol/Overlay.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index dff3e1fe25..7b82dfe5f4 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -328,9 +328,7 @@ class Overlay extends BaseObject { */ handlePositionChanged() { this.updatePixelPosition(); - if (this.get(Property.POSITION) && this.autoPan) { - this.performAutoPan(); - } + this.performAutoPan(); } /** @@ -403,7 +401,7 @@ class Overlay extends BaseObject { panIntoView(panIntoViewOptions) { const map = this.getMap(); - if (!map || !map.getTargetElement()) { + if (!map || !map.getTargetElement() || !this.get(Property.POSITION)) { return; }