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