[OpenLayers-Trac] [OpenLayers] #3518: VirtualEarth sometimes broken
in Mozilla
OpenLayers
trac-20090302 at openlayers.org
Sat Sep 24 20:56:36 EDT 2011
#3518: VirtualEarth sometimes broken in Mozilla
--------------------------------+-------------------------------------------
Reporter: philipn | Owner: ahocevar
Type: feature | Status: new
Priority: major | Milestone: 2.12 Release
Component: Layer.VirtualEarth | Version: 2.11 RC3
Keywords: | State:
--------------------------------+-------------------------------------------
I've noticed that VirtualEarth layers don't always appear in Firefox. In
particular, they don't seem to always load correctly when there's other
base layers in the mix.
It looks like this is because the VirtualEarth JS incorrectly calls
{{{window.attachEvent}}}, which doesn't exist in Firefox:
From the VE Init() method, beautified:
{{{
...
graphicCanvas = GetGraphic(this);
window.attachEvent("onresize", WindowResizeSVG);
tileLayerManager.Active = true;
...
}}}
There are other instances in the VE js where {{{window.attachEvent}}} are
called, but they don't appear to screw up OL, at least in my experiences.
It looks like {{{Layer.VirtualEarth}}} tries to cover this up by using a
{{{try/catch}}} block:
{{{
if (this.mapObject != null) {
try { // this is to catch a Mozilla bug without falling apart
...
} catch (e) { }
...
}
}}}
This just stops OL from crashing -- the layer can remain unloaded. My
attached patch replaces this {{{try/catch}}} with a check for the
existence of {{{window.attachEvent}}} and temporarily monkey-patches in a
working {{{window.attachEvent}}} for the duration of the map load call.
The patch fixes all issues I'm seeing with VE layer loading in FF.
------
I've attached an example that reproduces this issue for me. I'm using FF
6.0.2 and, additionally, the olwidget OL wrapper. It doesn't appear to
have anything to do with the OL wrapper I'm using, but I didn't have time
to come up with a new test case. Toggling to the VE later produces the
error {{{mapInstance.GetCurrentMode() is null}}}
--
Ticket URL: <http://trac.openlayers.org/ticket/3518>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list