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
This commit is contained in:
euzuro
2006-07-16 16:41:54 +00:00
parent 460446f558
commit 629e62b82b
+6 -6
View File
@@ -262,12 +262,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
* *
* @returns An OpenLayers.LonLat which is the passed-in view port * @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by GMAPS * 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 * @type OpenLayers.LonLat
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null; var lonlat = null;
if (this.gmap != null) { if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gPoint = this.getGPointFromOLPixel(viewPortPx); var gPoint = this.getGPointFromOLPixel(viewPortPx);
var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint) var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint)
lonlat = this.getOLLonLatFromGLatLng(gLatLng); 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, * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY GMAPS * 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 * @type OpenLayers.Pixel
*/ */
getViewPortPxFromLonLat: function (lonlat) { getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null; var viewPortPx = null;
if (this.gmap != null) { if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gLatLng = this.getGLatLngFromOLLonLat(lonlat); var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
// note we use special hacked function here // note we use special hacked function here
@@ -302,12 +302,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* *
* @returns Corresponding zoom level for a specified 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 * @type int
*/ */
getZoomForExtent: function (bounds) { getZoomForExtent: function (bounds) {
var zoom = null; var zoom = null;
if (this.gmap != null) { if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
var gZoom = this.gmap.getBoundsZoomLevel(gBounds); var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
zoom = this.getOLZoomFromGZoom(gZoom); zoom = this.getOLZoomFromGZoom(gZoom);