Change to getZoomForResolution() (and those who call it) so that it does not choose the closest fit by default. Doing so was causing us problems, because user would drag a zoom box and then the map's new zoom would not contain said zoombox. Not good. Default is back to how it was before, but now there's an option 'closest' for those times when what we really want is the closest. Right now, the only time that's true is when we're switching baselayers. This is based on the work from sandbox/euzuro/zoomToResolution, which is started by reverting r4318. (Closes #1043)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4792 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+17
-6
@@ -711,13 +711,13 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
// simply set center but force zoom change
|
||||
this.setCenter(
|
||||
center,
|
||||
this.getZoomForResolution(this.resolution),
|
||||
this.getZoomForResolution(this.resolution, true),
|
||||
false, true
|
||||
);
|
||||
} else {
|
||||
// zoom to oldExtent *and* force zoom change
|
||||
this.setCenter(oldExtent.getCenterLonLat(),
|
||||
this.getZoomForExtent(oldExtent),
|
||||
this.getZoomForExtent(oldExtent, true),
|
||||
false, true);
|
||||
}
|
||||
}
|
||||
@@ -1367,15 +1367,19 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
* closest - {Boolean} Find the zoom level that most closely fits the
|
||||
* specified bounds. Note that this may result in a zoom that does
|
||||
* not exactly contain the entire extent.
|
||||
* Default is false.
|
||||
*
|
||||
* Returns:
|
||||
* {Integer} A suitable zoom level for the specified bounds.
|
||||
* If no baselayer is set, returns null.
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
getZoomForExtent: function (bounds, closest) {
|
||||
var zoom = null;
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForExtent(bounds);
|
||||
zoom = this.baseLayer.getZoomForExtent(bounds, closest);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -1385,15 +1389,22 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
*
|
||||
* Parameter:
|
||||
* resolution - {Float}
|
||||
* closest - {Boolean} Find the zoom level that corresponds to the absolute
|
||||
* closest resolution, which may result in a zoom whose corresponding
|
||||
* resolution is actually smaller than we would have desired (if this
|
||||
* is being called from a getZoomForExtent() call, then this means that
|
||||
* the returned zoom index might not actually contain the entire
|
||||
* extent specified... but it'll be close).
|
||||
* Default is false.
|
||||
*
|
||||
* Returns:
|
||||
* {Integer} A suitable zoom level for the specified resolution.
|
||||
* If no baselayer is set, returns null.
|
||||
*/
|
||||
getZoomForResolution: function(resolution) {
|
||||
getZoomForResolution: function(resolution, closest) {
|
||||
var zoom = null;
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForResolution(resolution);
|
||||
zoom = this.baseLayer.getZoomForResolution(resolution, closest);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user