Merge pull request #13101 from M393/view-set-center-undefined

Fix View set center to undefined
This commit is contained in:
Tim Schaub
2021-12-09 10:37:31 -06:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -1738,6 +1738,7 @@ class View extends BaseObject {
this.set(ViewProperty.RESOLUTION, newResolution);
}
if (
!newCenter ||
!this.get(ViewProperty.CENTER) ||
!equals(this.get(ViewProperty.CENTER), newCenter)
) {

View File

@@ -562,6 +562,17 @@ describe('ol/View', function () {
});
});
describe('#setCenter()', function () {
it('allows setting undefined center', function () {
const view = new View({
center: [0, 0],
resolution: 1,
});
view.setCenter(undefined);
expect(view.getCenter()).to.be(undefined);
});
});
describe('#setHint()', function () {
it('changes a view hint', function () {
const view = new View({