Ensure that entire extent is visible in ol.View2D#fitExtent

This commit is contained in:
Tom Payne
2014-01-28 18:55:37 +01:00
parent f0c1f03ae7
commit 6bc11142e8

View File

@@ -419,8 +419,12 @@ ol.View2D.prototype.fitExtent = function(extent, size) {
if (!ol.extent.isEmpty(extent)) {
this.setCenter(ol.extent.getCenter(extent));
var resolution = this.getResolutionForExtent(extent, size);
resolution = this.constrainResolution(resolution, 0, 0);
this.setResolution(resolution);
var constrainedResolution = this.constrainResolution(resolution, 0, 0);
if (constrainedResolution < resolution) {
constrainedResolution =
this.constrainResolution(constrainedResolution, -1, 0);
}
this.setResolution(constrainedResolution);
}
};