[OpenLayers-Users] Set Z-Index of a Feature

Andreas Hocevar ahocevar at opengeo.org
Tue Jan 27 12:43:00 EST 2009


On Tue, Jan 27, 2009 at 5:46 PM, Dizzle <lacertosa_domenick at bah.com> wrote:
>
> I saw that example and I'm still having problems.  I have a function:
> function sendToBack(selectedFeature) {
> // selectedFeature is a OpenLayers.Feature.Vector
> ??
> }
> I can't get the z-index of selected feature to change.  It was a polygon
> created by using wkt.read("POLYGON((......))");

By default, features have no zIndex. It would be best if you give your
features a zIndex attribute, and create a stylemap which reads the
zIndex attribute and turns it into a graphicZIndex symbolizer
property. But looking at your code snippet, it seems you don't use the
new style framework. So you would have to give your layer a default
style with a graphicZIndex that you define.

> I've tried things like this:
> selectedFeature.style = OpenLayers.Util.applyDefaults({ graphicZIndex: 1},
> OpenLayers.Feature.Vector.style['default']);

As soon as your layer's default style has a graphicZIndex, this will
work. The only thing you have to change is call
layer.drawFeature(feature, style) instead of just setting the style.

Regards,
Andreas.

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



More information about the Users mailing list