[OpenLayers-Users] Layer rendering

Andreas Hocevar andreas.hocevar at gmail.com
Tue Feb 26 11:34:33 EST 2008


Carlos,

the best way to do what you want is to use OpenLayers.StyleMap. See 
http://trac.openlayers.org/wiki/Styles for a tutorial and 
http://www.openlayers.org/dev/examples/georss-flickr.html for an 
example. You could also use SLD to define your styles. In that case, 
look at http://www.openlayers.org/dev/examples/sld.html for an example.

Things get much easier if you apply 
http://trac.openlayers.org/attachment/ticket/1373/1373-r6361-A0.patch to 
the current trunk version of OpenLayers. This patch also contains an 
example which should do quite exactly what you need.

Regards,
Andreas.

Carlos Pinto wrote:
> Your absolutely right, I discover thet only using the version "<script 
> src="http://www.openlayers.org/dev/lib/OpenLayers.js"></script>" could 
> be possible to apply styles to the KML file.
>
> So what is the best way to have good style on polygons?
> GML does not have either and I was trying to avoid customizing one by one.
>
> I need to draw a grid with ten classes and the simplest way it seemed 
> to have a GML or KML file with all the polygons connected to a style!!!!
>
> Thanks for your help
>
> Carlos
>
>
>
> On Tue, Feb 26, 2008 at 5:17 PM, Christopher Schmidt 
> <crschmidt at metacarta.com <mailto:crschmidt at metacarta.com>> wrote:
>
>     On Tue, Feb 26, 2008 at 04:13:10PM +0100, Carlos Pinto wrote:
>     > Hi all,
>     >
>     > Can anyone explain why when I run the example:
>     >
>     > http://www.openlayers.org/dev/examples/kml-layer.html
>     >
>     > it appears a line and 3 polygons with 3 different colors and if
>     I use
>     > exactly the same code with the same layer, the polygons are
>     replaced by one
>     > line?????
>     >
>     > The code is this:
>     >
>     >             map.addLayer(new OpenLayers.Layer.GML("KML",
>     "kml/lines.kml",
>     >                {
>     >                 format: OpenLayers.Format.KML,
>     >                 formatOptions: {
>     >                   extractStyles: true,
>     >                   extractAttributes: true
>     >                 }
>     >                }));
>     >
>     > and in fact, the layer has three polygons with different colors.
>     What am I
>     > missing.
>     >
>     > I have try also to reference the library that it is online but i
>     still stay
>     > with out seeing the polygons.
>     >
>     > Can anyone explain this?
>
>     What version of OpenLayers are you using? Probably not 2.6;
>     possibly not
>     2.5? It sounds like 2.4, though to be honest, there's no polygons
>     anywhere in this demo, so perhaps I'm confused. In any case, if you're
>     not using a recent trunk, you won't have decent KML styling support,,
>     which it sounds like might be your question.
>
>     Regards,
>     --
>     Christopher Schmidt
>     MetaCarta
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   




More information about the Users mailing list