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() {
|
||||
|
||||
//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<77>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<77>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();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user