[OpenLayers-Users] SelectFeature selectStyle property

Ivan Grcic igrcic at gmail.com
Mon Feb 16 14:52:34 EST 2009


Hi,

http://openlayers.org/dev/examples/stylemap.html

On Mon, Feb 16, 2009 at 6:53 PM, Serge Travin <serge.travin at gmail.com> wrote:
> 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.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



-- 
Ivan Grcic



More information about the Users mailing list