[OpenLayers-Users] How to change style['select'] in OL 2.6
Arnd Wippermann
arnd.wippermann at web.de
Sun Apr 6 17:39:07 EDT 2008
It works.
But i'm not able to set the color of the vertices and the radius. Is there a
way to change these values as well?
And when I move a vertice, the feature will change to red (cleared the
selection?).
And the code works not for the ModifyFeature.Control.
Apart from this. With the SelectFeatureControl I can't toggle the selection
( i have to click outside the feature to unselect), but with the
ModifyFeature.Control it's possible. Shouldn't it be for both the same way?
Mit freundlichen Grüssen
Arnd Wippermann
http://gis.ibbeck.de/ginfo/
-----Ursprüngliche Nachricht-----
Von: andreas.hocevar at gmail.com [mailto:andreas.hocevar at gmail.com]
Gesendet: Sonntag, 6. April 2008 19:37
An: Arnd Wippermann
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] How to change style['select'] in OL 2.6
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