Hi all,<br><br>Maybe it is a problem with my install of OpenLayers, I have version 2.5<br><br>But this exemple don't show the Markers in my computer, <br>It shows the map but not the markers, shoud I download the version 2.6?<br>
what am I doing wrong?<br><br>Thanks, Carlos<br><br><br> <link rel="stylesheet" href="../OpenLayer/theme/default/style.css" type="text/css" /><br> <style type="text/css"><br>
#map {<br> width: 800px;<br> height: 400px;<br> border: 1px solid black;<br> }<br> </style><br> <script src="../OpenLayer/lib/OpenLayers.js"></script><br>
<script type="text/javascript"><br> var map, layer;<br><br> function init(){<br> map = new OpenLayers.Map('map', {maxResolution:'auto'});<br> var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",<br>
"<a href="http://labs.metacarta.com/wms/vmap0">http://labs.metacarta.com/wms/vmap0</a>", {layers: 'basic'} );<br> map.addLayer(wms);<br> map.setCenter(new OpenLayers.LonLat(0, 0), 0);<br>
<br> // create 20 random features with a random type attribute. The<br> // type attribute is a value between 0 and 2.<br> var features = new Array(20);<br> for (var i=0; i<20; i++) {<br>
features[i] = new OpenLayers.Feature.Vector(<br> new OpenLayers.Geometry.Point(Math.random()*360-180, Math.random()*180-90),<br> {type: parseInt(Math.random()*3)}<br> );<br>
}<br> <br> // create a styleMap with a custom default symbolizer<br> var styleMap = new OpenLayers.StyleMap({<br> fillOpacity: 1,<br> pointRadius: 10<br>
});<br> <br> // create a lookup table with different symbolizers for 0, 1 and 2<br> var lookup = {<br> 0: {externalGraphic: "../OpenLayer/img/marker-blue.png"},<br>
1: {externalGraphic: "../OpenLayer/img/marker-green.png"},<br> 2: {externalGraphic: "../OpenLayer/img/marker-gold.png"}<br> }<br> <br> // add rules from the above lookup table, with the keyes mapped to<br>
// the "type" property of the features, for the "default" intent<br> styleMap.addUniqueValueRules("default", "type", lookup);<br> <br> layer = new OpenLayers.Layer.Vector('Points', {<br>
styleMap: styleMap<br> });<br> <br> layer.addFeatures(features);<br> map.addLayer(layer);<br> }<br> </script><br><br><br><div class="gmail_quote">
On Fri, Feb 29, 2008 at 12:10 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>
<div class="Ih2E3d"><br>
Carlos Pinto wrote:<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>
</div>There is nothing wrong with this style map definition. Also, if you just<br>
add this line, nothing should stop working, because you do not apply<br>
this style map to a layer.<br>
<br>
But are you using SLD or are you defining your StyleMap in JavaScript?<br>
<div class="Ih2E3d"><br>
<br>
> The problem is so simple and I can't get a solution, I have a gml file<br>
> with 300 polygons but with only 20 classes and I just want to make<br>
> each class with diferent collor, in this example I have two squares<br>
> with class 2 should be red and class 3 green but when I make load the<br>
> sld file for this simple example nothing happens and when I try the<br>
> style the map doesn't show, the gml file:<br>
<br>
</div>Which attribute holds your class? I don't see it in your GML. The only<br>
"2" and "3" I see is in your fid (feature id), and if you have multiple<br>
features with the same fid, map rendering will probably fail because of<br>
that. The fid is supposed to be a unique id.<br>
<br>
Also, where are you loading your SLD? What does it look like? Maybe you<br>
can share an URL, that would make it easier to see your problem.<br>
<br>
But your requirement is now 100% covered by<br>
<a href="http://www.openlayers.org/dev/examples/styles-unique.html" target="_blank">http://www.openlayers.org/dev/examples/styles-unique.html</a><br>
<br>
Maybe you want to have a look at that and see if that works for you. No<br>
need to use SLD in that case.<br>
<br>
Regards,<br>
<font color="#888888">Andreas.<br>
<br>
<br>
</font></blockquote></div><br>