[OpenLayers-Dev] vector layer with highest zIndex not overlaying other vector layers

crb jcbeaude at yahoo.com
Fri Oct 1 15:02:22 EDT 2010


Apologies for the duplicate posting, but it morphed from the original posting
that had a subject with a (probably well-known) unsupported feature.  

I'm having trouble w/ an aspect of a solution I'm trying to implement, and
that is having one vector layer (a "selected features" layer) display over
the top of another "location features" layer. Even though the zIndex of the
"selected features" layer is higher (as I can see when stepping through
Map.js.setLayerZIndex()) it's still not displaying over the "location
features" layer, even after a map.resetLayersZIndex(). 

Maybe there's another way around what I'm trying to do, but I think getting
the one vector feature to display over the top of the other will work. 

Ultimately the issue I'm trying to resolve is that having too many vector
features in the map (hundreds at a time) slows the browser performance down
too much (esp. IE, which is unusable).  We were originally loading all
vector features on map init. We changed it so that: 
   - vector features only display at a specific, zoomed-in scale 
   - only the features in the current map extent are displayed (i.e. the
callback to get the features is run on each map moveend event) 
   - features use a cluster strategy 

This all works fine.  Now the problem comes with selected features, which
we'd like to show at *all* scales, since they should only ever be a small
enough subset of all features that they don't affect browser performance,
and they are visible to the user regardless of the scale that they switch
to.  Originally we thought we would solve this by doing the following when a
feature in the "location features" layer is selected: 
1. clone the feature in the "location features" layer and add it to the
"selected features" layer (which has a higher zIndex), hoping that the
feature in the "selected features" layer would display over the top of the
locations layer 
2. show a popup on the feature (has to be the "location features" layer
since only it can have an associated SelectFeatures control) 

When unselecting the feature: 
1. delete the cloned feature from the "selected features" layer 
2. close the popup 

As you can see, this only works if the "selected features" layer actually
displays over the top of the "location features" layer.  Not sure yet if the
'selected' event will fire on the "location features" layer if the "selected
features" layer (eventually) overlays it. 

What's not working: 
- when selecting a single (non-clustered) feature in the "location features"
layer: 
     * all features in that layer briefly disappear 
     * the newly-added feature in the "selected features" layer briefly
appears 
     * the popup appears 
     * the "location features" layer overlays the "selected features" layer 
If I turn off the "location features" layer, I see this first feature (only)
in the "selected features" layer 
- only the first single selected feature is added to the "selected featues"
layer: subsequently-selected single features are not (even though when
debugging I can clearly see the call to
'selsLayerDef.addFeatures([feature])' executed) 
- when clustered features in the "location features" layer are selected,
they are not added to the "selected features" layer, even though when
selecting them I can see the array getting added: 

for (var i = 0; i < feature.cluster.length; i++) {
   hFeatures.push(feature.cluster[i].clone());
}
selsLayerDef.addFeatures(hFeatures); 

- on the SelectFeature control, both 'clickout' and 'toggle' are set to
'true', but when I do either in the map then the function associated with
onUnselect does not fire 

Note that 'displayInLayerSwitcher' is set to 'false' on my "selected
features" layer.  It correctly doesn't show up in the layer switcher, but
given its higher zIndex I would still expect it to render over the top of
the "location features" layer.

Should I be going about this a different way? 
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/vector-layer-with-highest-zIndex-not-overlaying-other-vector-layers-tp5592538p5592538.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list