Hi Eric,<div>Thanks for your answer. </div><div><br></div><div>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). </div><div>I assume that the example <a href="http://www.openlayers.org/dev/examples/symbolizers-fill-stroke-graphic.html">http://www.openlayers.org/dev/examples/symbolizers-fill-stroke-graphic.html</a> corresponds to the new way of symbolizing feature. Is it correct ?</div>
<div><br></div><div>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 (<a href="http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Style.js#L148">http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Style.js#L148</a>) and a function createSymbolizer(feature, intent) in StyleMap.js <a href="http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/StyleMap.js#L108">http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/StyleMap.js#L108</a> </div>
<div><br></div><div>You proposed to use styleMap.createSymbolizer(feature), shouldn't it be styleMap.createSymbolizer(feature, intent) ?</div><div><br></div><div>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 ? </div>
<div><br></div><div>In the specific label case, the style needs to contain a rule's symbolizer with a label property: </div><div><div>styleMap: new OpenLayers.StyleMap({</div><div> 'default': new OpenLayers.Style(null, {</div>
<div> rules: [</div><div> new OpenLayers.Rule({</div><div> symbolizer: {</div><div> graphic: false,</div>
<div> <font class="Apple-style-span" color="#CC0000"> <b>label: "$(labelAttribute)</b></font><span class="Apple-style-span" style="font-family: monospace; font-size: medium; white-space: pre-wrap; "><span class="Apple-style-span" style="font-family: arial; white-space: normal; font-size: small; "><font class="Apple-style-span" color="#CC0000"><b>",</b></font></span></span></div>
<div> labelSelect: true</div><div> }</div><div><br></div><div>Is it correct ?</div></div><div><br></div><div>I have probably missunderstood one key styling concept, so sorry for my dummy questions.</div>
<div><br></div><div>Cédric<br><div class="gmail_quote">On Fri, Jan 15, 2010 at 11:05 PM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Fri, Jan 15, 2010 at 8:10 PM, Alexandre Dube <<a href="mailto:adube@mapgears.com">adube@mapgears.com</a>> wrote:<br>
> Hi,<br>
><br>
> I want to be able to save a OpenLayers.Style object or hash to a<br>
> vector feature. Currently, in code, feature.style exists but you must<br>
> define a hash or else it doesn't work.<br>
><br>
> My problem is that I want to be able to draw features to be used as<br>
> labels (floating text on the map). To be able to do so, I need to<br>
> define a StyleMap with a context to display the label (I manually set<br>
> feature.isLabel on "featureadded") [1]<br>
><br>
> That works well, but as soon as I want to "bind / save" the style to<br>
> the feature, I mean set feature.style,<br>
<br>
</div>feature.style is for the old way of styling features<br>
<div class="im"><br>
> I need to set a hash and the<br>
> feature will be rendered without the contexts.<br>
<br>
</div>if you want to get the symbolizer (style hash) of a feature use<br>
styleMap.createSymbolizer(feature, intent).<br>
<div class="im"><br>
<br>
> I don't fully understand how the contexts, symbolizers, etc. work, but<br>
> my first guess would be to support OpenLayers.Style object directly in<br>
> the feature object. Does that make sense ?<br>
><br>
> Or maybe I'm doing it wrong and their's an other way of "labeling"<br>
> features. My goal is to create features on a "cosmetic" layer with a<br>
> default style, then to be able to change the style of the features and<br>
> bind it to them (I mean without using rules on the layer level, but by<br>
> defining directly the feature style)<br>
<br>
</div>I guess binding a symbolizer to a feature can only be done with<br>
feature.style. So feature.style = styleMap.createSymbolizer(feature)<br>
may be what you're looking for.<br>
<br>
Cheers,<br>
--<br>
Eric Lemoine<br>
<br>
Camptocamp France SAS<br>
Savoie Technolac, BP 352<br>
73377 Le Bourget du Lac, Cedex<br>
<br>
Tel : 00 33 4 79 44 44 96<br>
Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
<div><div></div><div class="h5">_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@openlayers.org">Dev@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/dev" target="_blank">http://openlayers.org/mailman/listinfo/dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>CTO Geospatial Camptocamp SA<br>Cédric Moullet<br>PSE A<br>CH-1015 Lausanne<br><a href="http://www.camptocamp.com">www.camptocamp.com</a> / <a href="http://www.mapfish.org">www.mapfish.org</a> / <a href="http://twitter.com/cedricmoullet">twitter.com/cedricmoullet</a> / <a href="http://mapfishblog.blogspot.com/">mapfishblog.blogspot.com/</a><br>
<br>+41 79 759 69 83 (mobile)<br>+41 21 619 10 21 (direct)<br>+41 21 619 10 10 (centrale)<br>+41 21 619 10 00 (fax)<br>
</div>