same-case these functions for if there is no baselayer. in theory,

these should never be called if no baselayer is set... but one never
knows what a user will do. So instead of crashing, we will just return null.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@857 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-03 14:11:48 +00:00
parent af5e930c0a
commit 98302beddd
+26 -6
View File
@@ -641,27 +641,47 @@ OpenLayers.Map.prototype = {
/** /**
* @returns A Bounds object which represents the lon/lat bounds of the * @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 * @type OpenLayers.Bounds
*/ */
getExtent: function () { 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 () { getResolution: function () {
return this.baseLayer.getResolution(); var resolution = null;
if (this.baseLayer != null) {
resolution = this.baseLayer.getResolution();
}
return resolution;
}, },
/** /**
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* *
* @returns A suitable zoom level for the specified bounds.
* If no baselayer is set, returns null.
* @type int * @type int
*/ */
getZoomForExtent: function (bounds) { getZoomForExtent: function (bounds) {
return this.baseLayer.getZoomForExtent(bounds); zoom = null;
if (this.baseLayer != null) {
zoom = this.baseLayer.getZoomForExtent(bounds);
}
return zoom;
}, },
/********************************************************/ /********************************************************/