[OpenLayers-Dev] Feature.style doesn't support contexts
eric.lemoine at camptocamp.com
Fri Jan 15 17:05:30 EST 2010
On Fri, Jan 15, 2010 at 8:10 PM, Alexandre Dube <adube at mapgears.com> wrote:
> I want to be able to save a OpenLayers.Style object or hash to a
> vector feature. Currently, in code, feature.style exists but you must
> define a hash or else it doesn't work.
> My problem is that I want to be able to draw features to be used as
> labels (floating text on the map). To be able to do so, I need to
> define a StyleMap with a context to display the label (I manually set
> feature.isLabel on "featureadded") 
> That works well, but as soon as I want to "bind / save" the style to
> the feature, I mean set feature.style,
feature.style is for the old way of styling features
> I need to set a hash and the
> feature will be rendered without the contexts.
if you want to get the symbolizer (style hash) of a feature use
> I don't fully understand how the contexts, symbolizers, etc. work, but
> my first guess would be to support OpenLayers.Style object directly in
> the feature object. Does that make sense ?
> Or maybe I'm doing it wrong and their's an other way of "labeling"
> features. My goal is to create features on a "cosmetic" layer with a
> default style, then to be able to change the style of the features and
> bind it to them (I mean without using rules on the layer level, but by
> defining directly the feature style)
I guess binding a symbolizer to a feature can only be done with
feature.style. So feature.style = styleMap.createSymbolizer(feature)
may be what you're looking for.
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
More information about the Dev