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:
@@ -134,43 +134,36 @@ 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();
|
||||||
|
|
||||||
// catch pans and zooms from GMap
|
// catch pans and zooms from GMap
|
||||||
GEvent.addListener(this.gmap,
|
GEvent.addListener(this.gmap,
|
||||||
"moveend",
|
"moveend",
|
||||||
this.catchPanZoom.bindAsEventListener(this));
|
this.catchPanZoom.bindAsEventListener(this));
|
||||||
|
|
||||||
|
|
||||||
// attach to the drag start and end and we´ll set a flag so that
|
// 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(),
|
// we dont get recursivity. this is because when we call setCenter(),
|
||||||
// it calls moveTo() on all layers
|
// it calls moveTo() on all layers
|
||||||
GEvent.addListener(this.gmap,
|
GEvent.addListener(this.gmap,
|
||||||
"dragstart",
|
"dragstart",
|
||||||
this.dragStart.bindAsEventListener(this));
|
this.dragStart.bindAsEventListener(this));
|
||||||
|
|
||||||
GEvent.addListener(this.gmap,
|
GEvent.addListener(this.gmap,
|
||||||
"dragend",
|
"dragend",
|
||||||
this.dragEnd.bindAsEventListener(this));
|
this.dragEnd.bindAsEventListener(this));
|
||||||
|
|
||||||
// catch pans and zooms from GMap
|
// catch pans and zooms from GMap
|
||||||
GEvent.addListener(this.gmap,
|
GEvent.addListener(this.gmap,
|
||||||
"drag",
|
"drag",
|
||||||
this.catchPanZoom.bindAsEventListener(this));
|
this.catchPanZoom.bindAsEventListener(this));
|
||||||
}
|
} catch (e) {
|
||||||
|
this.loadWarningMessage();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user