[OpenLayers-Users] map initialize() question

Christopher Schmidt crschmidt at metacarta.com
Thu Feb 15 20:27:23 EST 2007


On Thu, Feb 15, 2007 at 04:44:58PM -0800, Anselm Hook wrote:
> I have a question regarding openlayers/lib/OpenLayers/Map.js / initialize() {}
> 
> It has a line like follows:
> 
>         this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
> 
> And I'm wondering if I can comment it out or say change the zIndex to
> a bigger number or something.  This line seems to occlude another
> layer that I am adding (a canvas layer that is no longer officially
> supported but presumably this issue would affect any other layer?).
> 
> It seems to work if I just comment it out...  just wanted to know if
> there were any other concerns.
>
> My impression is that it is trying to make sure the entire map layer
> is behind some kind of popup layer.  Popups do actually work for me
> under FireFox (I do know that this line may have something to do with
> Internet Explorer due to bugs cited in svn).

Yep. The problem is definitely IE related. I can't recall the exact
reason for it: I should have put a comment for it there, but I can't
remember it off the top of my head.

Essentially, there are two types of layers: fixed, and non-fixed. Canvas
is a fixed layer, because the implementation was never satisfactorily
completed such that it could be not-fixd. (this is also the reason it
leaks memory like a sieve.) Without that line, popups fail to work in IE
due to the intracacies of having different zindexes on parents of
layers. It's all a real mess, and the workaround isn't really any
cleaner than anything else. 

There is probably a cleaner work around for the Canvas issue, but
removing that shouldn't have any serious problems: it was a workaround
for a relatively small bug, and the reason it doens't have a better
solution is because there are no layers that are both: 
 
 * fixed 
 * used as overlays

other than Canvas.

Ah, here's the reason for that fix:

"""
IE treats non-assigned zIndex values as 0. children of an element with a 
zIndex set to 0 will always be below children of an element with a zIndex
set to 100. Because VirtualEarth sits outside the ContainerDiv, its maps were
always showing up over things contained inside the container div, such as 
markers. Acceptance test for this is to visit ./examples/ve.html and see if
the marker displays (should be over barcelona). IE, Firefox and Safari now
pass this acceptance test.
"""

(r1331 in
http://svn.openlayers.org/branches/openlayers/2.0/lib/OpenLayers/Map.js )

So, if you're using a fixed base layer (GMaps, VE, etc.), without this 
zindex set, you won't be able to see markers. If you're only using WMS, you
should have no problems.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list