[OpenLayers-Users] FEatures orders

Andreas Hocevar ahocevar at opengeo.org
Fri Jan 16 08:16:35 EST 2009


Hi,

On Fri, Jan 16, 2009 at 1:37 PM, darrepac <pascal.darre at laposte.net> wrote:
> I have a GEoJson file with my feature inside. I am able to select feature
> with openlayers by clicking on it.
> Some features are over other, for example a small rectangle area is over a
> bigger rectangle.
> When it is in this order, there is no problem (I can select the small and
> the big rectangle) but when it is the reverse (=the small rectangle is below
> the big rectangle), I cannot select the small rectangle area.
>
> The problem is I do not master the ordering. I try to order the feature in
> the GeoJson file thinking that first written, first drawn, but whenever I
> select the big rectangle it seems to go back to front and so the small
> rectangle is no more accessible.
>
> Any idea on how to manage this?

You could use z-indexing on the layer. See
http://www.openlayers.org/dev/examples/ordering.html for an example.

You would probably have to sort your features by size, and create
ascending z-indices with descending size. This would ensure that
smaller rectangles will be drawn on top of larger ones.

Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list