<meta charset="utf-8">Yes ! It's working :)<div><br></div><div>Thanks for your reply !!!</div><div><br></div><div>Can you explain or show me some example with 'rules' ?</div><div><br></div><div>That will probably reduce the size of my json and I'll learn something new too ;)</div>
<div><br></div><div>Thanks! :)</div><div><br></div>-Pol D.-<br><a href="http://www.google.com/profiles/110003197662276240659">http://www.google.com/profiles/110003197662276240659</a><br>
<br><br><div class="gmail_quote">On Tue, Mar 23, 2010 at 23:24, Tim Schaub <span dir="ltr"><<a href="mailto:tschaub@opengeo.org">tschaub@opengeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Pol wrote:<br>
> Hello,<br>
><br>
> I just discovered GeoExt and OpenLayers 2 days ago and I'm rebuilding my<br>
> project using GeoExt (it was using the very good GmapPanel before).<br>
> First of all, thanks for it, it's a very good job !<br>
><br>
<br>
</div>Thanks. Welcome.<br>
<div class="im"><br>
> I subscribe to this list because I have a small problem.<br>
><br>
> I have a single URL who return me all the markers to display on the map.<br>
> Those markers must have different icons.<br>
><br>
> I don't want to create multiple layers for each kind of markers, that would<br>
> make too much external calls and slow down the whole stuff.<br>
><br>
> I have pasted some bits of code here: <a href="http://pastebin.com/Uee7xdzJ" target="_blank">http://pastebin.com/Uee7xdzJ</a><br>
><br>
> I suppose that I have to add a property like:<br>
><br>
> imgRef: 1<br>
><br>
> in my json response to identify the picture to display in javascript later,<br>
> but I don't know where to put it and how to retrieve it.<br>
><br>
> Can you help me ?<br>
<br>
</div>Your vector layer will contain a collection of vector features.<br>
OpenLayers.Feature.Vector objects have an "attributes" property. You'll<br>
need to have a feature attribute that can be used to derive the path to<br>
the image you'd like to use for rendering those features.<br>
<br>
In the simplest case, your features have an attribute whose value is the<br>
path to an external graphic. In this case, you will be using a<br>
symbolizer that refers to the appropriate feature attribute.<br>
<br>
e.g.<br>
<br>
// assuming feature.attributes.icon = "path/to/marker.png"<br>
var symbolizer = {<br>
graphicHeight: 10,<br>
graphicWidth: 5,<br>
externalGraphic: "${icon}"<br>
};<br>
<br>
This symbolizer is used to create an OpenLayers.Style object that is<br>
referenced in an OpenLayers.StyleMap (yes, complicated).<br>
<br>
See <a href="http://openlayers.org/dev/examples/styles-rotation.html" target="_blank">http://openlayers.org/dev/examples/styles-rotation.html</a> for a<br>
similar example using feature attribute values for rotation and fill<br>
opacity.<br>
<br>
It looks like you are using GeoJSON as your transport format. Your<br>
OpenLayers feature object would look something like the following when<br>
serialized:<br>
<br>
{<br>
"type": "Feature",<br>
"geometry": {<br>
"type": "Point",<br>
"coordinates": [4.22, 50.72]<br>
},<br>
"properties": {<br>
"icon": "path/to/marker.png"<br>
}<br>
}<br>
<br>
The "properties" member of a GeoJSON feature object maps to the<br>
attributes object of an OpenLayers vector feature.<br>
<br>
If you don't want to include the path to your external graphic in your<br>
data, but instead you want to render your features based on some other<br>
combination of attributes, you can use rule based styling. Write back<br>
if that's what you're after.<br>
<br>
And, you might find the OpenLayers lists a more appropriate place for<br>
pure OpenLayers questions.<br>
<br>
Good luck,<br>
Tim<br>
<br>
<br>
><br>
> Thanks.<br>
><br>
> -Pol D.-<br>
><br>
><br>
><br>
> ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
> <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
<br>
--<br>
Tim Schaub<br>
OpenGeo - <a href="http://opengeo.org" target="_blank">http://opengeo.org</a><br>
Expert service straight from the developers.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>