@vidro/map-handler 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +27 -4
- package/dist/map-handler.js +1 -1
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/cachedTokenData.dat +1 -1
- package/examples/full/index.php +14 -2
- package/examples/full/tester.js +496 -437
- package/examples/vidromap/index.php +2 -4
- package/package.json +1 -1
- package/src/index.js +18 -1
package/examples/full/tester.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// Config:
|
2
2
|
|
3
3
|
var sessionToken = document.querySelector("#sessionToken").textContent;
|
4
|
-
var communicator = new VidroMaps.Communicator({sessionToken});
|
4
|
+
var communicator = new VidroMaps.Communicator({ sessionToken });
|
5
5
|
var clickedCoordinates = null;
|
6
6
|
// UI buttons:
|
7
7
|
|
@@ -23,8 +23,12 @@ var btStopGeolocalize = document.querySelector("#btStopGeolocalize");
|
|
23
23
|
var btHighlight = document.querySelector("#btHighlight");
|
24
24
|
var zoomToHighlightCheck = document.querySelector("#zoomToHighlightCheck");
|
25
25
|
var btToggleGiswaterTiled = document.querySelector("#btToggleGiswaterTiled");
|
26
|
-
var toggleGiswaterTiledCheck = document.querySelector(
|
27
|
-
|
26
|
+
var toggleGiswaterTiledCheck = document.querySelector(
|
27
|
+
"#toggleGiswaterTiledCheck"
|
28
|
+
);
|
29
|
+
var btReloadDisplayedLayers = document.querySelector(
|
30
|
+
"#btReloadDisplayedLayers"
|
31
|
+
);
|
28
32
|
var btAddGeoJSON = document.querySelector("#btAddGeoJSON");
|
29
33
|
var btClearGeoJSON = document.querySelector("#btClearGeoJSON");
|
30
34
|
var geoJSONFileContent = document.getElementById("geojsonfile");
|
@@ -36,9 +40,13 @@ var btsetGiswaterFilters = document.querySelector("#btsetGiswaterFilters");
|
|
36
40
|
var btgetGiswaterFilters = document.querySelector("#btgetGiswaterFilters");
|
37
41
|
var btLoadWMSLayers = document.querySelector("#btLoadWMSLayers");
|
38
42
|
var btDebug = document.querySelector("#btDebug");
|
39
|
-
var btAddGeoJSONFromGiswater = document.querySelector(
|
43
|
+
var btAddGeoJSONFromGiswater = document.querySelector(
|
44
|
+
"#btAddGeoJSONFromGiswater"
|
45
|
+
);
|
40
46
|
//override layer properties
|
41
|
-
var overrideLayerProperties = document.querySelector(
|
47
|
+
var overrideLayerProperties = document.querySelector(
|
48
|
+
"#overrideLayerProperties"
|
49
|
+
);
|
42
50
|
var gutter = document.querySelector("#gutter");
|
43
51
|
var toggleTransparentLayer = document.querySelector("#toggleTransparentLayer");
|
44
52
|
var toggleSingleTile = document.querySelector("#toggleSingleTile");
|
@@ -49,284 +57,317 @@ var geom_stroke_width = document.querySelector("#geom_stroke_width");
|
|
49
57
|
var geom_fill_color = document.querySelector("#geom_fill_color");
|
50
58
|
var geom_shape = document.querySelector("#geom_shape");
|
51
59
|
var geom_radius = document.querySelector("#geom_radius");
|
52
|
-
|
60
|
+
|
53
61
|
var btSetColors = document.querySelector("#btSetColors");
|
54
62
|
var btGetElementsFromLayer = document.querySelector("#btGetElementsFromLayer");
|
63
|
+
var btGetToc = document.querySelector("#btGetToc");
|
64
|
+
var btChangeBackground = document.querySelector("#btChangeBackground");
|
65
|
+
var newBackground = document.querySelector("#newBackground");
|
55
66
|
|
56
67
|
var geoJSONName = null; //geoJSON file name
|
57
68
|
var geoJSONContent = null; // geojson file content
|
58
69
|
//local var for store active layer
|
59
70
|
var currentActiveLayer = null;
|
60
|
-
function cleanContainers(){
|
61
|
-
|
62
|
-
|
71
|
+
function cleanContainers() {
|
72
|
+
Error_container.innerHTML = "";
|
73
|
+
Result_container.innerHTML = "";
|
63
74
|
}
|
64
75
|
|
65
76
|
// Map events
|
66
77
|
|
67
|
-
communicator.on("onZoomChange", function(data){
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
78
|
+
communicator.on("onZoomChange", function (data) {
|
79
|
+
console.log("onZoomChange", data);
|
80
|
+
if (document.getElementById("zoomLevel")) {
|
81
|
+
//Add current zoom Level to highlight input zoomlevel
|
82
|
+
document.getElementById("zoomLevel").value = data;
|
83
|
+
}
|
84
|
+
cleanContainers();
|
85
|
+
Result_container.innerHTML = `Zoom level changed: ${data}`;
|
75
86
|
});
|
76
87
|
|
88
|
+
communicator.on("geomAdded", function (data) {
|
89
|
+
console.log("geomAdded", data);
|
90
|
+
cleanContainers();
|
91
|
+
//show geometry on DOM
|
92
|
+
Result_container.innerHTML = data;
|
93
|
+
//Add current geom to highlight input geom
|
94
|
+
document.getElementById("geom").value = data;
|
95
|
+
});
|
77
96
|
|
78
|
-
communicator.on("
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
97
|
+
communicator.on("loaded", function (data) {
|
98
|
+
console.log("loaded", data);
|
99
|
+
communicator.setCustomColors({
|
100
|
+
geom_stroke_color: "rgb(19, 39, 99,0.5)",
|
101
|
+
geom_fill_color: "rgb(19, 39, 99,0.5)",
|
102
|
+
geom_stroke_width: 1,
|
103
|
+
geom_shape: "circle",
|
104
|
+
geom_radius: 200,
|
105
|
+
});
|
85
106
|
});
|
86
107
|
|
87
|
-
communicator.on("
|
88
|
-
|
108
|
+
communicator.on("layers", function (data) {
|
109
|
+
console.log("layers received", data);
|
110
|
+
fillDisplayedLayersSelect(data);
|
89
111
|
});
|
90
112
|
|
91
|
-
communicator.on("
|
92
|
-
|
93
|
-
fillDisplayedLayersSelect(data);
|
113
|
+
communicator.on("getToc", function (data) {
|
114
|
+
console.log("getToc received", data);
|
94
115
|
});
|
95
116
|
|
96
|
-
communicator.on("geoJSONlayers", function(data){
|
97
|
-
|
98
|
-
|
117
|
+
communicator.on("geoJSONlayers", function (data) {
|
118
|
+
console.log("geoJSONlayers received", data);
|
119
|
+
fillGeoJSONLayersSelect(data);
|
99
120
|
});
|
100
121
|
|
101
122
|
//error event
|
102
|
-
communicator.on("error", function(data){
|
103
|
-
|
104
|
-
|
105
|
-
|
123
|
+
communicator.on("error", function (data) {
|
124
|
+
console.error("error", data);
|
125
|
+
cleanContainers();
|
126
|
+
Error_container.innerHTML = data.error;
|
106
127
|
});
|
107
128
|
|
108
129
|
//clicked coordinates
|
109
|
-
communicator.on("coordinates", function(data){
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
130
|
+
communicator.on("coordinates", function (data) {
|
131
|
+
console.info("coordinates", data);
|
132
|
+
cleanContainers();
|
133
|
+
clickedCoordinates = [data.coordinates[0], data.coordinates[1]];
|
134
|
+
Result_container.innerHTML = `Clicked coordinates -> x: ${data.coordinates[0]}, y: ${data.coordinates[1]}`;
|
114
135
|
});
|
115
136
|
|
116
|
-
communicator.on("activeLayer", function(data){
|
117
|
-
|
118
|
-
|
119
|
-
|
137
|
+
communicator.on("activeLayer", function (data) {
|
138
|
+
console.info("activeLayer", data);
|
139
|
+
cleanContainers();
|
140
|
+
Result_container.innerHTML = data.activeLayer;
|
120
141
|
});
|
121
142
|
|
122
|
-
communicator.on("geolocation", function(data){
|
123
|
-
|
124
|
-
|
143
|
+
communicator.on("geolocation", function (data) {
|
144
|
+
console.info("geolocation", data);
|
145
|
+
cleanContainers();
|
125
146
|
});
|
126
147
|
|
127
|
-
communicator.on("GiswaterLayerAvailableFilters", function(data){
|
128
|
-
|
129
|
-
|
130
|
-
|
148
|
+
communicator.on("GiswaterLayerAvailableFilters", function (data) {
|
149
|
+
console.info("GiswaterLayerAvailableFilters", data);
|
150
|
+
cleanContainers();
|
151
|
+
Result_container.innerHTML = data.filters;
|
131
152
|
});
|
132
153
|
|
133
|
-
|
134
154
|
//info event
|
135
|
-
communicator.on("info", function(data){
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
155
|
+
communicator.on("info", function (data) {
|
156
|
+
console.log("info received", data);
|
157
|
+
var dataToRender = data.data;
|
158
|
+
//depending on infoType, data.data can be an string or a JSON
|
159
|
+
if (data.infoType === "giswater") {
|
160
|
+
dataToRender = JSON.stringify(data.data);
|
161
|
+
}
|
162
|
+
cleanContainers();
|
163
|
+
Result_container.innerText = dataToRender;
|
144
164
|
});
|
145
165
|
|
146
166
|
//Layer elements list
|
147
|
-
communicator.on("layerElements", function(data){
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
167
|
+
communicator.on("layerElements", function (data) {
|
168
|
+
console.log("layerElements received", data);
|
169
|
+
var dataToRender = data.data;
|
170
|
+
//depending on requested format, data.data can be an string (xml) or a JSON
|
171
|
+
cleanContainers();
|
172
|
+
Result_container.innerText =
|
173
|
+
typeof dataToRender === "object"
|
174
|
+
? JSON.stringify(dataToRender)
|
175
|
+
: dataToRender;
|
153
176
|
});
|
154
177
|
|
155
178
|
//giswater tiled background
|
156
|
-
communicator.on("giswaterTiledBackgroundDisplayed", function(data){
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
179
|
+
communicator.on("giswaterTiledBackgroundDisplayed", function (data) {
|
180
|
+
console.log("giswaterTiledBackgroundDisplayed", data);
|
181
|
+
if (toggleGiswaterTiledCheck) {
|
182
|
+
toggleGiswaterTiledCheck.checked = data.visible;
|
183
|
+
}
|
162
184
|
});
|
163
|
-
communicator.on("giswaterTiledBackgroundAvailable", function(data){
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
185
|
+
communicator.on("giswaterTiledBackgroundAvailable", function (data) {
|
186
|
+
console.log("giswaterTiledBackgroundAvailable", data);
|
187
|
+
if (btToggleGiswaterTiled && data.available) {
|
188
|
+
btToggleGiswaterTiled.disabled = false;
|
189
|
+
var use_giswater_tiled = document.querySelector("#use_giswater_tiled");
|
190
|
+
if (use_giswater_tiled) {
|
191
|
+
toggleGiswaterTiledCheck.checked = use_giswater_tiled.checked;
|
192
|
+
}
|
193
|
+
}
|
172
194
|
});
|
173
|
-
communicator.on("WMSInfoAvailable", function(){
|
174
|
-
|
175
|
-
|
195
|
+
communicator.on("WMSInfoAvailable", function () {
|
196
|
+
console.log("WMSInfoAvailable");
|
197
|
+
if (btWMSInfo) btWMSInfo.disabled = false;
|
176
198
|
});
|
177
|
-
communicator.on("availableWMSLayers", function(data){
|
178
|
-
|
179
|
-
|
199
|
+
communicator.on("availableWMSLayers", function (data) {
|
200
|
+
console.log("availableWMSLayers", data);
|
201
|
+
fillLayersSelect(data);
|
180
202
|
});
|
181
203
|
|
182
204
|
function fillLayersSelect(options) {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
205
|
+
console.log("fillLayersSelect", options);
|
206
|
+
var projectlayers = document.getElementById("projectlayers");
|
207
|
+
if (projectlayers) {
|
188
208
|
var length = projectlayers.options.length;
|
189
209
|
|
190
|
-
for (i = length-1; i >= 0; i--) {
|
210
|
+
for (i = length - 1; i >= 0; i--) {
|
191
211
|
projectlayers.options[i] = null;
|
192
212
|
}
|
193
|
-
for(var i = 0; i < options.length; i++) {
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
213
|
+
for (var i = 0; i < options.length; i++) {
|
214
|
+
var opt = options[i];
|
215
|
+
var el = document.createElement("option");
|
216
|
+
el.textContent = opt;
|
217
|
+
el.value = opt;
|
218
|
+
projectlayers.appendChild(el);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
function fillDisplayedLayersSelect(options) {
|
224
|
+
var layers_select = document.getElementById("layers");
|
225
|
+
if (layers_select) {
|
226
|
+
//empty previous options
|
227
|
+
var length = layers_select.options.length;
|
228
|
+
for (i = length - 1; i >= 0; i--) {
|
229
|
+
layers_select.options[i] = null;
|
230
|
+
}
|
231
|
+
for (var i = 0; i < options.length; i++) {
|
232
|
+
var opt = options[i];
|
233
|
+
var el = document.createElement("option");
|
234
|
+
el.textContent = opt;
|
235
|
+
el.value = opt;
|
236
|
+
layers_select.appendChild(el);
|
199
237
|
}
|
200
238
|
}
|
201
239
|
}
|
202
240
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
for (i = length-1; i >= 0; i--) {
|
209
|
-
layers_select.options[i] = null;
|
210
|
-
}
|
211
|
-
for(var i = 0; i < options.length; i++) {
|
212
|
-
var opt = options[i];
|
213
|
-
var el = document.createElement("option");
|
214
|
-
el.textContent = opt;
|
215
|
-
el.value = opt;
|
216
|
-
layers_select.appendChild(el);
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}
|
220
|
-
|
221
|
-
if(btDebug){
|
222
|
-
btDebug.addEventListener("click", function(){
|
223
|
-
var debug = parseInt(document.getElementById("debug").value);
|
224
|
-
communicator.setDebug(debug);
|
225
|
-
});
|
241
|
+
if (btDebug) {
|
242
|
+
btDebug.addEventListener("click", function () {
|
243
|
+
var debug = parseInt(document.getElementById("debug").value);
|
244
|
+
communicator.setDebug(debug);
|
245
|
+
});
|
226
246
|
}
|
227
247
|
// Actions
|
228
|
-
btZoomIn.addEventListener("click", function(){
|
248
|
+
btZoomIn.addEventListener("click", function () {
|
229
249
|
return communicator.ZoomIn();
|
230
250
|
});
|
231
251
|
|
232
|
-
btZoomOut.addEventListener("click", function(){
|
252
|
+
btZoomOut.addEventListener("click", function () {
|
233
253
|
communicator.ZoomOut();
|
234
254
|
});
|
235
|
-
if(btZoomToCoordinates){
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
}
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
255
|
+
if (btZoomToCoordinates) {
|
256
|
+
btZoomToCoordinates.addEventListener("click", function () {
|
257
|
+
let level = 4;
|
258
|
+
if (document.getElementById("zoomLevelToCoordinates")) {
|
259
|
+
//zoom Level
|
260
|
+
level = document.getElementById("zoomLevelToCoordinates").value;
|
261
|
+
}
|
262
|
+
if (clickedCoordinates) {
|
263
|
+
communicator.zoomToCoordinates(
|
264
|
+
clickedCoordinates[0],
|
265
|
+
clickedCoordinates[1],
|
266
|
+
level
|
267
|
+
);
|
268
|
+
} else {
|
269
|
+
Error_container.innerHTML = "No coordinates provided";
|
270
|
+
}
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
if (btAddPoint) {
|
275
|
+
btAddPoint.addEventListener("click", function () {
|
276
|
+
communicator.AddGeom("Point");
|
277
|
+
});
|
278
|
+
}
|
279
|
+
if (btAddPolygon) {
|
280
|
+
btAddPolygon.addEventListener("click", function () {
|
281
|
+
communicator.AddGeom("Polygon");
|
282
|
+
});
|
283
|
+
}
|
284
|
+
if (btAddLine) {
|
285
|
+
btAddLine.addEventListener("click", function () {
|
286
|
+
communicator.AddGeom("Line");
|
287
|
+
});
|
288
|
+
}
|
289
|
+
if (btGeolocalize) {
|
290
|
+
btGeolocalize.addEventListener("click", function () {
|
291
|
+
communicator.Geolocalize(true);
|
292
|
+
});
|
293
|
+
}
|
294
|
+
if (btStopGeolocalize) {
|
295
|
+
btStopGeolocalize.addEventListener("click", function () {
|
296
|
+
communicator.Geolocalize(false);
|
297
|
+
});
|
274
298
|
}
|
275
299
|
//**********************************************************
|
276
300
|
//************** LAYERS ****************
|
277
301
|
//**********************************************************
|
278
|
-
if(btToggleLayer){
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
}
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
});
|
302
|
+
if (btToggleLayer) {
|
303
|
+
btToggleLayer.addEventListener("click", function () {
|
304
|
+
if (overrideLayerProperties) {
|
305
|
+
if (overrideLayerProperties.checked) {
|
306
|
+
var properties = {};
|
307
|
+
if (toggleTransparentLayer) {
|
308
|
+
properties.transparent = toggleTransparentLayer.checked;
|
309
|
+
}
|
310
|
+
if (toggleSingleTile) {
|
311
|
+
properties.singletile = toggleSingleTile.checked;
|
312
|
+
}
|
313
|
+
if (gutter) properties.gutter = gutter.value;
|
314
|
+
communicator.toggleLayer(
|
315
|
+
document.getElementById("projectlayers").value,
|
316
|
+
properties
|
317
|
+
);
|
318
|
+
return;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
communicator.toggleLayer(document.getElementById("projectlayers").value);
|
323
|
+
});
|
324
|
+
}
|
325
|
+
|
326
|
+
if (btGetActiveLayer) {
|
327
|
+
btGetActiveLayer.addEventListener("click", function () {
|
328
|
+
cleanContainers();
|
329
|
+
communicator.getActiveLayer();
|
330
|
+
});
|
331
|
+
}
|
332
|
+
if (btReloadDisplayedLayers) {
|
333
|
+
btReloadDisplayedLayers.addEventListener("click", function () {
|
334
|
+
communicator.reloadDisplayedLayers();
|
335
|
+
});
|
336
|
+
}
|
337
|
+
if (btLoadWMSLayers) {
|
338
|
+
btLoadWMSLayers.addEventListener("click", function (evt) {
|
339
|
+
console.log("btLoadWMSLayers");
|
340
|
+
communicator.loadWMSAvailableLayers();
|
341
|
+
});
|
319
342
|
}
|
320
343
|
|
321
344
|
//Override layer properties
|
322
|
-
if(overrideLayerProperties){
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
345
|
+
if (overrideLayerProperties) {
|
346
|
+
overrideLayerProperties.addEventListener("click", function () {
|
347
|
+
if (overrideLayerProperties.checked) {
|
348
|
+
if (containerOverride) containerOverride.style.display = "block";
|
349
|
+
} else {
|
350
|
+
if (containerOverride) containerOverride.style.display = "none";
|
351
|
+
}
|
352
|
+
});
|
353
|
+
}
|
354
|
+
|
355
|
+
if (btGetToc) {
|
356
|
+
btGetToc.addEventListener("click", function (evt) {
|
357
|
+
console.log("btGetToc");
|
358
|
+
communicator.getToc();
|
359
|
+
});
|
360
|
+
}
|
361
|
+
;
|
362
|
+
if(btChangeBackground){
|
363
|
+
btChangeBackground.addEventListener("click", function (evt) {
|
364
|
+
if(newBackground.value){
|
365
|
+
console.log("btChangeBackground",newBackground.value);
|
366
|
+
communicator.changeBackground(newBackground.value);
|
367
|
+
}else{
|
368
|
+
console.warn("no active layer")
|
369
|
+
}
|
370
|
+
});
|
330
371
|
}
|
331
372
|
/*
|
332
373
|
overrideLayerProperties
|
@@ -338,186 +379,203 @@ containerOverride*/
|
|
338
379
|
//**********************************************************
|
339
380
|
//************** END LAYERS ****************
|
340
381
|
//**********************************************************
|
341
|
-
if(btClear){
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
}
|
347
|
-
if(btZoomToExtent){
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
}
|
353
|
-
if(btWMSInfo){
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
382
|
+
if (btClear) {
|
383
|
+
btClear.addEventListener("click", function () {
|
384
|
+
cleanContainers();
|
385
|
+
communicator.clear();
|
386
|
+
});
|
387
|
+
}
|
388
|
+
if (btZoomToExtent) {
|
389
|
+
btZoomToExtent.addEventListener("click", function () {
|
390
|
+
cleanContainers();
|
391
|
+
communicator.zoomToExtent();
|
392
|
+
});
|
393
|
+
}
|
394
|
+
if (btWMSInfo) {
|
395
|
+
btWMSInfo.addEventListener("click", function () {
|
396
|
+
cleanContainers();
|
397
|
+
communicator.infoFromCoordinates(
|
398
|
+
"wms",
|
399
|
+
document.getElementById("layers").value,
|
400
|
+
5,
|
401
|
+
document.getElementById("formatWMS").value
|
402
|
+
);
|
403
|
+
});
|
404
|
+
}
|
405
|
+
if (btGiswaterInfo) {
|
406
|
+
btGiswaterInfo.addEventListener("click", function () {
|
407
|
+
cleanContainers();
|
408
|
+
communicator.infoFromCoordinates(
|
409
|
+
"giswater",
|
410
|
+
document.getElementById("layers").value
|
411
|
+
);
|
412
|
+
});
|
413
|
+
}
|
414
|
+
if (btActiveLayer) {
|
415
|
+
btActiveLayer.addEventListener("click", function () {
|
416
|
+
cleanContainers();
|
417
|
+
communicator.setActiveLayer(document.getElementById("layers").value);
|
418
|
+
currentActiveLayer = document.getElementById("layers").value;
|
419
|
+
document.getElementById(
|
420
|
+
"currentActiveLayer"
|
421
|
+
).innerHTML = `<b>Active layer</b>: ${currentActiveLayer}`;
|
422
|
+
if (btAddGeoJSONFromGiswater) {
|
423
|
+
btAddGeoJSONFromGiswater.disabled = false;
|
424
|
+
}
|
425
|
+
document.getElementById(
|
426
|
+
"currentActiveLayerForGeoJSON"
|
427
|
+
).innerHTML = ` ${currentActiveLayer}`;
|
428
|
+
});
|
429
|
+
}
|
430
|
+
|
431
|
+
if (btHighlight) {
|
432
|
+
btHighlight.addEventListener("click", function () {
|
433
|
+
cleanContainers();
|
434
|
+
var options = {
|
435
|
+
geom: document.getElementById("geom").value,
|
436
|
+
};
|
437
|
+
if (zoomToHighlightCheck.checked) {
|
438
|
+
options.zoom = {
|
439
|
+
type: "geom",
|
440
|
+
};
|
441
|
+
} else {
|
442
|
+
options.zoom = {
|
443
|
+
type: "level",
|
444
|
+
zoomLevel: document.getElementById("zoomLevel").value,
|
445
|
+
};
|
446
|
+
}
|
447
|
+
communicator.Highlight(options);
|
448
|
+
});
|
449
|
+
}
|
450
|
+
if (zoomToHighlightCheck) {
|
451
|
+
//disable/enable zoom level to highlight
|
452
|
+
zoomToHighlightCheck.addEventListener("click", function () {
|
453
|
+
document.getElementById("zoomLevel").disabled =
|
454
|
+
zoomToHighlightCheck.checked;
|
455
|
+
});
|
403
456
|
}
|
404
457
|
//Giswater tiled background
|
405
|
-
if(btToggleGiswaterTiled && toggleGiswaterTiledCheck){
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
458
|
+
if (btToggleGiswaterTiled && toggleGiswaterTiledCheck) {
|
459
|
+
btToggleGiswaterTiled.addEventListener("click", function () {
|
460
|
+
cleanContainers();
|
461
|
+
communicator.toggleGiswaterTiled(toggleGiswaterTiledCheck.checked);
|
462
|
+
});
|
410
463
|
}
|
411
464
|
|
412
465
|
//**********************************************************
|
413
466
|
//************** GeoJSON ****************
|
414
467
|
//**********************************************************
|
415
468
|
|
416
|
-
if(geoJSONFileContent){
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
469
|
+
if (geoJSONFileContent) {
|
470
|
+
geoJSONFileContent.addEventListener("change", handleFiles, false);
|
471
|
+
function handleFiles() {
|
472
|
+
const fileList = this.files;
|
473
|
+
// use the 1st file from the list
|
474
|
+
f = fileList[0];
|
475
|
+
geoJSONName = f.name;
|
476
|
+
var reader = new FileReader();
|
477
|
+
// Closure to capture the file information.
|
478
|
+
reader.onload = (function (theFile) {
|
479
|
+
return function (e) {
|
480
|
+
geoJSONContent = e.target.result;
|
481
|
+
};
|
482
|
+
})(f);
|
483
|
+
|
484
|
+
// Read in the image file as a data URL.
|
485
|
+
reader.readAsText(f);
|
486
|
+
}
|
487
|
+
}
|
488
|
+
if (btAddGeoJSON) {
|
489
|
+
btAddGeoJSON.addEventListener("click", function () {
|
490
|
+
var geoToSend = null;
|
491
|
+
var geojsondata = document.querySelector("#geojsondata");
|
492
|
+
if (geojsondata) {
|
493
|
+
console.log("using geoJSON input");
|
494
|
+
var cleanjson = geojsondata.value.replace(/(\r\n|\n|\r)/gm, "");
|
495
|
+
geoToSend = cleanjson;
|
496
|
+
}
|
497
|
+
if (geoJSONContent) {
|
498
|
+
console.log("using geoJSON file");
|
499
|
+
geoToSend = geoJSONContent;
|
500
|
+
}
|
501
|
+
var fillcolor = document.querySelector("#fillcolor");
|
502
|
+
var strokecolor = document.querySelector("#strokecolor");
|
503
|
+
|
504
|
+
//Check JSON
|
505
|
+
try {
|
506
|
+
let options = {
|
507
|
+
fillcolor: null,
|
508
|
+
strokecolor: null,
|
509
|
+
};
|
510
|
+
if (fillcolor) {
|
511
|
+
options.fillcolor = fillcolor.value;
|
512
|
+
}
|
513
|
+
if (strokecolor) {
|
514
|
+
options.strokecolor = strokecolor.value;
|
515
|
+
}
|
516
|
+
communicator.addGeoJSON(JSON.parse(geoToSend), options, geoJSONName);
|
517
|
+
} catch (e) {
|
518
|
+
console.error("invalid geoJSON", e);
|
519
|
+
}
|
520
|
+
});
|
521
|
+
}
|
522
|
+
|
523
|
+
if (btClearGeoJSON) {
|
524
|
+
btClearGeoJSON.addEventListener("click", function () {
|
525
|
+
communicator.clearGeoJSON();
|
526
|
+
});
|
527
|
+
}
|
528
|
+
|
529
|
+
if (btGeoJSONInfo) {
|
530
|
+
btGeoJSONInfo.addEventListener("click", function () {
|
531
|
+
cleanContainers();
|
532
|
+
let tolerance = 10;
|
533
|
+
if (hitTolerance) {
|
534
|
+
//(typeof hitTolerance!='undefined') ? hitTolerance : 5,
|
535
|
+
tolerance =
|
536
|
+
hitTolerance.value == "" || hitTolerance.value == null
|
537
|
+
? 5
|
538
|
+
: parseInt(hitTolerance.value);
|
539
|
+
}
|
540
|
+
communicator.infoFromCoordinates(
|
541
|
+
"geojson",
|
542
|
+
document.getElementById("geojsonlayers").value,
|
543
|
+
tolerance
|
544
|
+
);
|
545
|
+
});
|
546
|
+
}
|
547
|
+
|
548
|
+
if (btRemoveGeoJSONLayer) {
|
549
|
+
btRemoveGeoJSONLayer.addEventListener("click", function () {
|
550
|
+
cleanContainers();
|
551
|
+
communicator.removeGeoJSONLayer(
|
552
|
+
document.getElementById("geojsonlayers").value
|
553
|
+
);
|
554
|
+
});
|
555
|
+
}
|
556
|
+
|
557
|
+
function fillGeoJSONLayersSelect(options) {
|
558
|
+
var layers_select = document.getElementById("geojsonlayers");
|
559
|
+
if (layers_select) {
|
560
|
+
//empty previous options
|
561
|
+
var length = layers_select.options.length;
|
562
|
+
for (i = length - 1; i >= 0; i--) {
|
563
|
+
layers_select.options[i] = null;
|
564
|
+
}
|
565
|
+
for (var i = 0; i < options.length; i++) {
|
566
|
+
var opt = options[i];
|
567
|
+
var el = document.createElement("option");
|
568
|
+
el.textContent = opt;
|
569
|
+
el.value = opt;
|
570
|
+
layers_select.appendChild(el);
|
571
|
+
}
|
572
|
+
}
|
573
|
+
if (btGeoJSONInfo && options.length > 0) {
|
574
|
+
btGeoJSONInfo.disabled = false;
|
575
|
+
}
|
576
|
+
if (btRemoveGeoJSONLayer && options.length > 0) {
|
577
|
+
btRemoveGeoJSONLayer.disabled = false;
|
578
|
+
}
|
521
579
|
}
|
522
580
|
|
523
581
|
//**********************************************************
|
@@ -528,24 +586,22 @@ function fillGeoJSONLayersSelect(options){
|
|
528
586
|
//************** GISWATER FILTERS ****************
|
529
587
|
//**********************************************************
|
530
588
|
|
589
|
+
if (btsetGiswaterFilters) {
|
590
|
+
btsetGiswaterFilters.addEventListener("click", function () {
|
591
|
+
var filters = document.getElementById("giswaterFilters").value;
|
531
592
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
cleanContainers();
|
537
|
-
communicator.setGiswaterFilters(filters);
|
538
|
-
});
|
593
|
+
cleanContainers();
|
594
|
+
communicator.setGiswaterFilters(filters);
|
595
|
+
});
|
539
596
|
}
|
540
|
-
if(btgetGiswaterFilters){
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
597
|
+
if (btgetGiswaterFilters) {
|
598
|
+
btgetGiswaterFilters.addEventListener("click", function () {
|
599
|
+
var layerName = document.getElementById("layers").value;
|
600
|
+
cleanContainers();
|
601
|
+
communicator.getGiswaterLayerAvailableFilters(layerName);
|
602
|
+
});
|
546
603
|
}
|
547
604
|
|
548
|
-
|
549
605
|
//**********************************************************
|
550
606
|
//************** END GISWATER FILTERS ****************
|
551
607
|
//**********************************************************
|
@@ -554,33 +610,32 @@ if(btgetGiswaterFilters){
|
|
554
610
|
//************** CUSTOM COLORS ****************
|
555
611
|
//**********************************************************
|
556
612
|
|
557
|
-
if(btSetColors){
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
});
|
613
|
+
if (btSetColors) {
|
614
|
+
btSetColors.addEventListener("click", function () {
|
615
|
+
var properties = {
|
616
|
+
geom_stroke_color: "rgb(19, 39, 99,0.5)",
|
617
|
+
geom_fill_color: "rgb(19, 39, 99,0.5)",
|
618
|
+
geom_stroke_width: 1,
|
619
|
+
geom_shape: "circle",
|
620
|
+
geom_radius: 4,
|
621
|
+
};
|
622
|
+
if (geom_stroke_color) {
|
623
|
+
properties.geom_stroke_color = geom_stroke_color.value;
|
624
|
+
}
|
625
|
+
if (geom_stroke_width) {
|
626
|
+
properties.geom_stroke_width = geom_stroke_width.value;
|
627
|
+
}
|
628
|
+
if (geom_fill_color) {
|
629
|
+
properties.geom_fill_color = geom_fill_color.value;
|
630
|
+
}
|
631
|
+
if (geom_shape) {
|
632
|
+
properties.geom_shape = geom_shape.value;
|
633
|
+
}
|
634
|
+
if (geom_radius) {
|
635
|
+
properties.geom_radius = geom_radius.value;
|
636
|
+
}
|
637
|
+
communicator.setCustomColors(properties);
|
638
|
+
});
|
584
639
|
}
|
585
640
|
|
586
641
|
//**********************************************************
|
@@ -590,17 +645,21 @@ if(btSetColors){
|
|
590
645
|
//**********************************************************
|
591
646
|
//************** WMS TABLE ****************
|
592
647
|
//**********************************************************
|
593
|
-
if(btGetElementsFromLayer){
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
648
|
+
if (btGetElementsFromLayer) {
|
649
|
+
btGetElementsFromLayer.addEventListener("click", function () {
|
650
|
+
let limit = document.getElementById("limit")
|
651
|
+
? document.getElementById("limit").value
|
652
|
+
: 100;
|
653
|
+
let format = document.getElementById("format")
|
654
|
+
? document.getElementById("format").value
|
655
|
+
: "xml";
|
656
|
+
communicator.getElementsFromLayer(
|
657
|
+
document.getElementById("layers").value,
|
658
|
+
limit,
|
659
|
+
format
|
660
|
+
);
|
661
|
+
});
|
600
662
|
}
|
601
663
|
//**********************************************************
|
602
664
|
//************** END WMS TABLE ****************
|
603
665
|
//**********************************************************
|
604
|
-
|
605
|
-
|
606
|
-
|