NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

[I have tried searching using google and the search option - I promise]

I wish to embed an Open Streetmap Map into my website (which is easy using LeafletJS), and then I want to display the boundary for a "relation" you have stored. Looking at the xml I can see the relation is made up of multiple 'ways' and for each 'way' I could seek to download a 'node'. From here I could traverse the xml and locate each GPS co-ord and then add it programatically to the map using Leaflet but this seems (to me) overcomplicated. Is this what is generally done or is there a blindingly obvious programatic way that I have not seen? I can imagine this question should be directed here or to the Leaflet folks -so apologies if this is a wrong posting

Howard

asked 01 May '23, 16:30

hjp23's gravatar image

hjp23
11112
accept rate: 0%

Unrelated to getting the Relation into Leaflet, if you're planning on using tiles from the "default" style then there's an associated usage policy linked to from the copyright page.

(01 May '23, 22:33) InsertUser

If you only want to use a single relation statically, and don't need updates then you can download the data in GeoJSON format from Overpass Turbo. I think Leaflet then allows you to use GeoJSON layers if you store it on your site somewhere.

permanent link

answered 01 May '23, 22:22

InsertUser's gravatar image

InsertUser
11.0k1369185
accept rate: 19%

Thank you! I must admit that when I went to Overpass I scratched my head as to how to find the "relation" from OSM - but a quick question with ChatGPT led to the following Overpass query

[out:json]; relation(9456324); (._;>;); out;

which then allowed me to download the GPS points as you describe. Perfect!

(02 May '23, 07:59) hjp23

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×535
×128
×92
×91
×1

question asked: 01 May '23, 16:30

question was seen: 1,554 times

last updated: 02 May '23, 07:59

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum