[OpenLayers-Users] SelectFeature selectStyle property

Serge Travin serge.travin at gmail.com
Mon Feb 16 12:53:06 EST 2009


Hi,
I'm using SelectFeature control and I want to set custom styles for
features, when they are in default and selected state.
Well, I've created feature and set it's style like this:

var defaultStyle = OpenLayers.Util.extend({},
            OpenLayers.Feature.Vector.style['default']
        );
defaultStyle.strokeColor = mapBounds.color;
defaultStyle.fillOpacity = 0.0;
feature.style = defaultStyle;

and also I set selectStyle for SelectFeature control:

 var selectStyle = OpenLayers.Util.extend({},
            OpenLayers.Feature.Vector.style['default']
        );
 selectStyle.strokeColor = mapBounds.color;
 selectStyle.strokeWidth = 2;
 selectStyle.fillOpacity = 0.2;
 sf.selectStyle = selectStyle;

Everything is ok, except this case:

Feature is selected, it's drawn with select style, then I perform
zoom-in(out). and feature's style changes to default.
It's still selected, just drawn with default style.

I can avoid this by modifying feature style each time it's
selected/unselected, but I don't think it's a good idea.

Could anyone suggest smth?
Thanks in advance.

---
wbr, Serge Travin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090216/45869641/attachment.html


More information about the Users mailing list