-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (57 loc) · 1.3 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import pluginConfig from './config';
const {
base,
inherit
} = g3wsdk.core.utils;
const { Plugin:BasePlugin } = g3wsdk.core.plugin;
const Service = require('./service');
const Plugin = function() {
base(this, {
name: 'openrouteservice',
i18n: pluginConfig.i18n,
service: Service,
});
this.service.once('ready', () => {
if (this.registerPlugin(this.config.gid)) {
this.setupGUI();
this.setReady(true);
}
});
//initialize service
this.service.init(this.config);
}
inherit(Plugin, BasePlugin);
Plugin.prototype.setupGUI = function () {
const component = this.createSideBarComponent({template: '<ul></ul>'},
{
id: this.name,
title: 'OPENROUTESERVICE',
open: false,
collapsible: false,
iconConfig: {
color: 'purple',
icon: 'layers',
},
mobile: true,
events: {
open: {
when: 'after',
cb: bool => {
//only in case of bool true
if (bool) {
this.service.openForm();
component.state.open = false;
}
},
}
},
sidebarOptions: {
position: 1
}
}
);
};
Plugin.prototype.unload = function() {
this.service.clear();
}
new Plugin();