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