View custom OSM files with a versatile style file in YAML format.
git clone https://github.com/geowiki-net/geowiki-viewer
cd geowiki-viewer
npm install
cp config.yaml-dist config.yaml # You might want to change parameters
npm start # start built-in http server (you can use other web servers as well; no server process needed)
Browse to http://localhost:8080
BY default, geowiki-viewer uses Overpass API for loading data. Alternatively, you could specify a file in OSM format as data soure:
This would load filename.osm
from the data/ directory.
Specify an alternate style file with the style parameter:
This would load foobar.yaml
from the data/ directory.
layers:
- query: way[highway]
feature:
title: Road ({{ tags.highway }})
style:
color: black
width: 5
- query: |
(
nwr[natural=wood];
nwr[landuse=forest];
)
feature:
style:
fillColor: '#007f00'
panes:
casing:
zIndex: 399
opacity: 0.5
highlight:
zIndex: 401
Add additional panes. Set style options as sub-object, including 'zIndex'.
There are a few additional modules available. You can install them via npm,
e.g. npm install geowiki-module-fullscreen
. You then have to enable it in the
'modules.js' file and re-build your code with npm run build
.
To create your own module, use this code as skeleton:
module.exports = {
id: 'my-module-name',
requireModules: [], // add the name of any module which should be loaded first, e.g. 'map'
layerInit: (layer, [callback]) => {
// will be executed for each LeafletGeowiki layer (if defined). You can
// hook to events with: layer.on('layeradd', () => { ... })
// if no callback argument is added, the function will be called
// synchronously.
callback()
},
appInit: (app, [callback]) => {
// will be executed if run inside GeowikiViewer (if defined). You can hook
// to events with: app.on('init', () => { ... })
// if no callback argument is added, the function will be called
// synchronously.
callback()
}
}
}
When developing, use the following command to automatically update the compiled JS file - with debugging information included:
npm run watch