Hi all,<br><br>I have try to use SLD but I was missing something. <br><br>Then I try to apply the&nbsp; style and wen I put this line:<br><br><br>var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.extend(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {fillColor: &quot;green&quot;, fillOpacity: 1, strokeColor: &quot;black&quot;},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenLayers.Feature.Vector.style[&quot;default&quot;]);<br><br>the map just stop working :(<br><br>The problem is so simple and I can&#39;t get a solution, I have a gml file with 300 polygons but with only 20 classes and I just want to make each class with diferent collor, in this example I have two squares with class 2 should be red and class 3 green but when I make load the sld file for this simple example nothing happens and when I try the style the map doesn&#39;t show, the gml file:<br>
<br>Thanks in advance for any help.<br><br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;<br>&lt;wfs:FeatureCollection xmlns:ms=&quot;<a href="http://mapserver.gis.umn.edu/mapserver">http://mapserver.gis.umn.edu/mapserver</a>&quot; xmlns:wfs=&quot;<a href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</a>&quot; xmlns:gml=&quot;<a href="http://www.opengis.net/gml">http://www.opengis.net/gml</a>&quot; xmlns:ogc=&quot;<a href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</a>&quot; xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot; xsi:schemaLocation=&quot;<a href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</a> <a href="http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://mapserver.gis.umn.edu/mapserver">http://mapserver.gis.umn.edu/mapserver</a> <a href="http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;amp;VERSION=1.0.0&amp;amp;REQUEST=DescribeFeatureType&amp;amp;TYPENAME=polygon&amp;amp;OUTPUTFORMAT=XMLSCHEMA">http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;amp;VERSION=1.0.0&amp;amp;REQUEST=DescribeFeatureType&amp;amp;TYPENAME=polygon&amp;amp;OUTPUTFORMAT=XMLSCHEMA</a>&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:boundedBy&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:Box srsName=&quot;EPSG:4326&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:coordinates&gt;-0.768746,47.003018 3.002191,47.925567&lt;/gml:coordinates&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/gml:Box&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:boundedBy&gt;<br><br>&nbsp;&nbsp;&nbsp; &lt;gml:featureMember&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:polygon fid=&quot;2&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:boundedBy&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:Box srsName=&quot;EPSG:4326&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:coordinates&gt;0.511919,47.088176 3.002191,48.882988&lt;/gml:coordinates&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/gml:Box&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:boundedBy&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:msGeometry&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:Polygon srsName=&quot;EPSG:4326&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:outerBoundaryIs&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:LinearRing&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:coordinates&gt;7.25,54.25 7.75,54.25 7.75,54.75 7.25,54.75 7.25,54.25&lt;/gml:coordinates&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:LinearRing&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:outerBoundaryIs&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:Polygon&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ms:msGeometry&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:ogc_fid&gt;2&lt;/ms:ogc_fid&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:name&gt;Meu quadrado&lt;/ms:name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:id&gt;0&lt;/ms:id&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ms:polygon&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/gml:featureMember&gt;<br>
<br>&nbsp;&nbsp;&nbsp; &lt;gml:featureMember&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:polygon fid=&quot;3&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:boundedBy&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:Box srsName=&quot;EPSG:4326&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;gml:coordinates&gt;0.511919,47.088176 3.002191,48.882988&lt;/gml:coordinates&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/gml:Box&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:boundedBy&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:msGeometry&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:Polygon srsName=&quot;EPSG:4326&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:outerBoundaryIs&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:LinearRing&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;gml:coordinates&gt;1.75,53.25 2.25,53.25 2.25,53.75 1.75,53.75 1.75,53.25 &lt;/gml:coordinates&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:LinearRing&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:outerBoundaryIs&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/gml:Polygon&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ms:msGeometry&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:ogc_fid&gt;3&lt;/ms:ogc_fid&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:name&gt;Meu quadrado&lt;/ms:name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ms:id&gt;3&lt;/ms:id&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ms:polygon&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/gml:featureMember&gt;<br>
&lt;/wfs:FeatureCollection&gt;<br><br><br><br><br><br><br><div class="gmail_quote">On Tue, Feb 26, 2008 at 5:34 PM, Andreas Hocevar &lt;<a href="mailto:andreas.hocevar@gmail.com">andreas.hocevar@gmail.com</a>&gt; 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>
the best way to do what you want is to use OpenLayers.StyleMap. See<br>
<a href="http://trac.openlayers.org/wiki/Styles" target="_blank">http://trac.openlayers.org/wiki/Styles</a> for a tutorial and<br>
<a href="http://www.openlayers.org/dev/examples/georss-flickr.html" target="_blank">http://www.openlayers.org/dev/examples/georss-flickr.html</a> for an<br>
example. You could also use SLD to define your styles. In that case,<br>
look at <a href="http://www.openlayers.org/dev/examples/sld.html" target="_blank">http://www.openlayers.org/dev/examples/sld.html</a> for an example.<br>
<br>
Things get much easier if you apply<br>
<a href="http://trac.openlayers.org/attachment/ticket/1373/1373-r6361-A0.patch" target="_blank">http://trac.openlayers.org/attachment/ticket/1373/1373-r6361-A0.patch</a> to<br>
the current trunk version of OpenLayers. This patch also contains an<br>
example which should do quite exactly what you need.<br>
<br>
Regards,<br>
Andreas.<br>
<div class="Ih2E3d"><br>
Carlos Pinto wrote:<br>
&gt; Your absolutely right, I discover thet only using the version &quot;&lt;script<br>
&gt; src=&quot;<a href="http://www.openlayers.org/dev/lib/OpenLayers.js" target="_blank">http://www.openlayers.org/dev/lib/OpenLayers.js</a>&quot;&gt;&lt;/script&gt;&quot; could<br>
&gt; be possible to apply styles to the KML file.<br>
&gt;<br>
&gt; So what is the best way to have good style on polygons?<br>
&gt; GML does not have either and I was trying to avoid customizing one by one.<br>
&gt;<br>
&gt; I need to draw a grid with ten classes and the simplest way it seemed<br>
&gt; to have a GML or KML file with all the polygons connected to a style!!!!<br>
&gt;<br>
&gt; Thanks for your help<br>
&gt;<br>
&gt; Carlos<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Feb 26, 2008 at 5:17 PM, Christopher Schmidt<br>
</div><div><div></div><div class="Wj3C7c">&gt; &lt;<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a> &lt;mailto:<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; On Tue, Feb 26, 2008 at 04:13:10PM +0100, Carlos Pinto wrote:<br>
&gt; &nbsp; &nbsp; &gt; Hi all,<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; Can anyone explain why when I run the example:<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; <a href="http://www.openlayers.org/dev/examples/kml-layer.html" target="_blank">http://www.openlayers.org/dev/examples/kml-layer.html</a><br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; it appears a line and 3 polygons with 3 different colors and if<br>
&gt; &nbsp; &nbsp; I use<br>
&gt; &nbsp; &nbsp; &gt; exactly the same code with the same layer, the polygons are<br>
&gt; &nbsp; &nbsp; replaced by one<br>
&gt; &nbsp; &nbsp; &gt; line?????<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; The code is this:<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.addLayer(new OpenLayers.Layer.GML(&quot;KML&quot;,<br>
&gt; &nbsp; &nbsp; &quot;kml/lines.kml&quot;,<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: OpenLayers.Format.KML,<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formatOptions: {<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extractStyles: true,<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; extractAttributes: true<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}));<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; and in fact, the layer has three polygons with different colors.<br>
&gt; &nbsp; &nbsp; What am I<br>
&gt; &nbsp; &nbsp; &gt; missing.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; I have try also to reference the library that it is online but i<br>
&gt; &nbsp; &nbsp; still stay<br>
&gt; &nbsp; &nbsp; &gt; with out seeing the polygons.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; Can anyone explain this?<br>
&gt;<br>
&gt; &nbsp; &nbsp; What version of OpenLayers are you using? Probably not 2.6;<br>
&gt; &nbsp; &nbsp; possibly not<br>
&gt; &nbsp; &nbsp; 2.5? It sounds like 2.4, though to be honest, there&#39;s no polygons<br>
&gt; &nbsp; &nbsp; anywhere in this demo, so perhaps I&#39;m confused. In any case, if you&#39;re<br>
&gt; &nbsp; &nbsp; not using a recent trunk, you won&#39;t have decent KML styling support,,<br>
&gt; &nbsp; &nbsp; which it sounds like might be your question.<br>
&gt;<br>
&gt; &nbsp; &nbsp; Regards,<br>
&gt; &nbsp; &nbsp; --<br>
&gt; &nbsp; &nbsp; Christopher Schmidt<br>
&gt; &nbsp; &nbsp; MetaCarta<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
&gt;<br>
<br>
</blockquote></div><br>