[OpenLayers-Users] Layer rendering

Andreas Hocevar andreas.hocevar at gmail.com
Fri Feb 29 06:10:42 EST 2008


Carlos,

Carlos Pinto wrote:
> I have try to use SLD but I was missing something.
>
> Then I try to apply the  style and wen I put this line:
>
>
> var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.extend(
>         {fillColor: "green", fillOpacity: 1, strokeColor: "black"},
>         OpenLayers.Feature.Vector.style["default"]);
>
> the map just stop working :(

There is nothing wrong with this style map definition. Also, if you just 
add this line, nothing should stop working, because you do not apply 
this style map to a layer.

But are you using SLD or are you defining your StyleMap in JavaScript?


> 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:

Which attribute holds your class? I don't see it in your GML. The only 
"2" and "3" I see is in your fid (feature id), and if you have multiple 
features with the same fid, map rendering will probably fail because of 
that. The fid is supposed to be a unique id.

Also, where are you loading your SLD? What does it look like? Maybe you 
can share an URL, that would make it easier to see your problem.

But your requirement is now 100% covered by 
http://www.openlayers.org/dev/examples/styles-unique.html

Maybe you want to have a look at that and see if that works for you. No 
need to use SLD in that case.

Regards,
Andreas.





More information about the Users mailing list