Thursday 26 September 2019

Using local OpenStreetMap (*.OSM) map with Openlayers 3?


What do I need to load a .OSM map in a client side javascript app? (Imagine an offline webapp).



Answer




With OpenLayers 2 you can load .osm files using OpenLayers.Format.OSM, see the OpenLayers osm file example in the OSM wiki. Keep in mind that this approach will be rather limited compared to a tile server and will work only for small files.


With OpenLayers 3 you can achieve something similar according to this similar question on StackOverflow by using ol.source.OSMXML. There is also an example of loading OSM XML vector data dynamically from a server (in this case using Overpass API).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...