bubbling up the 'closest' parameter to the higher-level map object api calls zoomToScale() and zoomToExtent(). Includes thorough tests. r=cr5 (Closes #1250)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7889 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1940,8 +1940,13 @@ 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.
|
||||
*
|
||||
*/
|
||||
zoomToExtent: function(bounds) {
|
||||
zoomToExtent: function(bounds, closest) {
|
||||
var center = bounds.getCenterLonLat();
|
||||
if (this.baseLayer.wrapDateLine) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
@@ -1965,7 +1970,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
//
|
||||
center = bounds.getCenterLonLat().wrapDateLine(maxExtent);
|
||||
}
|
||||
this.setCenter(center, this.getZoomForExtent(bounds));
|
||||
this.setCenter(center, this.getZoomForExtent(bounds, closest));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1995,8 +2000,13 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
*
|
||||
* Parameters:
|
||||
* scale - {float}
|
||||
* closest - {Boolean} Find the zoom level that most closely fits the
|
||||
* specified scale. Note that this may result in a zoom that does
|
||||
* not exactly contain the entire extent.
|
||||
* Default is false.
|
||||
*
|
||||
*/
|
||||
zoomToScale: function(scale) {
|
||||
zoomToScale: function(scale, closest) {
|
||||
var res = OpenLayers.Util.getResolutionFromScale(scale,
|
||||
this.baseLayer.units);
|
||||
var size = this.getSize();
|
||||
@@ -2008,7 +2018,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
this.zoomToExtent(extent);
|
||||
this.zoomToExtent(extent, closest);
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
|
||||
Reference in New Issue
Block a user