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
This commit is contained in:
euzuro
2006-07-14 15:51:01 +00:00
parent eb6c2a6346
commit e5dbb97ef2
+3 -10
View File
@@ -134,18 +134,10 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
loadGMap:function() { loadGMap:function() {
//has gmaps library has been loaded? //has gmaps library has been loaded?
var gmapsLoaded = (typeof GMap2) != "undefined"; try {
if (!gmapsLoaded) {
this.loadWarningMessage();
} else {
// create GMap, hide nav controls // create GMap, hide nav controls
this.gmap = new GMap2(this.div); 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 causes the GMap to set itself to Map's center/zoom
this.moveTo(); this.moveTo();
@@ -170,7 +162,8 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
GEvent.addListener(this.gmap, GEvent.addListener(this.gmap,
"drag", "drag",
this.catchPanZoom.bindAsEventListener(this)); this.catchPanZoom.bindAsEventListener(this));
} } catch (e) {
this.loadWarningMessage();
} }
}, },