[OSM-talk] Use leaflet or openlayers to display a route relations in realtime

Rob Nickerson rob.j.nickerson at gmail.com
Wed Mar 19 19:29:05 UTC 2014


>I've looked briefly into using Leaflet or Openlayers & can work out  how
>to hard code the lat/long of each node or to load a gpx file, but see no
>way to retrieve the current data. What is the best/any way to do this?
>
>Cheers
>Dave F.
>

Hi Dave,

Take a look at Overpass API [1]. There is a XAPI compatibility layer that
makes it easy to get an OSM extract using a simple web http request [2]
(I've had a go at improving the documentation [3] which may help you) but
this compatibility layer only returns data in the OSM XML format.

You can extract data in other formats, as described in the Overpass API
language guide. I like to use the Overpass Turbo site and it's "Wizard"
button to make it easier to construct these queries. For example see my
blog post about a relation for a bus route in Coventry [5]. The Overpass
turbo page for this is permalinked at [6] and you can get the data as a
GeoJSON file via [7].

Regards,
Rob

[1] http://wiki.openstreetmap.org/wiki/Overpass_API
[2] http://wiki.openstreetmap.org/wiki/Overpass_API/XAPI_Compatibility_Layer
[3] http://wiki.openstreetmap.org/wiki/User:RobJN#XAPI_Compatibility_Layer
[4] http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide
[5] http://blog.mappa-mercia.org/2013/06/on-buses.html
[6] http://overpass-turbo.eu/s/2Ou
[7] http://overpass.osm.rambler.ru/cgi/interpreter?data=[out:json];relation["name"="Travel
De Courcey route 360A"];(._;>;);out body;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/talk/attachments/20140319/7c3ef30b/attachment.html>


More information about the talk mailing list