@vidro/map-handler 1.3.2 → 1.3.4
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.
- package/README.md +67 -1
- package/dist/map-handler.js +1 -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/apidemo.js
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
// Config:
|
|
2
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
3
|
-
const user = urlParams.get("user");
|
|
4
|
-
const pwd = urlParams.get("pwd");
|
|
5
|
-
const apiQuery = urlParams.get("api");
|
|
6
|
-
|
|
7
|
-
if (apiQuery) document.querySelector("#apiurl").value = apiQuery;
|
|
8
|
-
var apiUrl = document.querySelector("#apiurl").value;
|
|
9
|
-
if (user) document.querySelector("#user").value = user;
|
|
10
|
-
if (pwd) document.querySelector("#pwd").value = pwd;
|
|
11
|
-
|
|
12
|
-
// UI:
|
|
13
|
-
var usertoken = document.querySelector("#usertoken");
|
|
14
|
-
var errorContainer = document.querySelector("#errorContainer");
|
|
15
|
-
var loginContainer = document.querySelector("#loginContainer");
|
|
16
|
-
var btLoginAgain = document.querySelector("#btLoginAgain");
|
|
17
|
-
var btLoadMap = document.querySelector("#btLoadMap");
|
|
18
|
-
var btLoadProjectLayers = document.querySelector("#btLoadProjectLayers");
|
|
19
|
-
var projectlayers = document.getElementById("projectlayers");
|
|
20
|
-
var userData = document.querySelector("#userData");
|
|
21
|
-
var btAddGeoJSONFromGiswater = document.querySelector(
|
|
22
|
-
"#btAddGeoJSONFromGiswater"
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
var btLogin = document.querySelector("#btLogin");
|
|
26
|
-
|
|
27
|
-
var projects_select = document.getElementById("selectProject");
|
|
28
|
-
var sessionToken = document.querySelector("#sessionToken");
|
|
29
|
-
var mapContainer = document.querySelector("#mapContainer");
|
|
30
|
-
var iframe = document.querySelector("#map-frame");
|
|
31
|
-
|
|
32
|
-
mapContainer.classList.add("hide");
|
|
33
|
-
|
|
34
|
-
//show login form
|
|
35
|
-
btLoginAgain.addEventListener("click", function (evt) {
|
|
36
|
-
usertoken.value = "";
|
|
37
|
-
loginContainer.classList.remove("hide");
|
|
38
|
-
errorContainer.classList.add("hide");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
//************** LOGIN EXAMPLE
|
|
42
|
-
|
|
43
|
-
btLogin.addEventListener("click", function (evt) {
|
|
44
|
-
apiUrl = document.querySelector("#apiurl").value;
|
|
45
|
-
//Build XMLHttpRequest for login
|
|
46
|
-
//form values
|
|
47
|
-
var user = document.querySelector("#user").value;
|
|
48
|
-
var pwd = document.querySelector("#pwd").value;
|
|
49
|
-
var data = { user: user, pwd: pwd };
|
|
50
|
-
var oReq = new XMLHttpRequest();
|
|
51
|
-
oReq.addEventListener("load", reqListener);
|
|
52
|
-
oReq.open("POST", `${apiUrl}letsgo`, true);
|
|
53
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
54
|
-
oReq.send(JSON.stringify(data));
|
|
55
|
-
console.log("Attem to log in", `${apiUrl}letsgo`, data);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
function reqListener() {
|
|
59
|
-
if (this.status === 200) {
|
|
60
|
-
console.log("Login response", this.responseText);
|
|
61
|
-
var res = JSON.parse(this.responseText);
|
|
62
|
-
//store token value on dom
|
|
63
|
-
usertoken.value = res.message.token;
|
|
64
|
-
//hide login form
|
|
65
|
-
loginContainer.classList.add("hide");
|
|
66
|
-
//simulate cache token
|
|
67
|
-
storeToken(res.message);
|
|
68
|
-
//fill user projects selector
|
|
69
|
-
fillUserProjects(res.message.maps);
|
|
70
|
-
} else {
|
|
71
|
-
console.error(this.status);
|
|
72
|
-
var res = JSON.parse(this.responseText);
|
|
73
|
-
console.log(res.error);
|
|
74
|
-
//show DOM error element
|
|
75
|
-
errorContainer.innerHTML = res.error;
|
|
76
|
-
errorContainer.classList.remove("hide");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
//************** END LOGIN EXAMPLE
|
|
80
|
-
|
|
81
|
-
//************** SIMULATE CACHE
|
|
82
|
-
function storeToken(result) {
|
|
83
|
-
//call a php script for simulate a token cache
|
|
84
|
-
//get current url
|
|
85
|
-
var uri = window.location.href.split("/");
|
|
86
|
-
uri.pop();
|
|
87
|
-
var uristr = uri.join("/");
|
|
88
|
-
var uriForCache = uristr.split("?");
|
|
89
|
-
var oReq = new XMLHttpRequest();
|
|
90
|
-
console.log(uristr);
|
|
91
|
-
oReq.open(
|
|
92
|
-
"GET",
|
|
93
|
-
`${uriForCache[0]}/storeToken.php?token=${result.token}&data=${result.projects}`,
|
|
94
|
-
true
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
98
|
-
oReq.send();
|
|
99
|
-
}
|
|
100
|
-
//************** END SIMULATE CACHE
|
|
101
|
-
|
|
102
|
-
//************** CHECK TOKEN
|
|
103
|
-
function checkToken() {
|
|
104
|
-
//Check if user token is valid
|
|
105
|
-
console.log("checkToken", usertoken.value);
|
|
106
|
-
if (usertoken.value != "") {
|
|
107
|
-
//build XMLHttpRequest for checking token
|
|
108
|
-
var oReq = new XMLHttpRequest();
|
|
109
|
-
oReq.addEventListener("load", tokenListener);
|
|
110
|
-
oReq.open("GET", `${apiUrl}token/`, true);
|
|
111
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
112
|
-
oReq.setRequestHeader("Authorization", `Bearer ${usertoken.value}`);
|
|
113
|
-
|
|
114
|
-
oReq.send();
|
|
115
|
-
console.log("Check token", `${apiUrl}token/`);
|
|
116
|
-
} else {
|
|
117
|
-
//show login form in case usertoken input is empty
|
|
118
|
-
loginContainer.classList.remove("hide");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function getUserProjects() {
|
|
123
|
-
//Check if user token is valid
|
|
124
|
-
console.log("getUserProjects", usertoken.value);
|
|
125
|
-
if (usertoken.value != "") {
|
|
126
|
-
//build XMLHttpRequest for checking token
|
|
127
|
-
var oReq = new XMLHttpRequest();
|
|
128
|
-
oReq.addEventListener("load", projectsListener);
|
|
129
|
-
oReq.open("GET", `${apiUrl}maps/`, true);
|
|
130
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
131
|
-
oReq.setRequestHeader("Authorization", `Bearer ${usertoken.value}`);
|
|
132
|
-
|
|
133
|
-
oReq.send();
|
|
134
|
-
console.log("getUserProjects", `${apiUrl}projects/`);
|
|
135
|
-
} else {
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function projectsListener() {
|
|
140
|
-
if (this.status === 200) {
|
|
141
|
-
var res = JSON.parse(this.responseText);
|
|
142
|
-
console.log("projectsListener", res.message);
|
|
143
|
-
var projects = [];
|
|
144
|
-
for (var i = 0; i < res.message.length; i++) {
|
|
145
|
-
projects.push(res.message[i].map_id);
|
|
146
|
-
}
|
|
147
|
-
fillUserProjects(projects);
|
|
148
|
-
} else {
|
|
149
|
-
//if token is invalid, show login form
|
|
150
|
-
console.error(this.status);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function tokenListener() {
|
|
154
|
-
if (this.status === 200) {
|
|
155
|
-
var res = JSON.parse(this.responseText);
|
|
156
|
-
console.log("Valid user token", res.message);
|
|
157
|
-
console.log("item", localStorage.getItem("selectedProjectId"));
|
|
158
|
-
getUserProjects();
|
|
159
|
-
|
|
160
|
-
//get from localstorage last iframe selected
|
|
161
|
-
var cachedMap = localStorage.getItem("iframe");
|
|
162
|
-
if (cachedMap) {
|
|
163
|
-
errorContainer.classList.add("hide");
|
|
164
|
-
mapContainer.classList.remove("hide");
|
|
165
|
-
iframe.src = cachedMap;
|
|
166
|
-
sessionToken.innerHTML = localStorage.getItem("sessionToken");
|
|
167
|
-
}
|
|
168
|
-
//get user projects
|
|
169
|
-
} else {
|
|
170
|
-
//if token is invalid, show login form
|
|
171
|
-
console.error(this.status);
|
|
172
|
-
var res = JSON.parse(this.responseText);
|
|
173
|
-
console.log(res.error);
|
|
174
|
-
loginContainer.classList.remove("hide");
|
|
175
|
-
usertoken.value = "";
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//************** END CHECK TOKEN
|
|
180
|
-
|
|
181
|
-
//************** User projects SELECT
|
|
182
|
-
|
|
183
|
-
function fillUserProjects(options) {
|
|
184
|
-
console.log("fillUserProjects", options);
|
|
185
|
-
//empty previous options
|
|
186
|
-
var length = projects_select.options.length;
|
|
187
|
-
for (i = length - 1; i >= 0; i--) {
|
|
188
|
-
projects_select.options[i] = null;
|
|
189
|
-
}
|
|
190
|
-
for (var i = 0; i < options.length; i++) {
|
|
191
|
-
var opt = options[i];
|
|
192
|
-
var el = document.createElement("option");
|
|
193
|
-
el.textContent = opt;
|
|
194
|
-
el.value = opt;
|
|
195
|
-
projects_select.appendChild(el);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
var selectedProjectId = localStorage.getItem("selectedProjectId");
|
|
199
|
-
if (selectedProjectId) {
|
|
200
|
-
selectProject(selectedProjectId);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function selectProject(id) {
|
|
205
|
-
document.getElementById("selectProject").value = id;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
//************** END User projects SELECT
|
|
209
|
-
|
|
210
|
-
//************** MAP EXAMPLE
|
|
211
|
-
|
|
212
|
-
btLoadMap.addEventListener("click", function (evt) {
|
|
213
|
-
apiUrl = document.querySelector("#apiurl").value;
|
|
214
|
-
//Build XMLHttpRequest for map
|
|
215
|
-
var selectedProjectId =
|
|
216
|
-
projects_select.options[projects_select.selectedIndex].value;
|
|
217
|
-
localStorage.setItem("selectedProjectId", selectedProjectId);
|
|
218
|
-
//form values
|
|
219
|
-
var zoom = document.querySelector("#zoom").value;
|
|
220
|
-
var data = { zoom: zoom, token: usertoken.value };
|
|
221
|
-
var uri = `${apiUrl}map/${selectedProjectId}?`;
|
|
222
|
-
if (zoom) {
|
|
223
|
-
uri += `&zoom=${zoom}`;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
var logo = document.querySelector("#logo").value;
|
|
227
|
-
if (logo) {
|
|
228
|
-
uri += `&logo=${logo}`;
|
|
229
|
-
}
|
|
230
|
-
var active_layer = document.querySelector("#active_layer").value;
|
|
231
|
-
if (active_layer) {
|
|
232
|
-
uri += `&active_layer=${active_layer}`;
|
|
233
|
-
}
|
|
234
|
-
var overrideHost = document.querySelector("#overrideHost").value;
|
|
235
|
-
if (overrideHost) {
|
|
236
|
-
uri += `&overrideHost=${overrideHost}`;
|
|
237
|
-
data.overrideHost = overrideHost;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
var show_layers = document.querySelector("#show_layers").value;
|
|
241
|
-
if (show_layers) {
|
|
242
|
-
uri += `&show_layers=${show_layers}`;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
var extent = document.querySelector("#extent").value;
|
|
246
|
-
if (extent) {
|
|
247
|
-
uri += `&extent=${extent}`;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
var srid = document.querySelector("#srid").value;
|
|
251
|
-
if (srid) {
|
|
252
|
-
uri += `&srid=${srid}`;
|
|
253
|
-
}
|
|
254
|
-
var use_giswater_tiled = document.querySelector("#use_giswater_tiled");
|
|
255
|
-
if (use_giswater_tiled && use_giswater_tiled.checked) {
|
|
256
|
-
uri += `&use_giswater_tiled=${use_giswater_tiled.checked}`;
|
|
257
|
-
data.use_giswater_tiled = use_giswater_tiled.checked;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
console.log(uri);
|
|
261
|
-
var oReq = new XMLHttpRequest();
|
|
262
|
-
oReq.addEventListener("load", mapListener);
|
|
263
|
-
oReq.open("GET", uri, true);
|
|
264
|
-
oReq.setRequestHeader("Authorization", `Bearer ${usertoken.value}`);
|
|
265
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
266
|
-
oReq.send(JSON.stringify(data));
|
|
267
|
-
console.log("Attempt to load map", `${apiUrl}map/${selectedProjectId}`, data);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
function mapListener() {
|
|
271
|
-
if (this.status === 200) {
|
|
272
|
-
console.log("mapListener response", this.responseText);
|
|
273
|
-
var res = JSON.parse(this.responseText);
|
|
274
|
-
errorContainer.classList.add("hide");
|
|
275
|
-
mapContainer.classList.remove("hide");
|
|
276
|
-
var src = `${res.message.iframe}?sessionToken=${res.message.sessionToken}`;
|
|
277
|
-
iframe.src = src;
|
|
278
|
-
console.log("iframe src", src);
|
|
279
|
-
sessionToken.innerHTML = res.message.sessionToken;
|
|
280
|
-
localStorage.setItem("iframe", iframe.src);
|
|
281
|
-
localStorage.setItem("sessionToken", res.message.sessionToken);
|
|
282
|
-
} else {
|
|
283
|
-
console.error(this.status);
|
|
284
|
-
var res = JSON.parse(this.responseText);
|
|
285
|
-
console.error(res.error);
|
|
286
|
-
//show DOM error element
|
|
287
|
-
errorContainer.innerHTML = res.error;
|
|
288
|
-
errorContainer.classList.remove("hide");
|
|
289
|
-
mapContainer.classList.add("hide");
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
//************** END MAP EXAMPLE
|
|
293
|
-
|
|
294
|
-
//************** PROJECT LAYER
|
|
295
|
-
|
|
296
|
-
btLoadProjectLayers.addEventListener("click", function (evt) {
|
|
297
|
-
apiUrl = document.querySelector("#apiurl").value;
|
|
298
|
-
|
|
299
|
-
//Build XMLHttpRequest for project layers
|
|
300
|
-
var selectedProjectId =
|
|
301
|
-
projects_select.options[projects_select.selectedIndex].value;
|
|
302
|
-
|
|
303
|
-
var uri = `${apiUrl}/layers/${selectedProjectId}`;
|
|
304
|
-
|
|
305
|
-
var oReq = new XMLHttpRequest();
|
|
306
|
-
oReq.addEventListener("load", layersListener);
|
|
307
|
-
oReq.open("GET", uri, true);
|
|
308
|
-
oReq.setRequestHeader("Authorization", `Bearer ${usertoken.value}`);
|
|
309
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
310
|
-
oReq.send();
|
|
311
|
-
console.log("Attempt to load project layers", uri);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
function layersListener() {
|
|
315
|
-
if (this.status === 200) {
|
|
316
|
-
console.log("layersListener response", this.responseText);
|
|
317
|
-
var res = JSON.parse(this.responseText);
|
|
318
|
-
var length = projectlayers.options.length;
|
|
319
|
-
console.log(res);
|
|
320
|
-
for (i = length - 1; i >= 0; i--) {
|
|
321
|
-
projectlayers.options[i] = null;
|
|
322
|
-
}
|
|
323
|
-
for (var i = 0; i < res.message.length; i++) {
|
|
324
|
-
var opt = res.message[i].qgis_name;
|
|
325
|
-
var el = document.createElement("option");
|
|
326
|
-
el.textContent = opt;
|
|
327
|
-
el.value = opt;
|
|
328
|
-
projectlayers.appendChild(el);
|
|
329
|
-
}
|
|
330
|
-
} else {
|
|
331
|
-
console.error(this.status);
|
|
332
|
-
var res = JSON.parse(this.responseText);
|
|
333
|
-
console.log(res.error);
|
|
334
|
-
//show DOM error element
|
|
335
|
-
errorContainer.innerHTML = res.error;
|
|
336
|
-
errorContainer.classList.remove("hide");
|
|
337
|
-
mapContainer.classList.add("hide");
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function fillLayersSelect(options) {
|
|
342
|
-
//empty previous options
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (btAddGeoJSONFromGiswater) {
|
|
346
|
-
btAddGeoJSONFromGiswater.addEventListener("click", function () {
|
|
347
|
-
let lay = document
|
|
348
|
-
.getElementById("currentActiveLayerForGeoJSON")
|
|
349
|
-
.innerHTML.trim();
|
|
350
|
-
console.log(`Requesting Giswater GeoJSON for layer ${lay}`);
|
|
351
|
-
if (lay && lay !== "") {
|
|
352
|
-
apiUrl = document.querySelector("#apiurl").value;
|
|
353
|
-
//Build XMLHttpRequest
|
|
354
|
-
var selectedProjectId =
|
|
355
|
-
projects_select.options[projects_select.selectedIndex].value;
|
|
356
|
-
var uri = `${apiUrl}giswater/geojson/${selectedProjectId}/${lay}`;
|
|
357
|
-
var oReq = new XMLHttpRequest();
|
|
358
|
-
oReq.addEventListener("load", GeoJSONListener);
|
|
359
|
-
oReq.open("GET", uri, true);
|
|
360
|
-
oReq.setRequestHeader("Authorization", `Bearer ${usertoken.value}`);
|
|
361
|
-
oReq.setRequestHeader("Content-type", "application/json");
|
|
362
|
-
oReq.send();
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function GeoJSONListener() {
|
|
368
|
-
if (this.status === 200) {
|
|
369
|
-
try {
|
|
370
|
-
var res = JSON.parse(this.responseText);
|
|
371
|
-
console.log("GeoJSONListener response", res.message);
|
|
372
|
-
if (document.getElementById("geojsondata")) {
|
|
373
|
-
document.getElementById("geojsondata").value = JSON.stringify(
|
|
374
|
-
res.message
|
|
375
|
-
);
|
|
376
|
-
var btAddGeoJSON = document.querySelector("#btAddGeoJSON");
|
|
377
|
-
if (btAddGeoJSON) {
|
|
378
|
-
btAddGeoJSON.click();
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
} catch (e) {
|
|
382
|
-
console.error("Invalid API response");
|
|
383
|
-
}
|
|
384
|
-
} else {
|
|
385
|
-
console.error(this.status);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
e47b595bdd549b83c9c061918313886e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
undefined
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
FROM ubuntu:20.04
|
|
2
|
-
|
|
3
|
-
# Set timezone to UTC to avoid tzdata interactive mode
|
|
4
|
-
ENV TZ=Etc/UTC
|
|
5
|
-
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
6
|
-
|
|
7
|
-
# Update packages and install Apache + PHP 7.4
|
|
8
|
-
RUN apt-get update && apt-get install -y \
|
|
9
|
-
apache2 \
|
|
10
|
-
php7.4 \
|
|
11
|
-
libapache2-mod-php7.4 \
|
|
12
|
-
php7.4-cli \
|
|
13
|
-
php7.4-mbstring \
|
|
14
|
-
php7.4-xml \
|
|
15
|
-
php7.4-curl \
|
|
16
|
-
php7.4-mysql \
|
|
17
|
-
php7.4-zip \
|
|
18
|
-
&& apt-get clean
|
|
19
|
-
|
|
20
|
-
# Set working directory
|
|
21
|
-
WORKDIR /var/www/html
|
|
22
|
-
|
|
23
|
-
# Expose port 80
|
|
24
|
-
EXPOSE 80
|
|
25
|
-
|
|
26
|
-
# Start Apache in foreground
|
|
27
|
-
CMD ["apache2ctl", "-D", "FOREGROUND"]
|
package/examples/full/index.php
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
|
|
3
|
-
<head>
|
|
4
|
-
<title>🛠️ MAP TESTER</title>
|
|
5
|
-
<link rel="stylesheet" href="tester.css">
|
|
6
|
-
</link>
|
|
7
|
-
<link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-32x32.png" sizes="32x32" />
|
|
8
|
-
<link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body onload="checkToken()">
|
|
12
|
-
<div class="form">
|
|
13
|
-
<div>
|
|
14
|
-
Api URL <input type="text" name="apiurl" id="apiurl" value="http://localhost" size="30">
|
|
15
|
-
</div>
|
|
16
|
-
<div>
|
|
17
|
-
User token: <input type="text" name="usertoken" id="usertoken" disabled size="40" value="<?php echo getUserToken(); ?>"> - <button id="btLoginAgain">Login again</button>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="error hide" id="errorContainer">Errr</div>
|
|
21
|
-
<div class="form hide" id="loginContainer">
|
|
22
|
-
User: <input type="text" name="user" id="user" value="">
|
|
23
|
-
Password: <input type="password" name="pwd" id="pwd" value="">
|
|
24
|
-
<button id="btLogin">Log in</button>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
<div class="form" id="userData">
|
|
28
|
-
<h1>Map Properties</h1>
|
|
29
|
-
<div>
|
|
30
|
-
Project ID
|
|
31
|
-
<select id="selectProject">
|
|
32
|
-
<?php
|
|
33
|
-
$cachedProjects = getCachedProjects();
|
|
34
|
-
if (count($cachedProjects) > 0) {
|
|
35
|
-
foreach ($cachedProjects as $pr) {
|
|
36
|
-
?>
|
|
37
|
-
<option id="<?php echo $pr; ?>"><?php echo $pr; ?></option>
|
|
38
|
-
<?php
|
|
39
|
-
}
|
|
40
|
-
?>
|
|
41
|
-
<?php
|
|
42
|
-
}
|
|
43
|
-
?>
|
|
44
|
-
</select>
|
|
45
|
-
</div>
|
|
46
|
-
<div>
|
|
47
|
-
Zoom: <input type="text" name="zoom" id="zoom" size="5" value=""> <small>Override default zoom level</small>
|
|
48
|
-
</div>
|
|
49
|
-
<div>
|
|
50
|
-
Custom logo: <input type="text" name="logo" id="logo" size="25" value=""> <small>Customize logo</small>
|
|
51
|
-
</div>
|
|
52
|
-
<div>
|
|
53
|
-
Show Layers: <input type="text" name="show_layers" id="show_layers" size="25" value="" placeholder="Arc,LOT"> <small>Show layers on map load</small>
|
|
54
|
-
</div>
|
|
55
|
-
<div>
|
|
56
|
-
Active layer: <input type="text" name="active_layer" id="active_layer" size="25" value=""> <small>Set a layer as active layer on map load</small>
|
|
57
|
-
</div>
|
|
58
|
-
<div>
|
|
59
|
-
Use Giswater tiled: <input type="checkbox" name="use_giswater_tiled" id="use_giswater_tiled" size="5" value=""> <small>If tiled background available, load it with map render</small>
|
|
60
|
-
</div>
|
|
61
|
-
<div>
|
|
62
|
-
Override Capabitilites extent: <input type="text" name="extent" id="extent" size="55" value="" placeholder="397663,4615771,406392,4623596"> <small>Override project extent</small>
|
|
63
|
-
</div>
|
|
64
|
-
<div>
|
|
65
|
-
Override Capabitilites SRID: <input type="text" name="srid" id="srid" size="10" value="" placeholder="EPSG:2831"> <small>Override project srid</small>
|
|
66
|
-
</div>
|
|
67
|
-
<hr>
|
|
68
|
-
<h5>Development parameters</h5>
|
|
69
|
-
<div>
|
|
70
|
-
Override iframe url: <input type="text" name="overrideHost" id="overrideHost" size="35" value="http://localhost:3000" placeholder="http://localhost:3000"> <small>Override map component url</small>
|
|
71
|
-
</div>
|
|
72
|
-
<div>
|
|
73
|
-
Debug
|
|
74
|
-
<button id="btDebug">Debug</button>
|
|
75
|
-
<select id="debug">
|
|
76
|
-
<option id="1" selected value=1>Show logs</option>
|
|
77
|
-
<option id="0" value=0>Hide logs</option>
|
|
78
|
-
</select> <small>Show/hide component logs</small>
|
|
79
|
-
</div>
|
|
80
|
-
<hr>
|
|
81
|
-
<div>
|
|
82
|
-
<button id="btLoadMap">Load Map</button> -
|
|
83
|
-
<button id="btLoadProjectLayers">Load Project layers</button>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<div id="mapContainer" class="hide">
|
|
88
|
-
<div id="Error_container"></div>
|
|
89
|
-
<div id="sessionToken"></div>
|
|
90
|
-
<div id="iframes-container">
|
|
91
|
-
<iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" allow="geolocation"></iframe>
|
|
92
|
-
</div>
|
|
93
|
-
<hr />
|
|
94
|
-
<pre id="Result_container"></pre>
|
|
95
|
-
<hr />
|
|
96
|
-
<h2>Layers</h2>
|
|
97
|
-
|
|
98
|
-
Project Layers: <select id="projectlayers"></select> - <small>click on "Load Project Layers button</small> <button id="btToggleLayer">Add / Remove Layer</button><br><br>
|
|
99
|
-
Displayed Layers: <select id="layers"></select> -
|
|
100
|
-
<button id="btActiveLayer">Set Active Layer</button>
|
|
101
|
-
<button id="btGetActiveLayer">Get Active Layer</button>
|
|
102
|
-
<span id="currentActiveLayer"></span>
|
|
103
|
-
<button id="btReloadDisplayedLayers">Reload displayed layers</button>
|
|
104
|
-
<br><br>
|
|
105
|
-
Get TOC: <button id="btGetToc">Get TOC</button>
|
|
106
|
-
<br><br>
|
|
107
|
-
Override layer properties (gutter, single/multi tile, transparent)
|
|
108
|
-
<input type="checkbox" name="overrideLayerProperties" id="overrideLayerProperties" value="">
|
|
109
|
-
<div id="containerOverride" style="display: none;">____________________________________________________<br><br>
|
|
110
|
-
Gutter: <input type="text" name="gutter" id="gutter" size="5" value="">
|
|
111
|
-
<br><br>
|
|
112
|
-
Transparent layer:
|
|
113
|
-
<input type="checkbox" name="toggleTransparentLayer" id="toggleTransparentLayer" checked value=""><br><br>
|
|
114
|
-
SingleTile layer:
|
|
115
|
-
<input type="checkbox" name="toggleSingleTile" id="toggleSingleTile" checked value=""><br>
|
|
116
|
-
<br>
|
|
117
|
-
____________________________________________________
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<h4>Tiled layer</h4>
|
|
121
|
-
<button id="btToggleGiswaterTiled" disabled="true">Show/hide tiled Giswater tiled background</button>
|
|
122
|
-
<input type="checkbox" name="toggleGiswaterTiledCheck" id="toggleGiswaterTiledCheck" size="5" value=""><br><br>
|
|
123
|
-
<small>only for giswater projects with tiled enabled</small>
|
|
124
|
-
</div>
|
|
125
|
-
<h2>Zoom</h2>
|
|
126
|
-
<button id="btZoomIn">Zoom In</button>
|
|
127
|
-
<button id="btZoomOut">Zoom Out</button>
|
|
128
|
-
<button id="btZoomToExtent">Zoom to extent</button>
|
|
129
|
-
<br><br>
|
|
130
|
-
<button id="btZoomToCoordinates">Zoom to coordinates</button>
|
|
131
|
-
ZoomToCoordinates level: <input type="text" name="zoomLevelToCoordinates" id="zoomLevelToCoordinates" size="5" value="4">
|
|
132
|
-
<h2>Add geometry</h2>
|
|
133
|
-
<button id="btAddPoint">Add point</button>
|
|
134
|
-
<button id="btAddPolygon">Add polygon</button>
|
|
135
|
-
<button id="btAddLine">Add line</button>
|
|
136
|
-
<button id="btClear">Clear geometries</button>
|
|
137
|
-
<h2>Info</h2>
|
|
138
|
-
<button id="btWMSInfo" disabled="true">WMS Info</button>
|
|
139
|
-
<select id="formatWMS">
|
|
140
|
-
<option id="xml" selected value="xml">XML</option>
|
|
141
|
-
<option id="json" value="json">JSON</option>
|
|
142
|
-
</select> <small>Output format</small>
|
|
143
|
-
<button id="btGiswaterInfo">Giswater Info</button>
|
|
144
|
-
|
|
145
|
-
<h2>Geolocation</h2>
|
|
146
|
-
<button id="btGeolocalize">Geolocalize User</button>
|
|
147
|
-
<button id="btStopGeolocalize">Cancel Geolocalize</button>
|
|
148
|
-
|
|
149
|
-
<h2>Highlight</h2>
|
|
150
|
-
<button id="btHighlight">Highlight geom</button>
|
|
151
|
-
Geom: <input type="text" name="geom" id="geom" size="25" value="">
|
|
152
|
-
<br>
|
|
153
|
-
Highlight to zoom level: <input type="text" name="zoomLevel" id="zoomLevel" size="5" value=""> or Zoom to geometry: <input type="checkbox" name="zoomToHighlightCheck" id="zoomToHighlightCheck" size="5" value="">
|
|
154
|
-
<h2>Giswater Filters</h2>
|
|
155
|
-
<button id="btsetGiswaterFilters">Set giswater filters</button> - <button id="btgetGiswaterFilters">Get giswater layer available filters</button><br><br>
|
|
156
|
-
<textarea name="giswaterFilters" id="giswaterFilters" rows="10" cols="20">{"expl_id":[1,2,3]}</textarea>
|
|
157
|
-
<h2>GeoJSON</h2>
|
|
158
|
-
<input type="file" id="geojsonfile" name="geojsonfile" accept="application/json"><small> Select geoJSON file</small><br><br>
|
|
159
|
-
<small>Load a geojson from a Giswater layer<b><span id="currentActiveLayerForGeoJSON"></span></b></span></small> <button id="btAddGeoJSONFromGiswater" disabled>Add GeoJSON from Giswater Layer </button>
|
|
160
|
-
<input type="hidden" name="geojsondata" id="geojsondata" />
|
|
161
|
-
<br><br>
|
|
162
|
-
<b>Options</b><br><br>
|
|
163
|
-
Geojson layer name: <input type="text" name="geojsonaLayername" id="geojsonaLayername" size="25" value="geojsontest"><br>
|
|
164
|
-
Stroke color: <input type="text" name="strokecolor" id="strokecolor" size="10" value="#FF0000" placeholder="#000000"> <small>Override stroke color, desfault #ff0000</small><br>
|
|
165
|
-
Fill color: <input type="text" name="fillcolor" id="fillcolor" size="10" value="#FF0000" placeholder="#000000"> <small>Override fill color, desfault #ff0000</small><br><br>
|
|
166
|
-
<button id="btSetColors">Set colors</button>
|
|
167
|
-
<button id="btAddGeoJSON">Add GeoJSON Layer</button> <button id="btClearGeoJSON">Clear GeoJSON Layer</button><br><br>
|
|
168
|
-
<input type="text" name="hitTolerance" id="hitTolerance" size="5" value="" placeholder="5"> <small>Override hit tolerance</small><br><br>
|
|
169
|
-
|
|
170
|
-
Selected GeoJSON Layer: <select id="geojsonlayers"></select> - <button id="btGeoJSONInfo" disabled="true">GeoJSON Info</button> <button id="btRemoveGeoJSONLayer" disabled="true">Remove GeoJSON Layer</button><br><br>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
<script src="https://unpkg.com/@vidro/map-handler@1.2.191/dist/map-handler.js"></script>
|
|
174
|
-
<script src="./tester.js"></script>
|
|
175
|
-
<script src="./apidemo.js"></script>
|
|
176
|
-
</body>
|
|
177
|
-
|
|
178
|
-
</html>
|
|
179
|
-
<?php
|
|
180
|
-
function getCachedProjects()
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
$cacheFileName = "cachedTokenData.dat";
|
|
184
|
-
if (file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400) { // 24 hours
|
|
185
|
-
$chachedProjects = file_get_contents($cacheFileName);
|
|
186
|
-
}
|
|
187
|
-
return explode(",", $chachedProjects);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
function getUserToken()
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
$cacheFileName = "cachedToken.dat";
|
|
195
|
-
if (file_exists($cacheFileName) && time() - filemtime($cacheFileName) < 86400) { // 24 hours
|
|
196
|
-
$userToken = file_get_contents($cacheFileName);
|
|
197
|
-
}
|
|
198
|
-
return $userToken;
|
|
199
|
-
}
|
|
200
|
-
?>
|