diff --git a/src/ol/View.js b/src/ol/View.js index 1e7e5e9477..0faf434d73 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -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) ) { diff --git a/test/browser/spec/ol/View.test.js b/test/browser/spec/ol/View.test.js index 9bc5df0a88..7246d8b85d 100644 --- a/test/browser/spec/ol/View.test.js +++ b/test/browser/spec/ol/View.test.js @@ -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({