Biểu trưng OpenStreetMap OpenStreetMap

Plotting a route (from relations) on an OSM map

Do Richard đăng vào 14 tháng 12 năm 2008 bằng English.

We have lots and lots of lovely relations in the OSM database these days (as well as some fairly nasty ones) but they're not always shown on the map of your choice.

So I've just knocked up a very little bit of code to take a route relation, and plot it on a map using OpenLayers. Code here, example here.

Biểu tượng thư điện tử Biểu tượng Bluesky Biểu tượng Facebook Biểu tượng LinkedIn Biểu tượng Mastodon Biểu tượng Telegram Biểu tượng X

Thảo luận

Bình luận của IgnoredAmbience vào 14 tháng 12 năm 2008 lúc 23:18

Arrgh! You've used the evil piece of GPX code that should really be sent to /dev/null.
Anyway, there's an easier way to do this. Just grab the full OSM file from the API, and add it to OL using the Vector layer + OSM format.

Bình luận của Richard vào 14 tháng 12 năm 2008 lúc 23:28

Ha ha. FSVO "easier" maybe. I tried using the proper way to do it - in fact, I spent half the afternoon using GML which should logically be much more flexible than GPX - but the only thing that'd work (in this browser, at least) was said evil piece of GPX code...

Bình luận của IgnoredAmbience vào 14 tháng 12 năm 2008 lúc 23:52

A demo, http://ge.pythonmoo.co.uk/maps/osmrelations.htm
Also shows the upcoming method of vector handling in OL, currently broken with reprojectioning stuff. (Tower Hamlets)

Bình luận của kaerast vào 15 tháng 12 năm 2008 lúc 13:49

I've been looking for something like this, between these two I can now render the Lycian Way relation nicely to make it clearer what's missing.

Đăng nhập để nhận xét