How can I directly display a simple .OSM file in browser?

How can I directly display a simple .OSM file in browser. I want to simply display .OSM file in the browser like it is displayed in JOSM editor.

Upvotes: 2

Views: 2572

Answers (3)

Shaun McDonald
Shaun McDonald

Reputation: 6581

The Leaflet plugin leaflet-osm has the option to load a data layer which uses a single OSM object, or a small number of objects. This method is not recommended for a large amount of data.

Here's the example from the leaflet page:

$.ajax({
  url: "http://www.openstreetmap.org/api/0.6/node/164979149",
  // or "http://www.openstreetmap.org/api/0.6/way/52477381/full"
  dataType: "xml",
  success: function (xml) {
    var layer = new L.OSM.DataLayer(xml).addTo(map);
    map.fitBounds(layer.getBounds());
  }
});

Upvotes: 3

tyr
tyr

Reputation: 1833

You can display osm as vector data by using the leaflet plugin leaflet-osm for example.

Upvotes: 1

scai
scai

Reputation: 21509

That is not directly possible because the .osm file is just a XML file containing raw data, it needs to be rendered first. However there is various rendering software, some of it can produce an image directly out of a .osm file.

Upvotes: 0

Related Questions