Hi Eric,<br><br>I've already passed through something like this. At least the code looks similar to me. Code is below:<br><br><span style="color: rgb(0, 0, 102);">var mycontext = { </span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);"> getColor: function(feature) </span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> { </span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> var jsonvalue = feature.attributes["fillcolor"];</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);"> return jsonvalue;</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> }</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">}; </span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">var contexttemplate = { </span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> fillOpacity: 0.6,</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> fillColor: "${getColor}",</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);"> strokeColor:"orange",</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> strokeWidth:"1"</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);"> }; </span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);"> </span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">var contextStyle = new OpenLayers.Style(contexttemplate,mycontext);</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">var myStyleMap = new OpenLayers.StyleMap(<span style="color: rgb(255, 0, 0);">{"default":contextStyle}</span>);</span> <br style="color: rgb(0, 0, 102);"><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">var rules = [new OpenLayers.Rule({</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">symbolizer: contexttemplate,</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">context: mycontext,</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">elseFilter: true</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">})];</span><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">myStyleMap.styles["default"].addRules(rules);</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">myStyleMap.styles["select"].addRules(rules); (w/ or w/o this line does not work) </span><br style="color: rgb(0, 0, 102);"><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">var regions = new
OpenLayers.Layer.Vector("regions",{extractAttributes:true, format:
OpenLayers.Format.GeoJSON, projection: new
OpenLayers.Projection("EPSG:4326"), styleMap: myStyleMap});</span><br><br><br>The fill color is not changed accordingly to color I have in GeoJSON file under attribute fillcolor. All other properties in template are applied. The edit function does not work.<br>
If I remove {"default":contextStyle} from OpenLayers.StyleMap(<span style="color: rgb(255, 0, 0);">{"default":contextStyle}</span>); and we remain only with<br>var myStyleMap = new OpenLayers.StyleMap(<span style="color: rgb(255, 0, 0);"></span>); and all rest of code the same, the edit function works. But still no fillcolor context is applied.<br>
<br>I have also oversimplified the code in a separate page, but result is identical.<br><br>All the best,<br>Adorian<br>
<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
</div>I added the code below to the modify-feature.html example and it<br>
worked for me (code is based on Alexandre's):<br>
<br>
var tpl = {<br>
<div class="Ih2E3d"> pointRadius: "${radius}",<br>
fillOpacity: 0.4,<br>
strokeColor: "#000000",<br>
strokeWidth: 2<br>
</div> };<br>
var ctx = {<br>
context: {<br>
radius: function(feature) {<br>
return 10;<br>
}<br>
}<br>
};<br>
<br>
var oStyle = new OpenLayers.Style(tpl, ctx);<br>
<div class="Ih2E3d"><br>
var oStyleMap = new OpenLayers.StyleMap({<br>
"default": oStyle,<br>
</div> // works w/ or w/o the following<br>
<div class="Ih2E3d"> "select": new OpenLayers.Style({<br>
fillColor: "#66ccff",<br>
fillOpacity: 0.2,<br>
strokeColor: "#3399ff"<br>
})<br>
});<br>
<br>
var aoTypeColor = {<br>
'1': {fillColor:"blue"},<br>
'2': {fillColor:"red"},<br>
'3': {fillColor:"yellow"},<br>
'4': {fillColor:"white"}<br>
};<br>
<br>
oStyleMap.addUniqueValueRules("default", "Type", aoTypeColor);<br>
oStyleMap.addUniqueValueRules("select", "Type", aoTypeColor);<br>
<br>
</div><div class="Ih2E3d"> var rules = [<br>
new OpenLayers.Rule({<br>
</div> symbolizer: tpl,<br>
context: ctx,<br>
elseFilter: true<br>
})<br>
];<br>
oStyleMap.styles["default"].addRules(rules);<br>
oStyleMap.styles["select"].addRules(rules);<br>
<br>
<br>
<br>
--<br>
<font color="#888888">Eric<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Dr. Adorian Ardelean<br>coordinator of myNature Project<br><br><a href="http://mybiosis.info/nature/portal.php?pagename=firstpage">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian biodiversity-database]<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=adorian">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>