diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 086f674f30..fa2441d9d7 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -641,27 +641,47 @@ OpenLayers.Map.prototype = { /** * @returns A Bounds object which represents the lon/lat bounds of the - * current viewPort. + * current viewPort. + * If no baselayer is set, returns null. * @type OpenLayers.Bounds */ getExtent: function () { - return this.baseLayer.getExtent(); + var extent = null; + + if (this.baseLayer != null) { + extent = this.baseLayer.getExtent(); + } + return extent; }, /** - * @type float - */ + * @returns The current resolution of the map. + * If no baselayer is set, returns null. + * @type float + */ getResolution: function () { - return this.baseLayer.getResolution(); + var resolution = null; + + if (this.baseLayer != null) { + resolution = this.baseLayer.getResolution(); + } + return resolution; }, /** * @param {OpenLayers.Bounds} bounds * + * @returns A suitable zoom level for the specified bounds. + * If no baselayer is set, returns null. * @type int */ getZoomForExtent: function (bounds) { - return this.baseLayer.getZoomForExtent(bounds); + zoom = null; + + if (this.baseLayer != null) { + zoom = this.baseLayer.getZoomForExtent(bounds); + } + return zoom; }, /********************************************************/