From efbd12fc29679f212a56d348b841452df3c859f0 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 17 May 2006 17:21:11 +0000 Subject: [PATCH] Can't return an extent before center is set. git-svn-id: http://svn.openlayers.org/trunk/openlayers@106 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 18042517fb..b23ab7c9ee 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -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; + } }, /**