[OpenLayers-Users] Vector layer: overlapping data

Tim Schaub tschaub at opengeo.org
Thu Mar 25 13:14:50 EDT 2010


Tim Schaub wrote:
> Daniel Degasperi wrote:
>> Hi,
>> I have a Vector Layer with Linestrings, which can also overlapp and I've 
>> applied a SelectFeature Control (with hover effect) to this Vector Layer.
>> My question is, is it possible to bring the current selected feature on 
>> top of all features?
> 

I updated [1] the StyleMap example [2] to demonstrate how to use 
z-indexing with different render intents.

In addition to using a graphicZIndex (will eventually be zIndex) 
property in your symbolizers, you need to enable z-indexing on the 
renderer.  To do this, set rendererOptions on your layer as shown in the 
example.

To see z-indexing with selection in action, refresh the example until 
you see overlapping points.  When you hover over a point, the render 
intent changes to "select" and you should see the selected feature drawn 
over others.

Tim

[1] http://trac.openlayers.org/changeset/10144
[2] http://openlayers.org/dev/examples/stylemap.html

> See http://trac.openlayers.org/ticket/1066 for the change that made this 
> the expected behavior (not to bring selected features to the top).
> 
> We could provide an option to change this behavior.
> 
> Alternatively, you should be able to give your vector layer a style map 
> with different styles for the "default" and "select" rendering intents. 
>   Using a graphicZIndex property in your symbolizers, you could have 
> selected features rendered above unselected features.
> 
> The graphicZIndex property is poorly named.  It looks to me like it 
> should apply to any symbolizer - not just a symbolizer that uses an 
> external graphic.  I'll confirm this and open a ticket about adding 
> support for a more appropriately named "zIndex" property on symbolizers.
> 
> Relevant examples:
> 
> Using graphicZIndex
> http://openlayers.org/dev/examples/marker-shadow.html
> 
> Using a StyleMap with multiple render intents
> http://openlayers.org/dev/examples/stylemap.html
> 
> Tim
> 
>> Best regards,
>> Daniel
>>
> 
> 


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Users mailing list