4

I would like to show this type of relations in a simple map with Openlayers. http://www.openstreetmap.org/api/0.6/relation/1637735/full

I'm specially interested in being able to show tags as legend. Do you know how can I do it in the simplest way possible?

I'm not sure if Openlayers has already a package to display relations.

1
  • 1
    To generate the layer use new OpenLayers.Layer.GML("Polygon", "file.osm", {format: OpenLayers.Format.OSM, style: {strokeColor: "blue", .... etc
    – zom-pro
    Commented Apr 16, 2012 at 16:38

2 Answers 2

1

There are two solutions that I use for REST applications, most of the time I use both:
1)Store the tags in a array and use JavaScrip to keep track of tags related to a feature.
2)Populate the feature with some or all the tags with an iteration.

For example, load the geometries into a layer with one request, load the tags with other request, relate them with the ID. Now to have some resources working like the bubble popup, pupulate the layer with some important or desired attributes.

3
  • Ok I figure it out I can parse the xml with JQuery and it seems reasonable. Do you use jQuery also or something else?
    – zom-pro
    Commented Apr 16, 2012 at 13:42
  • I started with JQuery + BackboneJS, than I rewrote the code to use Extjs4. It worked fine with both solutions. If you plan to stick with JQuery I strongly recommend you to use something to manage your models like Backbonejs, otherwise you will spend a lot of time writing low level code.
    – Pablo
    Commented Apr 16, 2012 at 14:02
  • For the server side I use Django + Tastypie + Postgis. They rock!
    – Pablo
    Commented Apr 16, 2012 at 14:04
0

you can check OpenLayers GeoRSS Example. it is all about geotagged information. for more about GeoRSS, you can read it.

and GeoRSS Model:

<geo:Point>
   <geo:lat>55.701</geo:lat>
   <geo:long>12.552</geo:long>
</geo:Point>

and usage :

<?xml version="1.0"?>
 <rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
   <channel>
     ...
     <item>
       <title>An example annotation</title>
       <link>http://example.com/geo</link>
       <description>Just an example</description>
       <geo:lat>26.58</geo:lat>
       <geo:long>-97.83</geo:long>
     </item>
     ...
   </channel>
 </rss>

i hope it helps you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.