-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrols.js
153 lines (128 loc) · 4.69 KB
/
controls.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
class LegendControl {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'legend-control mapboxgl-ctrl-group maplibregl-ctrl mapboxgl-ctrl';
let legend = document.createElement('div');
legend.className = 'legend';
let title = document.createElement('h4');
title.innerText = 'Company Category';
legend.append(title)
let li1 = document.createElement('div');
li1.innerHTML = `<span style="background-color: #74ae36"></span>Digital Farming`
let li2 = document.createElement('div');
li2.innerHTML = `<span style="background-color: #ff5252"></span>Earth Observation`
let li3 = document.createElement('div');
li3.innerHTML = `<span style="background-color: #ffe900"></span>GIS / Spatial Analysis`
let li4 = document.createElement('div');
li4.innerHTML = `<span style="background-color: #757575"></span>Satellite Operator`
let li5 = document.createElement('div');
li5.innerHTML = `<span style="background-color: #048ad1"></span>UAV / Aerial`
let li6 = document.createElement('div');
li6.innerHTML = `<span style="background-color: #f57801"></span>Webmap / Cartography`
legend.append(li1,li2,li3,li4,li5,li6)
this.container.append(legend)
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class AddCompanyButton {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'add-button maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group';
this.container.innerHTML = '<button><b>+</b></button>';
this.container.title = "Add a Company"
this.container.value = 0;
this.container.onclick = ToggleForm
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class ShareButton {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'share-control maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group';
this.container.innerHTML = '<i class="fg-map-share-alt fg-2x" style="color:#fff;"></i>';
this.container.title = 'Share this map'
this.container.value = 0;
this.container.addEventListener("click", toggleShare);
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class AddCompanyControl {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'add-control mapboxgl-ctrl-group maplibregl-ctrl mapboxgl-ctrl';
let form = buildForm()
this.container.append(form)
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class EditCompanyControl {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'add-control mapboxgl-ctrl-group maplibregl-ctrl mapboxgl-ctrl';
let form = buildForm()
this.container.append(form)
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class ToggleFilterControl {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'toggle-filter-button maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group';
this.container.title = "Filter Companies"
this.img = document.createElement('img');
this.img.src = 'icons/filter.svg'
this.container.onclick = ToggleFilter
this.container.append(this.img)
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
class FilterControl {
onAdd(map){
this.map = map;
this.container = document.createElement('div');
this.container.className = 'filter-control mapboxgl-ctrl-group maplibregl-ctrl mapboxgl-ctrl';
let form = createFilterForm()
this.container.append(form)
return this.container;
}
onRemove(){
this.container.parentNode.removeChild(this.container);
this.map = undefined;
}
}
let legendControl = new LegendControl();
let addCompanyButton = new AddCompanyButton();
let addCompanyControl = new AddCompanyControl();
let toggleFilterControl = new ToggleFilterControl();
let filterControl = new FilterControl()
let shareButton = new ShareButton();