diff --git a/lib/OpenLayers/Layer/VirtualEarth.js b/lib/OpenLayers/Layer/VirtualEarth.js index 2385138405..95c2ad1191 100644 --- a/lib/OpenLayers/Layer/VirtualEarth.js +++ b/lib/OpenLayers/Layer/VirtualEarth.js @@ -75,16 +75,30 @@ OpenLayers.Layer.VirtualEarth.prototype = // create VEMap, hide nav controls this.vemap = new VEMap(this.name); - this.vemap.LoadMap(); - this.vemap.HideDashboard(); - - // catch pans and zooms from VE Map - this.vemap.AttachEvent("onendcontinuouspan", - this.catchPanZoom.bindAsEventListener(this)); - this.vemap.AttachEvent("onendzoom", - this.catchPanZoom.bindAsEventListener(this)); } catch (e) { + // do nothing this is to keep from crashing + // if the VE library was not loaded. + } + + + if (this.vemap == null) { this.loadWarningMessage(); + } else { + + + try { + this.vemap.LoadMap(); + } catch (e) { + // this is to catch a Mozilla bug without falling apart + } + + this.vemap.HideDashboard(); + + // catch pans and zooms from VE Map + this.vemap.AttachEvent("onendcontinuouspan", + this.catchPanZoom.bindAsEventListener(this)); + this.vemap.AttachEvent("onendzoom", + this.catchPanZoom.bindAsEventListener(this)); } }, @@ -142,7 +156,8 @@ OpenLayers.Layer.VirtualEarth.prototype = /** * @param {event} e */ - catchPanZoom: function(e) { + catchPanZoom: function(e) { + var veCenter = this.vemap.GetCenter(); var veZoom = this.vemap.GetZoomLevel();