From c5ad886d7c441a556a19ce659b129ba745ba43f9 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Mon, 18 Nov 2019 05:29:19 -0500 Subject: [PATCH] Ensure that OverviewMap respects the initial rotation of attached Maps --- src/ol/control/OverviewMap.js | 2 ++ test/spec/ol/control/overviewmap.test.js | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 6b0684938d..525bccdd22 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -304,6 +304,8 @@ class OverviewMap extends Control { */ bindView_(view) { view.addEventListener(getChangeEventType(ViewProperty.ROTATION), this.boundHandleRotationChanged_); + // Sync once with the new view + this.handleRotationChanged_(); } /** diff --git a/test/spec/ol/control/overviewmap.test.js b/test/spec/ol/control/overviewmap.test.js index 7ffa8a0f4f..64cf8c8e8d 100644 --- a/test/spec/ol/control/overviewmap.test.js +++ b/test/spec/ol/control/overviewmap.test.js @@ -35,7 +35,7 @@ describe('ol.control.OverviewMap', function() { const view = new View({ center: [0, 0], zoom: 0, - rotation: 0 + rotation: Math.PI / 2 }); map.setView(view); @@ -44,7 +44,7 @@ describe('ol.control.OverviewMap', function() { }); map.addControl(control); const ovView = control.ovmap_.getView(); - expect(ovView.getRotation()).to.be(0); + expect(ovView.getRotation()).to.be(Math.PI / 2); view.setRotation(Math.PI / 4); expect(ovView.getRotation()).to.be(Math.PI / 4); @@ -61,9 +61,11 @@ describe('ol.control.OverviewMap', function() { const view = new View({ center: [0, 0], zoom: 0, - rotation: 0 + rotation: Math.PI / 2 }); map.setView(view); + expect(ovView.getRotation()).to.be(Math.PI / 2); + view.setRotation(Math.PI / 4); expect(ovView.getRotation()).to.be(Math.PI / 4); });