@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.
Files changed (82) hide show
  1. package/README.md +67 -1
  2. package/map-handler.d.ts +134 -0
  3. package/package.json +10 -4
  4. package/src/types.d.ts +63 -0
  5. package/.babelrc +0 -6
  6. package/doc/animation.png +0 -0
  7. package/doc/confirmComponent.png +0 -0
  8. package/doc/giswater.png +0 -0
  9. package/doc/giswaterInfo.png +0 -0
  10. package/doc/giswaterInfoApi.png +0 -0
  11. package/doc/giswatergeojson.png +0 -0
  12. package/doc/multiTile.png +0 -0
  13. package/doc/multiTileNoGutter.png +0 -0
  14. package/doc/togglelayergiswater.png +0 -0
  15. package/doc/vidromaps-basic.png +0 -0
  16. package/examples/full/apidemo.js +0 -387
  17. package/examples/full/cachedToken.dat +0 -1
  18. package/examples/full/cachedTokenData.dat +0 -1
  19. package/examples/full/docker/Docker_compose.yml +0 -14
  20. package/examples/full/docker/Dockerfile +0 -27
  21. package/examples/full/index.php +0 -200
  22. package/examples/full/storeToken.php +0 -6
  23. package/examples/full/tester.css +0 -74
  24. package/examples/full/tester.js +0 -658
  25. package/examples/multipleIframes/index.js +0 -82
  26. package/examples/multipleIframes/index.php +0 -52
  27. package/examples/react-next/README.md +0 -282
  28. package/examples/react-next/atoms/PrintLayoutSelector.js +0 -51
  29. package/examples/react-next/atoms/PrintPaperSizeSelector.js +0 -49
  30. package/examples/react-next/atoms/PrintScaleSelector.js +0 -61
  31. package/examples/react-next/atoms/ZoomToScaleButton.js +0 -57
  32. package/examples/react-next/components/AuthComponent.js +0 -88
  33. package/examples/react-next/components/MapButtons.js +0 -108
  34. package/examples/react-next/components/MapFilters.js +0 -120
  35. package/examples/react-next/components/MapIframe.js +0 -25
  36. package/examples/react-next/components/MapInfo.js +0 -36
  37. package/examples/react-next/components/MapLayers.js +0 -60
  38. package/examples/react-next/components/MapList.js +0 -51
  39. package/examples/react-next/components/MapPrint.js +0 -50
  40. package/examples/react-next/contexts/auth.js +0 -147
  41. package/examples/react-next/contexts/maps.js +0 -185
  42. package/examples/react-next/contexts/messages.js +0 -358
  43. package/examples/react-next/contexts/print.js +0 -125
  44. package/examples/react-next/env.sample +0 -3
  45. package/examples/react-next/eslint.config.mjs +0 -14
  46. package/examples/react-next/hooks/useMapEvents.js +0 -118
  47. package/examples/react-next/jsconfig.json +0 -7
  48. package/examples/react-next/next.config.mjs +0 -6
  49. package/examples/react-next/package.json +0 -25
  50. package/examples/react-next/pages/_app.js +0 -5
  51. package/examples/react-next/pages/index.js +0 -97
  52. package/examples/react-next/postcss.config.mjs +0 -8
  53. package/examples/react-next/public/discord.svg +0 -8
  54. package/examples/react-next/public/favicon.ico +0 -0
  55. package/examples/react-next/public/file.svg +0 -1
  56. package/examples/react-next/public/logo.png +0 -0
  57. package/examples/react-next/public/next.svg +0 -1
  58. package/examples/react-next/shared/constants.js +0 -48
  59. package/examples/react-next/shared/cookies.js +0 -23
  60. package/examples/react-next/styles/globals.css +0 -24
  61. package/examples/react-next/tailwind.config.mjs +0 -17
  62. package/examples/serverLess/dist/index.23420cfa.js +0 -2973
  63. package/examples/serverLess/dist/index.23420cfa.js.map +0 -1
  64. package/examples/serverLess/dist/index.91b6cacc.js +0 -2
  65. package/examples/serverLess/dist/index.91b6cacc.js.map +0 -1
  66. package/examples/serverLess/dist/index.html +0 -1
  67. package/examples/serverLess/index.html +0 -39
  68. package/examples/serverLess/main.js +0 -113
  69. package/examples/serverLess/package.json +0 -18
  70. package/examples/serverLess/readme.md +0 -41
  71. package/examples/simple/index.html +0 -23
  72. package/examples/simple/simple.js +0 -80
  73. package/examples/taigua/index.html +0 -55
  74. package/examples/taigua/main.js +0 -490
  75. package/examples/tester.css +0 -74
  76. package/examples/vidromap/index.js +0 -20
  77. package/examples/vidromap/index.php +0 -111
  78. package/flows.md +0 -73
  79. package/helpers.md +0 -45
  80. package/src/index.js +0 -882
  81. package/src/shared/iframe-communicator.js +0 -18
  82. package/webpack.config.js +0 -22
@@ -1,113 +0,0 @@
1
- import axios from "axios"; //lib for simplify XMLHttpRequest
2
- import { Communicator } from "@vidro/map-handler"; //Vidro Software map js library
3
- import parser from "xml2json-light"; //open source XML to JSON, used for parse WMS Info
4
- let clickedPoint = null; //store clicked coordinates for further use
5
-
6
- const apiUrl = "<YOUR API URL>";
7
- const user = "<YOUR USER>";
8
- const pwd = "<YOUR USER PASSWORD>";
9
- const customLogo = "<YOUR LOGO URL>";
10
-
11
- const layerToLoad = "Arc"; //Layer to be loaded
12
- const zoomLevel = 17;
13
-
14
- //DOM Elements
15
- const iframe = document.querySelector("#map-frame");
16
- const infoContainer = document.querySelector("#infoContainer");
17
- const infoContent = document.querySelector("#infoContent");
18
- const closeInfo = document.querySelector("#closeInfo");
19
-
20
- //1. Get BMAPS user token
21
- axios
22
- .post(`${apiUrl}letsgo`, {
23
- user: user,
24
- pwd: pwd,
25
- })
26
- .then(function (response) {
27
- console.log(response.data.message);
28
- const userToken = response.data.message.token;
29
- //2. Get first user project
30
- const project_id = response.data.message.projects[0];
31
- console.log(project_id);
32
- //3. Get Map
33
- axios
34
- .get(`${apiUrl}map/${project_id}`, {
35
- headers: { Authorization: `Bearer ${userToken}` },
36
- params: {
37
- logo: customLogo,
38
- active_layer: layerToLoad,
39
- show_layers: layerToLoad,
40
- zoom: zoomLevel,
41
- },
42
- })
43
- .then(function (response) {
44
- console.log(response.data.message);
45
- const sessionToken = response.data.message.sessionToken;
46
- //4. Load iframe
47
- iframe.src = `${response.data.message.iframe}?sessionToken=${sessionToken}`;
48
- //5. Use js lib
49
- const communicator = new Communicator({
50
- sessionToken: sessionToken,
51
- });
52
- //6. Do WMS info on clickclicked coordinates
53
- communicator.on("coordinates", function (data) {
54
- console.info("clicked coordinates", data);
55
- //create geometry for highlight clicked point and center map
56
- clickedPoint = `POINT(${data.coordinates[0]} ${data.coordinates[1]})`;
57
- communicator.infoFromCoordinates("wms", layerToLoad);
58
- });
59
-
60
- //info event
61
- communicator.on("info", function (data) {
62
- console.log("info received", data);
63
- communicator.clear(); //clear previous higlight geometry
64
- //highlight click point and center map o it
65
- communicator.Highlight({
66
- geom: clickedPoint,
67
- zoom: { type: "level", zoomLevel: zoomLevel },
68
- });
69
- //parse WMS and display Arc Id attributte
70
- let arc_id = parseWMSInfo(data.data);
71
- if (arc_id) {
72
- infoContainer.style.display = "block"; //show info container
73
- infoContent.innerHTML = `ID: ${parseWMSInfo(data.data)}`;
74
- } else {
75
- infoContainer.style.display = "none"; //hide info container in case there's no info
76
- }
77
- });
78
- })
79
- .catch(function (error) {
80
- console.log(error);
81
- });
82
- })
83
-
84
- .catch(function (error) {
85
- console.log(error);
86
- });
87
-
88
- //DOM handlers
89
- closeInfo.addEventListener("click", (evt) => {
90
- infoContainer.style.display = "none";
91
- });
92
-
93
- const parseWMSInfo = (data) => {
94
- //console.log("parseWMSInfo", data);
95
- try {
96
- let parsedData = parser.xml2json(data);
97
- for (
98
- let i = 0;
99
- i < parsedData.GetFeatureInfoResponse.Layer.Feature.Attribute.length;
100
- i++
101
- ) {
102
- if (
103
- parsedData.GetFeatureInfoResponse.Layer.Feature.Attribute[i].name ===
104
- "arc_id"
105
- ) {
106
- return parsedData.GetFeatureInfoResponse.Layer.Feature.Attribute[i]
107
- .value;
108
- }
109
- }
110
- } catch (e) {
111
- return false;
112
- }
113
- };
@@ -1,18 +0,0 @@
1
- {
2
- "name": "serverlessMapHandlerExample",
3
- "version": "1.0.0",
4
- "scripts": {
5
- "start": "parcel index.html",
6
- "build": "parcel build --public-url . index.html"
7
- },
8
- "author": "",
9
- "license": "ISC",
10
- "devDependencies": {
11
- "parcel": "^2.0.0-beta.2"
12
- },
13
- "dependencies": {
14
- "@vidro/map-handler": "^1.0.5",
15
- "axios": "^0.21.1",
16
- "xml2json-light": "^1.0.6"
17
- }
18
- }
@@ -1,41 +0,0 @@
1
- # Map Handler ServerLess Demo
2
-
3
- #### Version 1.0.0 - July 2021
4
-
5
- Simple server less map integration.
6
-
7
- Loads a BMAPS map with custom logo and one layer rendered.
8
- On map click, performs an wms info and shows a property value.
9
-
10
-
11
- ## Installation
12
-
13
- Open a terminal/shell:
14
-
15
- ```
16
- cd examples/serverLess
17
- ```
18
- Install dependencies
19
-
20
- ```
21
- npm install
22
- ```
23
-
24
- Edit your credentials in `examples/serverLess/main.js` :
25
-
26
- ```
27
- const apiUrl = "<YOUR API URL>";
28
- const user = "<YOUR USER>";
29
- const pwd = "<YOUR USER PASSWORD>";
30
- const customLogo ="<YOUR LOGO URL>";
31
- ```
32
-
33
- Run
34
-
35
- ```
36
- npm start
37
- ```
38
-
39
- View
40
-
41
- Open a web broser with this url: `http://localhost:1234/`
@@ -1,23 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Vidro Maps Simple demo</title>
4
- <link rel="stylesheet" href="../tester.css"></link>
5
- <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-32x32.png" sizes="32x32" />
6
- <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
7
- </head>
8
- <body onload="loadMap()">
9
- <div>
10
- <b>Run</b>
11
- <br>
12
- <br>https://www.vidrosoftware.com/examples/simple/?user=user&pwd=pwd&api=API URL
13
- </div>
14
- <div id="iframes-container">
15
- <iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" ></iframe>
16
- </div>
17
- <button id="btZoomIn">Zoom In</button>
18
- <button id="btZoomOut">Zoom Out</button>
19
- <button id="btZoomToExtent">Zoom to extent</button>
20
- <script src="https://unpkg.com/@vidro/map-handler@1.0.0/dist/map-handler.js"></script>
21
- <script src="./simple.js"></script>
22
- </body>
23
- </html>
@@ -1,80 +0,0 @@
1
- // Config:
2
- var communicator = null;
3
- var usertoken = null;
4
- var sessionToken = null;
5
- var iframe = document.querySelector("#map-frame");
6
- const urlParams = new URLSearchParams(window.location.search);
7
- const user = urlParams.get("user");
8
- const pwd = urlParams.get("pwd");
9
- const apiUrl = urlParams.get("api");
10
-
11
- //************** Simple example
12
-
13
- function loadMap() {
14
- //************************************************
15
- //************************************************
16
- //************* **************
17
- //************* 1. Get user token **************
18
- //************* **************
19
- //************************************************
20
- //************************************************
21
-
22
- var data = { user: user, pwd: pwd };
23
- //Build XMLHttpRequest to API
24
- var oReq = new XMLHttpRequest();
25
- oReq.open("POST", `${apiUrl}letsgo`, true);
26
- oReq.setRequestHeader("Content-type", "application/json");
27
- oReq.send(JSON.stringify(data));
28
- console.log("Attempt to get user token", `${apiUrl}letsgo`, data);
29
- oReq.addEventListener("load", function () {
30
- console.log("Get user token response", this.responseText);
31
- var res = JSON.parse(this.responseText);
32
- //store token
33
- usertoken = res.message.token;
34
- var dataForMap = { token: usertoken };
35
-
36
- //************************************************
37
- //************************************************
38
- //************* **************
39
- //************* 2. Get MAP **************
40
- //************* **************
41
- //************************************************
42
- //************************************************
43
-
44
- //Build XMLHttpRequest to API
45
- var uri = `${apiUrl}map/${res.message.projects[0]}`;
46
- var loadMapReq = new XMLHttpRequest();
47
- loadMapReq.addEventListener("load", function () {
48
- console.log("Map response", this.responseText);
49
- var res = JSON.parse(this.responseText);
50
- sessionToken = res.message.sessionToken;
51
-
52
- //start JS Communicator
53
- communicator = new VidroMaps.Communicator({ sessionToken });
54
-
55
- //Load iframe
56
- iframe.src = `${res.message.iframe}?sessionToken=${sessionToken}`;
57
-
58
- // Map events
59
- communicator.on("onZoomChange", function (data) {
60
- console.log("communicator->onZoomChange", data);
61
- });
62
-
63
- // Map Actions
64
- btZoomIn.addEventListener("click", function () {
65
- communicator.ZoomIn();
66
- });
67
-
68
- btZoomOut.addEventListener("click", function () {
69
- communicator.ZoomOut();
70
- });
71
- btZoomToExtent.addEventListener("click", function () {
72
- communicator.zoomToExtent();
73
- });
74
- });
75
- loadMapReq.open("GET", uri, true);
76
- loadMapReq.setRequestHeader("Content-type", "application/json");
77
- loadMapReq.setRequestHeader("Authorization", `Bearer ${usertoken}`);
78
- loadMapReq.send(JSON.stringify(dataForMap));
79
- });
80
- }
@@ -1,55 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <meta http-equiv=”Content-Type” content=”text/html"; charset=ISO-8859-1 />
4
-
5
- <head>
6
- <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
7
- </head>
8
- <link rel="stylesheet" type="text/css" href="./css/fulla2.css" media="screen" />
9
-
10
- <body>
11
- <!---Menu Lateral Xavi-->
12
-
13
-
14
- <div id="contenedor" name="contenedor" class="contenedor">
15
- <text></text>
16
- <button id="btTanca" name="btTanca">Tancar.</button>
17
- </div>
18
- <main class="main" style="position: relative;">
19
-
20
- <img class="logo_taigua" src="img/logo.png"> </img>
21
- <div id="botonera" style="position: relative;">
22
-
23
- <button id="btZoomIn" name="btZoomIn"> <img id="img" src="./img/zoom-in.png" /></button>
24
- <button id="btZoomOut" name="btZoomOut"><img id="img" src="./img/zoom-out.png"></button>
25
- <button id="btGeoLocation" name="btGeoLocation"><img id="img" src="./img/geo.png"></button>
26
- <button id="btZoomToCoordinates" name="btZoomToCoordinates"><img id="img" src="">ZoomTocoord</button>
27
- <button id="btOfi" name="btOfin">Obres Finalitzades.</button>
28
- <button id="btOex" charset="UTF-8" name="btOfin">Obres en Execuci&oacute;.</button>
29
- <button id="btOpl" name="btOfin">Obres Planificades.</button>
30
- <button id="btOtm" name="btOfin">TM_TERRASSA.</button>
31
- <button id="btGetElementsFromLayer" class="btGetElementsFromLayer" name="btGetElementsFromLayer">Mostrar
32
- Dades</button>
33
- <div id="messages"></div>
34
- <div id="result_container"></div>
35
- <div id="Error_container"></div>
36
- <span id="error"></span>
37
- </div>
38
-
39
- <iframe id="map-frame" name="map-frame" width="100%" height="100%" allow="geolocation"
40
- style="position: relative;"
41
- src="https://component.vidrosoftware.com?sessionToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2ODIwNzk1NTksImF1ZCI6ImY0ODkxOWMwN2IzOGE5YzlmMmUzZDAyYWQ1NGQxNzFi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l3d3x6EwZCO5bfd_Z-lzrhUjwuMpoUKzzGp5JmEwjcWkzvsDEDu9XYuEDeU4zw57B6436MJFipnHXrAkuapyfjx1TZsSEuEh47B8x_Rm2hl65467NrDD5PeSauY2s75zB1OAOD8j7W072G7cbc4w"></iframe>
42
- </main>
43
-
44
- <!---fins aqui el menu-->
45
-
46
-
47
-
48
-
49
-
50
- </body>
51
-
52
- <script src="https://unpkg.com/@vidro/map-handler@1.0.11/dist/map-handler.js"></script>
53
- <script src="main.js"></script>
54
-
55
- </html>