Hi all,<br><br>Thanks very much. It is working and now I can start doing my grids.<br><br>the code is:<br><br> var styleMap = new OpenLayers.StyleMap({<br> fillOpacity: 1});<br><br> var lookup = {<br>
0: {fillColor: "green", fillOpacity: 1, strokeColor: "green"},<br> 1: {fillColor: "red", fillOpacity: 0.5, strokeColor: "red"}<br> }<br> styleMap.addUniqueValueRules("default", "type", lookup);<br>
<br> var mylayer = new OpenLayers.Layer.GML("GML", "../KML/MyPolygons.xml",{styleMap: styleMap} ); <br> map.addLayer(mylayer); <br> }<br><br><br>but one thing funny is that if I use the line <br>
<br>
myLayer.styleMap = styleMap;<br><br>it does not work<br><br><br>Thanks all especially to Andreas.<br><br><br><br><br><br><div class="gmail_quote">On Wed, Mar 5, 2008 at 3:06 PM, Andreas Hocevar <<a href="mailto:andreas.hocevar@gmail.com" target="_blank">andreas.hocevar@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Carlos,<br>
<br>
everything below is perfect, except that you need to add:<br>
<br>
<ms:type>1</ms:type><br>
<br>
instead of<br>
<br>
<type>1</type><br>
<br>
And yes, you should add the {styleMap: styleMap} options hash to your<br>
GML layer constructor. Or, after constructing the layer, just do<br>
<br>
myLayer.styleMap = styleMap;<br>
<br>
Regards,<br>
<font color="#888888">Andreas.<br>
</font><div><br>
Carlos Pinto wrote:<br>
> Hi all,<br>
><br>
</div><div><div></div><div>> then, if I use OpenLayers 2.6 I can use this feature, can I ask a help<br>
> of how then can I link the GML with the type?<br>
> and how can I format the color, transparency and set border of the<br>
> polygon?<br>
><br>
> can I do like this?<br>
> Thanks for your help, Carlos<br>
><br>
><br>
> var lookup = {<br>
> 0: {fillColor: "green", fillOpacity: 0.7, strokeColor: "green},<br>
> 1: {fillColor: "red", fillOpacity: 0.7, strokeColor: "green"},<br>
><br>
> 2: {fillColor: "#00ffff", fillOpacity: 0.7, strokeColor: "#00ffff"}<br>
><br>
> }<br>
> styleMap.addUniqueValueRules("default", "type", lookup);<br>
><br>
> // when I had the layer how do I say to apply the rules????<br>
> var mylayer = new OpenLayers.Layer.GML("GML",<br>
> "../KML/myPolygons.xml"); // should I add here in the end {styleMap:<br>
> styleMap}<br>
> map.addLayer(mylayer);<br>
><br>
> So I have put the line * <type>1</type> * in the GML:<br>
><br>
> <gml:featureMember><br>
> <ms:polygon fid="2"><br>
> <gml:boundedBy><br>
> <gml:Box srsName="EPSG:4326"><br>
> <gml:coordinates>0.511919,47.088176<br>
> 3.002191,48.882988</gml:coordinates><br>
> </gml:Box><br>
> </gml:boundedBy><br>
> <ms:msGeometry><br>
> <gml:Polygon srsName="EPSG:4326"><br>
> <gml:outerBoundaryIs><br>
> <gml:LinearRing><br>
> <gml:coordinates>7.25,54.25 7.75,54.25 7.75,54.75<br>
> 7.25,54.75 7.25,54.25</gml:coordinates><br>
> </gml:LinearRing><br>
> </gml:outerBoundaryIs><br>
> </gml:Polygon><br>
> </ms:msGeometry><br>
> <ms:ogc_fid>2</ms:ogc_fid><br>
> <ms:name>My box that is class1 </ms:name><br>
> * <type>1</type> *<br>
> <ms:id>0</ms:id><br>
> </ms:polygon><br>
> </gml:featureMember><br>
<br>
</div></div></blockquote></div><br>