Prevent endless cycles as observed in #9796

Guard against endless cycle of attempts to reset extent which can occur if there is a constraint conflict
This commit is contained in:
mike-000
2019-09-05 21:03:21 +01:00
committed by GitHub
parent 4161831e29
commit dc420c53a4

View File

@@ -16,7 +16,7 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
import {replaceNode} from '../dom.js';
import {listen, listenOnce} from '../events.js';
import EventType from '../events/EventType.js';
import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight, scaleFromCenter} from '../extent.js';
import {containsExtent, equals as equalsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight, scaleFromCenter} from '../extent.js';
/**
@@ -303,7 +303,7 @@ class OverviewMap extends Control {
/**
* Handle rotation changes to the main map.
* TODO: This should rotate the extent rectrangle instead of the
* TODO: This should rotate the extent rectangle instead of the
* overview map's view.
* @private
*/
@@ -335,6 +335,12 @@ class OverviewMap extends Control {
const view = map.getView();
const extent = view.calculateExtent(mapSize);
if (this.viewExtent_ && equalsExtent(extent, this.viewExtent_)) {
// repeats of the same extent may indicate constraint conflicts leading to an endless cycle
return;
}
this.viewExtent_ = extent;
const ovmapSize = /** @type {import("../size.js").Size} */ (ovmap.getSize());
const ovview = ovmap.getView();