[OpenLayers-Users] How to change style['select'] in OL 2.6
Andreas Hocevar
andreas.hocevar at gmail.com
Sun Apr 6 13:37:13 EDT 2008
Arnd Wippermann wrote:
> Hi,
>
> First, a great compliment to all the developers of OL. And best, only some
> easy changes needed to update own applications from 2.5 to 2.6.
>
> But some behaviour I'm used to in 2.5, I could not solve for 2.6.
>
> In OL 2.5 I do this to draw red features and draw select features in yellow:
>
> OpenLayers.Feature.Vector.style['select']['fillColor'] = 'yellow';
> OpenLayers.Feature.Vector.style['select']['strokeColor'] = 'yellow';
>
> var layer_style = OpenLayers.Util.extend({},
> OpenLayers.Feature.Vector.style['default']);
>
> style_red = OpenLayers.Util.extend({}, layer_style);
> style_red.strokeColor = "red";
> style_red.fillColor = "red";
>
> vector = new OpenLayers.Layer.Vector("Editable Vectors", {style:
> style_red});
>
>
> With OL 2.6 I have no luck. The features will drawn in red, but the selected
> features are also in red.
>
> How can I change the default style for selected features in OL 2.6?
>
The simplest way would be
var selectStyle = OpenLayers.Util.applyDefaults({
fillColor: "yellow",
strokeColor: "yellow"}, OpenLayers.Feature.Vector.style["select"]);
var selectFeatureControl = OpenLayers.Control.SelectFeature(yourLayer, {
selectStyle: selectStyle});
Regards,
Andreas.
More information about the Users
mailing list