0

I have the osm_id of various roads defined in OpenStreetMap and I am trying to get the polygon defining the road. How might I do this, preferably in JavaScript and preferably without downloading data from OSM to my own server. I am new the whole GIS ecosystem so I apologise if my question does not make sense because I misunderstood something.

What I intent to do is to highlight certain roads on my map and for that I thought of adding a new layer (I am using Mapbox.js) which would contain a coloured polygon over the road I'm trying to highlight.

2
1

You can use OSM's regular API for fetching the OSM way via its ID. Example: https://www.openstreetmap.org/api/0.6/way/136322077/full

The /full is important for fetching all of its nodes, too. The nodes define the geometry of the way. The order of the nodes is defined by the <nd ref> elements of the way. See OSM XML for more information.

Also read about when not to use this API and the API usage policy. Since this is the editing API it is not meant for bulk queries.

0

According to http://wiki.openstreetmap.org/wiki/Nominatim

try this:

http://nominatim.openstreetmap.org/lookup?osm_ids=R146656,W104393803,N240109189

You must try to do a GET in your Javascript using JQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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