[OpenLayers-Dev] Feature.style doesn't support contexts

Eric Lemoine eric.lemoine at camptocamp.com
Sat Jan 16 13:03:11 EST 2010


On Saturday, January 16, 2010, Cédric Moullet  wrote:
> Hi Eric,Thanks for your answer.
> However, I'm not sure that I have really understand it. The goal is to set a style to one feature (to assign feature.style).
> I assume that the example http://www.openlayers.org/dev/examples/symbolizers-fill-stroke-graphic.html corresponds to the new way of symbolizing feature. Is it correct ?

Yes it is.

> What is not clear to me is how to assign a style to a specific feature. There is a function createSymbolizer(feature) in Style.js (http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Style.js#L148) and a function createSymbolizer(feature, intent) in StyleMap.js http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/StyleMap.js#L108
>
>
> You proposed to use styleMap.createSymbolizer(feature), shouldn't it be styleMap.createSymbolizer(feature, intent) ?

if intent is undefined createSymbolizer uses "default" as the render intent.


> This implies that in order to manage "free style", it is required to add a Style in the StyleMap and assign to feature.style this style. Is it correct ?

What do you mean by "free style"? A user-defined style that isn't
derived by rules or a context?

It seems to me that you want to mix context-based styling and
per-feature user-defined styling.

What about that: when user wants to modify a feature's style call
createSymbolizer to get the feature's current style, modify the
returned style object as requested by the user and store  it in
feature.style.

There may be other options, but this is the one I see at this point.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Dev mailing list