Merge pull request #11561 from M393/view-constrain-center-after-fit

Constrain resolution when fit called without duration
This commit is contained in:
Olivier Guyot
2020-09-16 09:11:11 +02:00
committed by GitHub
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -1290,14 +1290,14 @@ class View extends BaseObject {
centerRotY += ((padding[0] - padding[2]) / 2) * resolution;
const centerX = centerRotX * cosAngle - centerRotY * sinAngle;
const centerY = centerRotY * cosAngle + centerRotX * sinAngle;
const center = [centerX, centerY];
const center = this.getConstrainedCenter([centerX, centerY], resolution);
const callback = options.callback ? options.callback : VOID;
if (options.duration !== undefined) {
this.animateInternal(
{
resolution: resolution,
center: this.getConstrainedCenter(center, resolution),
center: center,
duration: options.duration,
easing: options.easing,
},
+6
View File
@@ -1776,6 +1776,12 @@ describe('ol.View', function () {
expect(view.getCenter()[0]).to.be(1500);
expect(view.getCenter()[1]).to.be(1500);
});
it('fits correctly to the extent when a view extent is configured', function () {
view.options_.extent = [1500, 0, 2500, 10000];
view.applyOptions_(view.options_);
view.fit([1000, 1000, 2000, 2000]);
expect(view.calculateExtent()).eql([1500, 1000, 2500, 2000]);
});
it('throws on invalid geometry/extent value', function () {
expect(function () {
view.fit(true, [200, 200]);