Use calculateBounds function from patch on #228. This is a refactoring of the
code that Tim Schaub contributed on that patch. Thanks Tim! git-svn-id: http://svn.openlayers.org/trunk/openlayers@1702 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -607,6 +607,41 @@ OpenLayers.Map.prototype = {
|
||||
return size;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} center Default is this.getCenter()
|
||||
* @param {float} resolution Default is this.getResolution()
|
||||
*
|
||||
* @returns A Bounds based on resolution, center, and current mapsize.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
calculateBounds: function(center, resolution) {
|
||||
|
||||
var extent = null;
|
||||
|
||||
if (center == null) {
|
||||
center = this.getCenter();
|
||||
}
|
||||
if (resolution == null) {
|
||||
resolution = this.getResolution();
|
||||
}
|
||||
|
||||
if ((center != null) && (resolution != null)) {
|
||||
|
||||
var size = this.getSize();
|
||||
var w_deg = size.w * resolution;
|
||||
var h_deg = size.h * resolution;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Zoom, Center, Pan Functions */
|
||||
|
||||
Reference in New Issue
Block a user