From 629e62b82beb653109b4337bedaa97c288aedcde Mon Sep 17 00:00:00 2001 From: euzuro Date: Sun, 16 Jul 2006 16:41:54 +0000 Subject: [PATCH] protect google base layer functions from an uncentered gmaps object git-svn-id: http://svn.openlayers.org/trunk/openlayers@949 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Google.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js index cda46fb83a..f2e2d33c55 100644 --- a/lib/OpenLayers/Layer/Google.js +++ b/lib/OpenLayers/Layer/Google.js @@ -262,12 +262,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { * * @returns An OpenLayers.LonLat which is the passed-in view port * OpenLayers.Pixel, translated into lon/lat by GMAPS - * If gmap is not loaded, returns null. + * If gmap is not loaded or not centered, returns null * @type OpenLayers.LonLat */ getLonLatFromViewPortPx: function (viewPortPx) { var lonlat = null; - if (this.gmap != null) { + if ((this.gmap != null) && (this.gmap.getCenter() != null)) { var gPoint = this.getGPointFromOLPixel(viewPortPx); var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint) lonlat = this.getOLLonLatFromGLatLng(gLatLng); @@ -281,12 +281,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { * * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, * translated into view port pixels BY GMAPS - * If gmap is not loaded, returns null. + * If gmap is not loaded or not centered, returns null * @type OpenLayers.Pixel */ getViewPortPxFromLonLat: function (lonlat) { var viewPortPx = null; - if (this.gmap != null) { + if ((this.gmap != null) && (this.gmap.getCenter() != null)) { var gLatLng = this.getGLatLngFromOLLonLat(lonlat); // note we use special hacked function here @@ -302,12 +302,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { * @param {OpenLayers.Bounds} bounds * * @returns Corresponding zoom level for a specified Bounds. - * If gmap is not loaded, returns null. + * If gmap is not loaded or not centered, returns null * @type int */ getZoomForExtent: function (bounds) { var zoom = null; - if (this.gmap != null) { + if ((this.gmap != null) && (this.gmap.getCenter() != null)) { var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); var gZoom = this.gmap.getBoundsZoomLevel(gBounds); zoom = this.getOLZoomFromGZoom(gZoom);