openstreetmap / leaflet-osm

OpenStreetMap plugin for Leaflet
Other
111 stars 32 forks source link

osm files #24

Closed mtabdar closed 5 years ago

mtabdar commented 5 years ago

hi, i wonder if it is possible to load .osm file into a leaflet map using this js?

tomhughes commented 5 years ago

No it's not - this helps with configuring the tile layers that are shown on the OSM site.

tomhughes commented 5 years ago

Sorry I'm wrong - the data layer support is in this module as well, so yes you can - see https://github.com/openstreetmap/leaflet-osm#data-layer for an example.

mtabdar commented 5 years ago

thanks for the quick reply. unfortunately i could not make it work. let me explain my question: i have an osm file (exported from openstreetmaps site) and want to show it on a leaflet map and i am not connected to web.

tomhughes commented 5 years ago

It's fairly simple - you take the XML and call:

var layer = new L.OSM.DataLayer(xml).addTo(map);

How you load the XML into the xml variable is up to you - that is a general "how do I write javascript" question and nothing specific to this module.