-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (32 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class OpenInJOSM {
constructor(config) {
config.addJS('/node_modules/leaflet-editinosm/Leaflet.EditInOSM.js');
config.addCSS('/node_modules/leaflet-editinosm/Leaflet.EditInOSM.css');
config.addJS('/open-in-josm.js');
config.on('server:init', this.attachRoutes.bind(this));
}
extendMap(req, res) {
var front = function () {
L.K.Map.addInitHook(function () {
this.whenReady(function () {
var options = {
position: 'topleft',
widget: 'simplebutton',
widgetOptions: {
helpText: 'JOSM',
className: 'kosmtik-open-in-josm'
},
zoomThreshold: 14,
editors: ['josm']
};
this.openinjosm = (new L.Control.EditInOSM(options)).addTo(this);
});
});
};
this.pushToFront(res, front);
};
attachRoutes(e) {
e.server.addRoute('/open-in-josm.js', this.extendMap);
};
}
exports = module.exports = { Plugin: OpenInJOSM };