[OpenLayers-Users] Setting the color of a single vector

Eric Lemoine eric.c2c at gmail.com
Tue Aug 5 11:52:29 EDT 2008


On Tue, Aug 5, 2008 at 11:04 AM, Jani Patokallio <jpatokal at iki.fi> wrote:
> Greetings,
>
> A very simple question, probably with a very simple answer, but I'm
> having a devil of a time figuring it out...
>
> I have a PointTrack layer with a StyleMap attached to it.  The StyleMap
> says strokeColor: yellow, so when I draw vectors on the layer, they're
> yellow.  My question is, how do I specify that one (1) vector should
> *not* be yellow, but red?
>
> Feature.Vector has style objects as an optional argument, but I have no
> idea what "style {Object} An optional style object" is supposed to mean,
> and my guess at "new Vector(point, {foo: "bar"}, {strokeColor: "red"})"
> does nothing.

If you create a feature using:

feature = new OpenLayers.Feature.Vector(point, {foo: "bar"},
    OpenLayers.Util.applyDefaults({"strokeColor": "red"},
OpenLayers.Feature.Vector.style["default"]);

that should work.

--
Eric



More information about the Users mailing list