[GIS] How to convert osm way xml to openlayers feature

formatopenlayers-2openstreetmap

I am displaying the osm data through a popup with openlayers. For now i am using the overpass api to get data.

But my app needs to reflect the rapidly changing data i.e. one changes the data then uses my app, then they need to see the new data.

The one minute lag of overpass api is not acceptable, so i have decided to use the

  1. skel mode of overpass api to display feature,
  2. Get id and geometry
  3. query the feature from osm database

this way i can limit the data usage also.

Now i have an Openlayers Vector Layer using OpenLayers.Format.OSM. i can add features to it.

i need to convert an xml data in this format
to an OpenLayers.Feature.Vector.

Best Answer

You need to use a vector layer with OpenLayers.Format.OSM

This page on the OSM Wiki has a wonderful example:OpenLayers osm file example