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