openstreetmap / leaflet-osm

OpenStreetMap plugin for Leaflet
Other
111 stars 32 forks source link

Please implement relation->way #12

Closed chrispickford closed 8 years ago

chrispickford commented 8 years ago

First up, thanks for creating this plugin, it very nearly does exactly what I'm looking for and will save me tons of time parsing OSM XML structure.

My use case is to display a UK county boundary on a leafletjs map using an OSM layer much like they do on the OSM website, E.g. http://www.openstreetmap.org/relation/81941.

The XML URI for this "relation" is here: http://www.openstreetmap.org/api/0.6/relation/81941

And follows the following structure:

<osm ...>
  <relation ...>
    <member type="way" ... />
    ...
    <member type="way" ... />
  </relation>
</osm>

In leaflet-osm.js:260 is the comment // relation-way and relation-relation membership not implemented.

Please could you look at implementing the above or advise on whether it's on your roadmap?

jfirebaugh commented 8 years ago

L.OSM.getRelations is only used as an additional condition to determine if nodes are "interesting" and should be individually displayed. If they are members of a relation, they're considered interesting.

If you use the "/full" relation URL for loading the relation data, you'll get the member ways, and L.OSM.DataLayer#addData will render them. As an example, the code that osm.org uses is here.

chrispickford commented 8 years ago

Ideal, thanks for pointing that out!