Hi Eric,<div>Thanks for your answer. </div><div><br></div><div>However, I&#39;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&#39;t it be styleMap.createSymbolizer(feature, intent) ?</div><div><br></div><div>This implies that in order to manage &quot;free style&quot;, 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&#39;s symbolizer with a label property: </div><div><div>styleMap: new OpenLayers.StyleMap({</div><div>                    &#39;default&#39;: 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: &quot;$(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>&quot;,</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">&lt;<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>&gt;</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 &lt;<a href="mailto:adube@mapgears.com">adube@mapgears.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt;  I want to be able to save a OpenLayers.Style object or hash to a<br>
&gt; vector feature.  Currently, in code, feature.style exists but you must<br>
&gt; define a hash or else it doesn&#39;t work.<br>
&gt;<br>
&gt;  My problem is that I want to be able to draw features to be used as<br>
&gt; labels (floating text on the map).  To be able to do so, I need to<br>
&gt; define a StyleMap with a context to display the label (I manually set<br>
&gt; feature.isLabel on &quot;featureadded&quot;) [1]<br>
&gt;<br>
&gt;  That works well, but as soon as I want to &quot;bind / save&quot; the style to<br>
&gt; 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>
&gt; I need to set a hash and the<br>
&gt; 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>
&gt;  I don&#39;t fully understand how the contexts, symbolizers, etc. work, but<br>
&gt; my first guess would be to support OpenLayers.Style object directly in<br>
&gt; the feature object.  Does that make sense ?<br>
&gt;<br>
&gt;  Or maybe I&#39;m doing it wrong and their&#39;s an other way of &quot;labeling&quot;<br>
&gt; features.  My goal is to create features on a &quot;cosmetic&quot; layer with a<br>
&gt; default style, then to be able to change the style of the features and<br>
&gt; bind it to them (I mean without using rules on the layer level, but by<br>
&gt; 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&#39;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>