Can't return an extent before center is set.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@106 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-05-17 17:21:11 +00:00
parent 9235f04cce
commit efbd12fc29

View File

@@ -182,15 +182,19 @@ OpenLayers.Map.prototype = {
* @return {OpenLayers.Bounds}
*/
getExtent: function () {
var res = this.getResolution();
var size = this.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
return new OpenLayers.Bounds(
this.center.lon - w_deg / 2,
this.center.lat - h_deg / 2,
this.center.lon + w_deg / 2,
this.center.lat + h_deg / 2);
if (this.center) {
var res = this.getResolution();
var size = this.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
return new OpenLayers.Bounds(
this.center.lon - w_deg / 2,
this.center.lat - h_deg / 2,
this.center.lon + w_deg / 2,
this.center.lat + h_deg / 2);
} else {
return null;
}
},
/**