Merge pull request #10310 from brianhelba/overview-rotation

Ensure that OverviewMap respects the initial rotation of attached Maps
This commit is contained in:
Olivier Guyot
2019-11-18 16:40:54 +01:00
committed by GitHub
2 changed files with 7 additions and 3 deletions
+2
View File
@@ -304,6 +304,8 @@ class OverviewMap extends Control {
*/ */
bindView_(view) { bindView_(view) {
view.addEventListener(getChangeEventType(ViewProperty.ROTATION), this.boundHandleRotationChanged_); view.addEventListener(getChangeEventType(ViewProperty.ROTATION), this.boundHandleRotationChanged_);
// Sync once with the new view
this.handleRotationChanged_();
} }
/** /**
+5 -3
View File
@@ -35,7 +35,7 @@ describe('ol.control.OverviewMap', function() {
const view = new View({ const view = new View({
center: [0, 0], center: [0, 0],
zoom: 0, zoom: 0,
rotation: 0 rotation: Math.PI / 2
}); });
map.setView(view); map.setView(view);
@@ -44,7 +44,7 @@ describe('ol.control.OverviewMap', function() {
}); });
map.addControl(control); map.addControl(control);
const ovView = control.ovmap_.getView(); const ovView = control.ovmap_.getView();
expect(ovView.getRotation()).to.be(0); expect(ovView.getRotation()).to.be(Math.PI / 2);
view.setRotation(Math.PI / 4); view.setRotation(Math.PI / 4);
expect(ovView.getRotation()).to.be(Math.PI / 4); expect(ovView.getRotation()).to.be(Math.PI / 4);
@@ -61,9 +61,11 @@ describe('ol.control.OverviewMap', function() {
const view = new View({ const view = new View({
center: [0, 0], center: [0, 0],
zoom: 0, zoom: 0,
rotation: 0 rotation: Math.PI / 2
}); });
map.setView(view); map.setView(view);
expect(ovView.getRotation()).to.be(Math.PI / 2);
view.setRotation(Math.PI / 4); view.setRotation(Math.PI / 4);
expect(ovView.getRotation()).to.be(Math.PI / 4); expect(ovView.getRotation()).to.be(Math.PI / 4);
}); });