Merge pull request #1612 from twpayne/fix-view2d-fit-extent
Ensure that entire extent is visible in ol.View2D#fitExtent
This commit is contained in:
+6
-2
@@ -419,8 +419,12 @@ ol.View2D.prototype.fitExtent = function(extent, size) {
|
|||||||
if (!ol.extent.isEmpty(extent)) {
|
if (!ol.extent.isEmpty(extent)) {
|
||||||
this.setCenter(ol.extent.getCenter(extent));
|
this.setCenter(ol.extent.getCenter(extent));
|
||||||
var resolution = this.getResolutionForExtent(extent, size);
|
var resolution = this.getResolutionForExtent(extent, size);
|
||||||
resolution = this.constrainResolution(resolution, 0, 0);
|
var constrainedResolution = this.constrainResolution(resolution, 0, 0);
|
||||||
this.setResolution(resolution);
|
if (constrainedResolution < resolution) {
|
||||||
|
constrainedResolution =
|
||||||
|
this.constrainResolution(constrainedResolution, -1, 0);
|
||||||
|
}
|
||||||
|
this.setResolution(constrainedResolution);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user