From e5dbb97ef27ba810c7be4ca5c6522401e2941a67 Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 14 Jul 2006 15:51:01 +0000 Subject: [PATCH] even if the wrong key is provided to gmaps, it still loads the GMap2 object. When you try to instantiate it, however, it errors. So we use a try statement and on error, we display the warning message. Nice git-svn-id: http://svn.openlayers.org/trunk/openlayers@944 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Google.js | 61 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js index 947478b9c7..3263458195 100644 --- a/lib/OpenLayers/Layer/Google.js +++ b/lib/OpenLayers/Layer/Google.js @@ -134,43 +134,36 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { loadGMap:function() { //has gmaps library has been loaded? - var gmapsLoaded = (typeof GMap2) != "undefined"; - if (!gmapsLoaded) { - this.loadWarningMessage(); - } else { - + try { // create GMap, hide nav controls this.gmap = new GMap2(this.div); - - if (this.gmap == null) { - this.loadWarningMessage(); - } else { - // this causes the GMap to set itself to Map's center/zoom - this.moveTo(); - - // catch pans and zooms from GMap - GEvent.addListener(this.gmap, - "moveend", - this.catchPanZoom.bindAsEventListener(this)); - - - // attach to the drag start and end and weŽll set a flag so that - // we dont get recursivity. this is because when we call setCenter(), - // it calls moveTo() on all layers - GEvent.addListener(this.gmap, - "dragstart", - this.dragStart.bindAsEventListener(this)); - - GEvent.addListener(this.gmap, - "dragend", - this.dragEnd.bindAsEventListener(this)); - - // catch pans and zooms from GMap - GEvent.addListener(this.gmap, - "drag", - this.catchPanZoom.bindAsEventListener(this)); - } + // this causes the GMap to set itself to Map's center/zoom + this.moveTo(); + + // catch pans and zooms from GMap + GEvent.addListener(this.gmap, + "moveend", + this.catchPanZoom.bindAsEventListener(this)); + + + // attach to the drag start and end and weŽll set a flag so that + // we dont get recursivity. this is because when we call setCenter(), + // it calls moveTo() on all layers + GEvent.addListener(this.gmap, + "dragstart", + this.dragStart.bindAsEventListener(this)); + + GEvent.addListener(this.gmap, + "dragend", + this.dragEnd.bindAsEventListener(this)); + + // catch pans and zooms from GMap + GEvent.addListener(this.gmap, + "drag", + this.catchPanZoom.bindAsEventListener(this)); + } catch (e) { + this.loadWarningMessage(); } },