@vidro/map-handler 1.0.4 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. package/README.md +326 -118
  2. package/dist/map-handler.js +1 -1
  3. package/doc/giswater.png +0 -0
  4. package/doc/giswaterInfo.png +0 -0
  5. package/doc/giswaterInfoApi.png +0 -0
  6. package/doc/giswatergeojson.png +0 -0
  7. package/doc/multiTile.png +0 -0
  8. package/doc/multiTileNoGutter.png +0 -0
  9. package/doc/togglelayergiswater.png +0 -0
  10. package/doc/vidromaps-basic.png +0 -0
  11. package/examples/externalwms/index.js +20 -0
  12. package/examples/externalwms/index.php +88 -0
  13. package/examples/full/apidemo.js +54 -11
  14. package/examples/full/cachedToken.dat +1 -1
  15. package/examples/full/cachedTokenData.dat +1 -1
  16. package/examples/full/index.php +37 -18
  17. package/examples/full/tester.js +177 -13
  18. package/examples/integration/tool/css/dist/home.css.min.css +0 -0
  19. package/examples/integration/tool/css/dist/home.min.css +1 -0
  20. package/examples/integration/tool/css/dist/home.min.css.map +10 -0
  21. package/examples/integration/tool/css/dist/style-login.css.min.css +0 -0
  22. package/examples/integration/tool/css/dist/style-login.min.css +1 -0
  23. package/examples/integration/tool/css/dist/style-login.min.css.map +10 -0
  24. package/examples/integration/tool/css/dist/style.css.min.css +0 -0
  25. package/examples/integration/tool/css/dist/style.min.css +1 -0
  26. package/examples/integration/tool/css/dist/style.min.css.map +23 -0
  27. package/examples/integration/tool/css/master/_bottom-sheet-2.scss +103 -0
  28. package/examples/integration/tool/css/master/_bottom-sheet.scss +142 -0
  29. package/examples/integration/tool/css/master/_colors.scss +35 -0
  30. package/examples/integration/tool/css/master/_dropdown-form.scss +167 -0
  31. package/examples/integration/tool/css/master/_forms.scss +416 -0
  32. package/examples/integration/tool/css/master/_header.scss +134 -0
  33. package/examples/integration/tool/css/master/_menu-toc.scss +135 -0
  34. package/examples/integration/tool/css/master/_menu-tools.scss +187 -0
  35. package/examples/integration/tool/css/master/_mixins.scss +42 -0
  36. package/examples/integration/tool/css/master/_notifyjs.scss +39 -0
  37. package/examples/integration/tool/css/master/_ol-map-controls.scss +117 -0
  38. package/examples/integration/tool/css/master/_simplelightbox.scss +287 -0
  39. package/examples/integration/tool/css/master/_toc-config.scss +28 -0
  40. package/examples/integration/tool/css/master/_toc-layouts.scss +173 -0
  41. package/examples/integration/tool/css/master/_tooltip.scss +34 -0
  42. package/examples/integration/tool/css/master/home.scss +266 -0
  43. package/examples/integration/tool/css/master/style-login.scss +240 -0
  44. package/examples/integration/tool/css/master/style.scss +166 -0
  45. package/examples/integration/tool/img/doc-gallery-placeholder.svg +3 -0
  46. package/examples/integration/tool/img/home/ic_calendar-clock.svg +1 -0
  47. package/examples/integration/tool/img/home/ic_caret-down.svg +1 -0
  48. package/examples/integration/tool/img/home/ic_cog.svg +1 -0
  49. package/examples/integration/tool/img/home/ic_marker.svg +1 -0
  50. package/examples/integration/tool/img/home/ic_play-circle.svg +1 -0
  51. package/examples/integration/tool/img/home/ic_power.svg +1 -0
  52. package/examples/integration/tool/img/home/ic_squares.svg +1 -0
  53. package/examples/integration/tool/img/home/ic_user-pointer.svg +1 -0
  54. package/examples/integration/tool/img/home/ic_user-square.svg +1 -0
  55. package/examples/integration/tool/img/home/logo_footer.svg +1 -0
  56. package/examples/integration/tool/img/ic/accessControl.svg +1 -0
  57. package/examples/integration/tool/img/ic/account-location.svg +1 -0
  58. package/examples/integration/tool/img/ic/actionDelete.svg +64 -0
  59. package/examples/integration/tool/img/ic/actionOpen.svg +64 -0
  60. package/examples/integration/tool/img/ic/addFile.svg +100 -0
  61. package/examples/integration/tool/img/ic/addFile_off.svg +102 -0
  62. package/examples/integration/tool/img/ic/arrow-left.svg +1 -0
  63. package/examples/integration/tool/img/ic/arrow-right-drop-circle-outline.svg +1 -0
  64. package/examples/integration/tool/img/ic/bt_add_photo.svg +3 -0
  65. package/examples/integration/tool/img/ic/bug.svg +1 -0
  66. package/examples/integration/tool/img/ic/caret-down-bottomsheet.svg +3 -0
  67. package/examples/integration/tool/img/ic/checkbox-blank-outline-grey.svg +8 -0
  68. package/examples/integration/tool/img/ic/checkbox-blank-outline-white.svg +8 -0
  69. package/examples/integration/tool/img/ic/checkbox-blank-outline.svg +1 -0
  70. package/examples/integration/tool/img/ic/checkbox-marked-outline-grey.svg +8 -0
  71. package/examples/integration/tool/img/ic/checkbox-marked-outline-white.svg +8 -0
  72. package/examples/integration/tool/img/ic/checkbox-marked-outline.svg +1 -0
  73. package/examples/integration/tool/img/ic/chevron-down-grey.svg +7 -0
  74. package/examples/integration/tool/img/ic/chevron-down-white.svg +7 -0
  75. package/examples/integration/tool/img/ic/chevron-down.svg +1 -0
  76. package/examples/integration/tool/img/ic/chevron-right-grey.svg +7 -0
  77. package/examples/integration/tool/img/ic/chevron-right-white.svg +7 -0
  78. package/examples/integration/tool/img/ic/chevron-right.svg +1 -0
  79. package/examples/integration/tool/img/ic/comment-text-outline.svg +1 -0
  80. package/examples/integration/tool/img/ic/cookie.svg +1 -0
  81. package/examples/integration/tool/img/ic/delete.svg +1 -0
  82. package/examples/integration/tool/img/ic/dot.svg +1 -0
  83. package/examples/integration/tool/img/ic/dump.svg +1 -0
  84. package/examples/integration/tool/img/ic/e.svg +9 -0
  85. package/examples/integration/tool/img/ic/eye-off.svg +1 -0
  86. package/examples/integration/tool/img/ic/eye.svg +1 -0
  87. package/examples/integration/tool/img/ic/forbidden.svg +1 -0
  88. package/examples/integration/tool/img/ic/form-title-1.svg +3 -0
  89. package/examples/integration/tool/img/ic/group.svg +1 -0
  90. package/examples/integration/tool/img/ic/hamburger.svg +1 -0
  91. package/examples/integration/tool/img/ic/ic-users.svg +1 -0
  92. package/examples/integration/tool/img/ic/ic_dropdown-form-close.svg +3 -0
  93. package/examples/integration/tool/img/ic/ic_dropdown-form-link.svg +3 -0
  94. package/examples/integration/tool/img/ic/ic_feature-edit-cancel.svg +14 -0
  95. package/examples/integration/tool/img/ic/ic_feature-edit-save.svg +14 -0
  96. package/examples/integration/tool/img/ic/ic_gallery-item-delete.svg +3 -0
  97. package/examples/integration/tool/img/ic/ic_gallery-item-view.svg +3 -0
  98. package/examples/integration/tool/img/ic/ic_gps.svg +3 -0
  99. package/examples/integration/tool/img/ic/ic_search.svg +5 -0
  100. package/examples/integration/tool/img/ic/ic_selector_fechas.svg +63 -0
  101. package/examples/integration/tool/img/ic/ic_zoom-to-extent.svg +3 -0
  102. package/examples/integration/tool/img/ic/icon_reminder.png +0 -0
  103. package/examples/integration/tool/img/ic/image-gallery-placeholder.svg +55 -0
  104. package/examples/integration/tool/img/ic/imaqua.svg +87 -0
  105. package/examples/integration/tool/img/ic/incidencia.svg +77 -0
  106. package/examples/integration/tool/img/ic/info_multi_selection.svg +230 -0
  107. package/examples/integration/tool/img/ic/layers.svg +1 -0
  108. package/examples/integration/tool/img/ic/map-marker.svg +3 -0
  109. package/examples/integration/tool/img/ic/map.svg +1 -0
  110. package/examples/integration/tool/img/ic/measure_area.svg +111 -0
  111. package/examples/integration/tool/img/ic/minus.svg +7 -0
  112. package/examples/integration/tool/img/ic/notification.svg +1 -0
  113. package/examples/integration/tool/img/ic/offline.svg +3 -0
  114. package/examples/integration/tool/img/ic/online.svg +1 -0
  115. package/examples/integration/tool/img/ic/pencil.svg +3 -0
  116. package/examples/integration/tool/img/ic/plus.svg +1 -0
  117. package/examples/integration/tool/img/ic/polygon_selection.svg +68 -0
  118. package/examples/integration/tool/img/ic/power.svg +1 -0
  119. package/examples/integration/tool/img/ic/remoteLocalized.svg +4 -0
  120. package/examples/integration/tool/img/ic/remoteStartLocalize.svg +4 -0
  121. package/examples/integration/tool/img/ic/ruler.svg +125 -0
  122. package/examples/integration/tool/img/ic/selection-plus.svg +10 -0
  123. package/examples/integration/tool/img/ic/selection.svg +1 -0
  124. package/examples/integration/tool/img/ic/settings.svg +1 -0
  125. package/examples/integration/tool/img/ic/sort.svg +1 -0
  126. package/examples/integration/tool/img/ic/sort_asc.svg +1 -0
  127. package/examples/integration/tool/img/ic/sort_desc.svg +1 -0
  128. package/examples/integration/tool/img/ic/spreadsheet.svg +3 -0
  129. package/examples/integration/tool/img/ic/times.svg +1 -0
  130. package/examples/integration/tool/img/ic/toolbar/AB3.svg +1 -0
  131. package/examples/integration/tool/img/ic/toolbar/AB4.svg +1 -0
  132. package/examples/integration/tool/img/ic/toolbar/IC1.svg +1 -0
  133. package/examples/integration/tool/img/ic/toolbar/TB1.svg +1 -0
  134. package/examples/integration/tool/img/ic/toolbar/TB11.svg +5 -0
  135. package/examples/integration/tool/img/ic/toolbar/TB2.svg +1 -0
  136. package/examples/integration/tool/img/ic/toolbar/TB20.svg +1 -0
  137. package/examples/integration/tool/img/ic/toolbar/TB21.svg +54 -0
  138. package/examples/integration/tool/img/ic/toolbar/TB3.svg +1 -0
  139. package/examples/integration/tool/img/ic/toolbar/TB31.svg +1 -0
  140. package/examples/integration/tool/img/ic/toolbar/TB32.svg +57 -0
  141. package/examples/integration/tool/img/ic/toolbar/TB4.svg +1 -0
  142. package/examples/integration/tool/img/ic/toolbar/TB5.svg +1 -0
  143. package/examples/integration/tool/img/ic/toolbar/TB6.svg +1 -0
  144. package/examples/integration/tool/img/ic/toolbar/TB7.svg +1 -0
  145. package/examples/integration/tool/img/ic/toolbar/TB8.svg +1 -0
  146. package/examples/integration/tool/img/ic/tools.svg +28 -0
  147. package/examples/integration/tool/img/ic/user.svg +1 -0
  148. package/examples/integration/tool/img/ic/vector-polygon.svg +1 -0
  149. package/examples/integration/tool/img/ic/visit_manager.svg +135 -0
  150. package/examples/integration/tool/img/logo-footer-login.png +0 -0
  151. package/examples/integration/tool/img/logo-footer.png +0 -0
  152. package/examples/integration/tool/img/logo-header-login.png +0 -0
  153. package/examples/integration/tool/img/logo-header-login@2x.png +0 -0
  154. package/examples/integration/tool/img/logo-header-login@3x.png +0 -0
  155. package/examples/integration/tool/img/logo-header.png +0 -0
  156. package/examples/integration/tool/img/logo-header@2x.png +0 -0
  157. package/examples/integration/tool/img/logo-header@3x.png +0 -0
  158. package/examples/integration/tool/img/logo_project.png +0 -0
  159. package/examples/integration/tool/img/photo-gallery-placeholder.svg +3 -0
  160. package/examples/integration/tool/img/pixel.png +0 -0
  161. package/examples/integration/tool/index.html +228 -0
  162. package/examples/integration/tool/js/demo.js +238 -0
  163. package/examples/integration/tool/js/interface.js +147 -0
  164. package/examples/integration/tool/js/jquery.js +4 -0
  165. package/examples/integration/vanguardia.html +6636 -0
  166. package/examples/multipleIframes/index.js +82 -0
  167. package/examples/multipleIframes/index.php +52 -0
  168. package/examples/serverLess/dist/index.23420cfa.js +2973 -0
  169. package/examples/serverLess/dist/index.23420cfa.js.map +1 -0
  170. package/examples/serverLess/dist/index.91b6cacc.js +2 -0
  171. package/examples/serverLess/dist/index.91b6cacc.js.map +1 -0
  172. package/examples/serverLess/dist/index.html +1 -0
  173. package/examples/serverLess/index.html +39 -0
  174. package/examples/serverLess/main.js +113 -0
  175. package/examples/serverLess/package.json +18 -0
  176. package/examples/serverLess/readme.md +41 -0
  177. package/examples/simple/index.html +1 -1
  178. package/examples/simple/simple.js +63 -65
  179. package/examples/vidromap/index.js +20 -0
  180. package/examples/vidromap/index.php +48 -51
  181. package/flows.md +73 -0
  182. package/package.json +2 -2
  183. package/src/index.js +156 -42
  184. package/src/shared/iframe-communicator.js +12 -5
  185. package/examples/vidromap/vidromap.js +0 -87
@@ -0,0 +1,113 @@
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
+ };
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,41 @@
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/`
@@ -12,7 +12,7 @@
12
12
  <br>https://www.vidrosoftware.com/examples/simple/?user=user&pwd=pwd&api=API URL
13
13
  </div>
14
14
  <div id="iframes-container">
15
- <iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" ></iframe>
15
+ <iframe id="map-frame" name="map-frame" src="http://localhost:3000/?sessionToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2NDE5ODcyOTEsImF1ZCI6IjUyNmY5ODMyZDIxYWI0ZDI4ZjU0M2MxZWM1NzYxYTc0MjE3YjFiMDkiLCJkYXRhIjp7Inpvb20iOjE0LCJiYWNrZ3JvdW5kIjoiQ2FydG9EQkxpZ2h0Iiwic3JpZCI6bnVsbCwiZXh0ZW50IjpudWxsLCJnZW9zZXJ2aWNlIjoiUUdJUyIsIm5hbWUiOiJ0ZXN0ZmlsZSIsInByZXZpZXciOnRydWUsImFwaSI6Imh0dHBzOlwvXC9hcGkudmlkcm9zb2Z0d2FyZS5jb21cLyIsInR5cGUiOiJ2aWRyb21hcCIsInRva2VuIjoiMjNhYzNjMmY1YTEzYTY1NmVkNDBhYjU3N2E3YmU4Y2QiLCJzaG93X2xheWVycyI6ImxpbmVzIiwiaWQiOjYsImxvZ28iOiJodHRwczpcL1wvd3d3LnZpZHJvc29mdHdhcmUuY29tXC9sb2dvc1wvVklEUk8uc3ZnIn19.VlK69JRMTdHskUuYMT86sH_8adKZdwZHpOu3I1EzU-RQcVGaNIA-dwgqEPQG9qVXJNNWVlYA3YkPk7S0g4XpwHvdOZLqKO8a5Iwx9gYCPOAemGnNc3pQzf_OtBv8h2OuBZDRPeZEzB7PJ7WgRqvXJG6SsNWzaU8TXrMjs2aYiaS7ztSMIORT0jzwq1ssjl1lTwWdNOz_hgZVwcJNbBb1-aSTIV8SD3miru4iujokVDCLj8IhM_chb6RipegZb_lQc6AEm6vcxDBBIlpIXuJq-cot05w_eY6LuL9HPsah1ifxWGSQ8HM_-QLzna7eMEb9KzMHGmx0EIpO5bRBy358QLXkesxpxjLMe2BhRef-j7UlFojptVhsvZKCdE6-KCmzz52WH5d9xgFxlfypQopx3jPeMqZmIRdGQSaedKIgvnj8T_hiltG08KItM5LatVC-9L1XnDpffRlHIc96IOmYzWpDcbIltK6k4NudohV49liWBP0sv-d51TGSNePGnyXZS4rdNAouo-sI5V2fvtTn3nOfmMqMmlXEc41m43tE_ULIo9R1S0SIg7taPEc3vImzRNL6lcAhLjT0TIQZrQXBpiL_Ml8SRhPm7PWdw-VEIFhl3aZFA5e-BpK3A4fb_pn-Ooc1Dg0hVBnteX5COAcZJkYHqYhKBhKP23UaWoLG3l0" style="width:100%; height:600px;" ></iframe>
16
16
  </div>
17
17
  <button id="btZoomIn">Zoom In</button>
18
18
  <button id="btZoomOut">Zoom Out</button>
@@ -4,79 +4,77 @@ var usertoken = null;
4
4
  var sessionToken = null;
5
5
  var iframe = document.querySelector("#map-frame");
6
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');
7
+ const user = urlParams.get("user");
8
+ const pwd = urlParams.get("pwd");
9
+ const apiUrl = urlParams.get("api");
10
10
 
11
11
  //************** Simple example
12
12
 
13
- function loadMap(){
13
+ function loadMap() {
14
+ //************************************************
15
+ //************************************************
16
+ //************* **************
17
+ //************* 1. Get user token **************
18
+ //************* **************
19
+ //************************************************
20
+ //************************************************
14
21
 
15
- //************************************************
16
- //************************************************
17
- //************* **************
18
- //************* 1. Get user token **************
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 };
22
35
 
23
- var data = { 'user': user, 'pwd': pwd }
24
- //Build XMLHttpRequest to API
25
- var oReq = new XMLHttpRequest();
26
- oReq.open("POST", `${apiUrl}letsgo`,true);
27
- oReq.setRequestHeader('Content-type', 'application/json');
28
- oReq.send(JSON.stringify(data));
29
- console.log("Attempt to get user token",`${apiUrl}letsgo`,data);
30
- oReq.addEventListener("load", function(){
31
- console.log("Get user token response",this.responseText);
32
- var res = JSON.parse(this.responseText);
33
- //store token
34
- usertoken = res.message.token;
35
- var dataForMap = { 'token': usertoken }
36
-
37
- //************************************************
38
- //************************************************
39
- //************* **************
40
- //************* 2. Get MAP **************
41
- //************* **************
42
- //************************************************
43
- //************************************************
36
+ //************************************************
37
+ //************************************************
38
+ //************* **************
39
+ //************* 2. Get MAP **************
40
+ //************* **************
41
+ //************************************************
42
+ //************************************************
44
43
 
45
- //Build XMLHttpRequest to API
46
- var uri = `${apiUrl}map/${res.message.projects[0]}?token=${usertoken}`
47
- var loadMapReq = new XMLHttpRequest();
48
- loadMapReq.addEventListener("load", function(){
49
- console.log("Map response",this.responseText);
50
- var res = JSON.parse(this.responseText);
51
- sessionToken = res.message.sessionToken;
52
-
53
- //start JS Communicator
54
- communicator = new VidroMaps.Communicator({sessionToken});
55
-
56
- //Load iframne
57
- iframe.src = `${res.message.iframe}?sessionToken=${sessionToken}`;
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;
58
51
 
59
- // Map events
60
- communicator.on("onZoomChange", function(data){
61
- console.log("communicator->onZoomChange",data);
62
- });
52
+ //start JS Communicator
53
+ communicator = new VidroMaps.Communicator({ sessionToken });
63
54
 
64
- // Map Actions
65
- btZoomIn.addEventListener("click", function(){
66
- communicator.ZoomIn();
67
- });
55
+ //Load iframe
56
+ iframe.src = `${res.message.iframe}?sessionToken=${sessionToken}`;
68
57
 
69
- btZoomOut.addEventListener("click", function(){
70
- communicator.ZoomOut();
71
- });
72
- btZoomToExtent.addEventListener("click", function(){
73
- communicator.zoomToExtent();
74
- });
58
+ // Map events
59
+ communicator.on("onZoomChange", function (data) {
60
+ console.log("communicator->onZoomChange", data);
61
+ });
75
62
 
63
+ // Map Actions
64
+ btZoomIn.addEventListener("click", function () {
65
+ communicator.ZoomIn();
66
+ });
76
67
 
77
- });
78
- loadMapReq.open("GET", uri,true);
79
- loadMapReq.setRequestHeader('Content-type', 'application/json');
80
- loadMapReq.send(JSON.stringify(dataForMap));
81
- });
82
- };
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
+ }
@@ -0,0 +1,20 @@
1
+
2
+ var sessionToken = document.querySelector("#sessionToken");
3
+ var mapContainer = document.querySelector("#mapContainer");
4
+ var codeContent = document.querySelector("#code");
5
+ var iframesContainer = document.querySelector("#iframes-container");
6
+
7
+ var iframe = document.querySelector("#map-frame");
8
+ var host = document.querySelector("#overrideHost");
9
+ var btLoadIframe = document.querySelector("#btLoadIframe");
10
+
11
+
12
+ //************** MAP EXAMPLE
13
+
14
+ if(btLoadIframe){
15
+ btLoadIframe.addEventListener("click", function (evt) {
16
+ if(codeContent.value!=""){
17
+ iframesContainer.innerHTML = codeContent.value;
18
+ }
19
+ });
20
+ }
@@ -6,77 +6,65 @@
6
6
  <link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
7
7
  </head>
8
8
  <body>
9
- <div class="form">
10
- <div>
11
- Api URL <input type="text" name="apiurl" id="apiurl" value="http://localhost" size="30">
12
- </div>
13
- </div>
9
+
14
10
 
15
11
 
16
12
  <div class="form" id="userData">
17
- <h1>Map Properties</h1>
13
+ <h1>Vidromap</h1>
18
14
 
15
+ <div id="sessionToken"></div>
19
16
  <div>
20
- Zoom: <input type="text" name="zoom" id="zoom" size="5" value="">
21
- </div>
22
- <div>
23
- Custom logo: <input type="text" name="logo" id="logo" size="25" value="">
24
- </div>
25
- <div>
26
- Name: <input type="text" name="name" id="name" size="25" value="opentest">
27
- </div>
28
- <div>
29
- Srid: <input type="text" name="srid" id="srid" size="18" placeholder="EPSG:4326" value="EPSG:25831">
30
- </div>
31
- <div>
32
- Geo server: <input type="text" name="geoserver" id="geoserver" size="54" value=""placeholder="https://nv.napr.gov.ge/geoserver/wms"> <small>Geo server url</small>
33
- </div>
34
- <div>
35
- Show Layers: <input type="text" name="show_layers" id="show_layers" size="25" value="" placeholder="NG_REG_LAYER"> <small>Show layers on map load</small>
36
- </div>
37
- <div>
38
- Geo server data: <textarea name="geoserverdata" id="geoserverdata" rows="4" cols="50" placeholder="">{"options": {"params":{"LAYERS": "NG_REG_LAYER","FORMAT" : "image/png"},"srid" : "EPSG:4326","type" : "WMS"}}</textarea>
17
+ Paste your code here:<br> <textarea name="code" id="code" rows="10" cols="100" placeholder=""><iframe id="map-frame" name="map-frame" width="100%" height="600" src="http://localhost:3000/?sessionToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2NDMxMjM5MTcsImF1ZCI6ImVjNWI4ZDI5OWM1NjVlZjUxYmQxZmU4MzY1OGE5NTgwNDk0MDZkMjMiLCJkYXRhIjp7Inpvb20iOjE0LCJiYWNrZ3JvdW5kIjoiQ2FydG9EQkxpZ2h0Iiwic3JpZCI6bnVsbCwiZXh0ZW50IjpudWxsLCJnZW9zZXJ2aWNlIjoiUUdJUyIsIm5hbWUiOiJ0ZXN0ZmlsZSIsInByZXZpZXciOnRydWUsImFwaSI6Imh0dHBzOlwvXC9hcGkudmlkcm9zb2Z0d2FyZS5jb21cLyIsInR5cGUiOiJ2aWRyb21hcCIsInRva2VuIjoiNmJiNTM2MjY1NWU3MzdlNjY2YzY5OGU2ZmI1ZjA5YzQiLCJzaG93X2xheWVycyI6ImxpbmVzIiwiaWQiOjYsImxvZ28iOiJodHRwczpcL1wvd3d3LnZpZHJvc29mdHdhcmUuY29tXC9sb2dvc1wvVklEUk8uc3ZnIn19.Ocv0JUFhVHRep6-bkEt0AJ9KnmXcSVc9khMzS1d3Sb33n5jAXvgt2nAjh4CckUSkJUsekuQqk6Y0ZdiWIyOp780U3S5JK962PivB00tXB_05YHPyfU5XPrVbDWTMUcww9Qg9kYdTZsTjede3cOfjbGlU_opg2igL1hlKqkbeqBY2vAfhHF_zNa2EShcEIke21AIpuAo6h-FJXzkCRSQbGtnqEhJCXWT0LNQCns5Rc1q5fKpg98iaEUFFZRu3rM58s0UTK5sUu6LAXXbRWXDw3Q4jkCuGrV58QPeqVHjJQOo70hDWvV33HFJSSJZP2TkhWapPZqw7UxhPipo4K7p9WnFBmGWQqrhQ5yiQZY92E4Y8cwAsUvLbuJwBO-jZAsk4kNI8uK9L6Uy5JvEw6G-Ce8HUbEF3E-nYQKHzKtqOpLpsgo1PNFIV7PcWlQPhFZnOtSBjhH-DCKX9QzgiKu4n9L7uKUE_7YvxeJ8Zs-Oi0QoxBPa1GJ0KYGJg4VHBPuVRSfq9Plwtv8uWG-etJQjQYCDNM6z6oWjw9m1CzS67kFp49p3ek46MdlI86URGTUDX7u4bjuvCdYZdOxYGdw6XkCMdyeIxFXX2CUOQZPeFtc3wGZbHI7-WFqkkbnBJ2fDWQfOpcUncEeCSiKuvgI9pykhCXnP7TKA0DFHCJmcDuzo"></iframe>
18
+
19
+ </textarea>
39
20
  </div>
40
21
  <div>
41
- Override Capabitilites extent: <input type="text" name="extent" id="extent" size="55" value="417309, 4576150, 420550, 4578120" placeholder="397663,4615771,406392,4623596"> <small>Override project extent</small>
42
- </div>
43
- <div>
44
- Override iframe url: <input type="text" name="overrideHost" id="overrideHost" size="25" value="">
45
- </div>
46
-
47
- <div>
48
- Background: <input type="text" name="Background" id="Background" size="25" value="">
49
- </div>
50
-
51
-
52
- <div>
53
22
  Debug
23
+ <button id="btDebug">Debug</button>
54
24
  <select id="debug">
55
- <option id="1" value=1>True</option>
56
- <option id="0" selected value=0>False</option>
57
- </select>
58
- </div>
59
- <div>
60
- <button id="btLoadMap">Load Map</button>
25
+ <option id="1" selected value=1>Show logs</option>
26
+ <option id="0" value=0>Hide logs</option>
27
+ </select> <small>Show/hide component logs</small>
61
28
  </div>
62
29
  </div>
30
+ <div>
31
+ <button id="btLoadIframe">Load Map</button> -
32
+ <button id="btLoadWMSLayers">Load layers from wms</button>
33
+ </div>
63
34
  <div id="Error_container"></div>
64
- <div id="mapContainer" class="hide">
35
+ <div id="mapContainer">
65
36
 
66
- <div id="sessionToken"></div>
67
37
  <div id="iframes-container">
68
- <iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" allow="geolocation"></iframe>
38
+
69
39
  </div>
70
40
  <hr />
71
41
  <pre id="Result_container"></pre>
72
42
  <hr/>
43
+ <h2>Custom colors</h2>
44
+ Geom fill color: <input type="text" name="geom_fill_color" id="geom_fill_color" size="12" value="rgba(252,0,0,0.37)"><br><br>
45
+ Geom stroke color: <input type="text" name="geom_stroke_color" id="geom_stroke_color" size="12" value="rgba(252,0,0,0.37)"><br><br>
46
+ Geom stroke width: <input type="text" name="geom_stroke_width" id="geom_stroke_width" size="4" value="1"><br><br>
47
+ Geom shape for points - circle/square: <select id="geom_shape">
48
+ <option id="circle" selected value="circle">Circle</option>
49
+ <option id="square" value="square">Square</option>
50
+ </select><br><br>
51
+ Point radius: <input type="text" name="geom_radius" id="geom_radius" size="4" value="4"><br><br>
52
+ <button id="btSetColors">Set colors</button> <br><br>
53
+
73
54
  <h2>Zoom</h2>
74
55
  <button id="btZoomIn">Zoom In</button>
75
56
  <button id="btZoomOut">Zoom Out</button>
76
57
  <button id="btZoomToExtent">Zoom to extent</button>
58
+ <br><br>
59
+ <button id="btZoomToCoordinates">Zoom to coordinates</button>
60
+ ZoomToCoordinates level: <input type="text" name="zoomLevelToCoordinates" id="zoomLevelToCoordinates" size="5" value="4">
61
+ <h2>Add geometry</h2>
62
+ <button id="btAddPoint">Add point</button>
63
+ <button id="btAddPolygon">Add polygon</button>
64
+ <button id="btAddLine">Add line</button>
65
+ <button id="btClear">Clear geometries</button>
77
66
  <h2>Info</h2>
78
67
  <button id="btWMSInfo" disabled="true">WMS Info</button>
79
- <button id="btGiswaterInfo">Giswater Info</button>
80
68
  <h2>Layers</h2>
81
69
  Project Layers: <select id="projectlayers"></select> - <small>click on "Load Project Layers button</small> <button id="btToggleLayer">Add / Remove Layer</button><br><br>
82
70
  Displayed Layers: <select id="layers"></select> -
@@ -84,18 +72,27 @@
84
72
  <button id="btGetActiveLayer">Get Active Layer</button>
85
73
  <span id="currentActiveLayer"></span>
86
74
 
75
+ <h2>Geolocation</h2>
76
+ <button id="btGeolocalize">Geolocalize User</button>
77
+ <button id="btStopGeolocalize">Cancel Geolocalize</button>
87
78
 
79
+ <h2>Highlight</h2>
80
+ <button id="btHighlight">Highlight geom</button>
81
+ Geom: <input type="text" name="geom" id="geom" size="25" value="">
82
+ <br>
83
+ 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="">
88
84
  <h2>GeoJSON</h2>
89
-
90
85
  <input type="file" id="geojsonfile" name="geojsonfile" accept="application/json"><small> Select geoJSON file</small><br><br>
91
86
  <small>Or paste geoJSON content</small><br><br>
92
87
  <textarea name="geojsondata" id="geojsondata" rows="10" cols="80" placeholder=""></textarea> <br><br>
88
+
89
+
93
90
  <button id="btAddGeoJSON">Add GeoJSON </button><br><br>
91
+
94
92
  </div>
95
93
 
96
- <!--<script src="https://unpkg.com/@vidro/map-handler@1.0.1/dist/map-handler.js"></script>-->
97
- <script src="../../dist/map-handler.js"></script>
94
+ <script src="https://unpkg.com/@vidro/map-handler@1.0.8/dist/map-handler.js"></script>
98
95
  <script src="../full/tester.js"></script>
99
- <script src="./vidromap.js"></script>
96
+ <script src="./index.js"></script>
100
97
  </body>
101
98
  </html>
package/flows.md ADDED
@@ -0,0 +1,73 @@
1
+ # Map Handler flows
2
+
3
+ This document defines use case flows of map handler
4
+
5
+ ## Vidromaps basic flow
6
+
7
+ Vidromaps basic flow
8
+
9
+ 1. Login to giswater - API `letsgo`
10
+ 2. Get map - API `map/{project_id}`
11
+ 3. Load iframe
12
+
13
+ ![](doc/vidromaps-basic.png)
14
+
15
+ ## Giswater basic flow
16
+
17
+ Giswater basic flow
18
+
19
+ 1. Login to giswater - API `letsgo`
20
+ 2. Get map - API `map/{project_id}`
21
+ 3. Load iframe
22
+
23
+
24
+ ![](doc/giswater.png)
25
+
26
+ ## Giswater info
27
+
28
+ Giswater info can be performed using mapHandler or usind API REST methods
29
+
30
+ 1. Login to giswater - API `letsgo`
31
+ 2. Get map - API `map/{project_id}`
32
+ 3. Load iframe
33
+ 4. Instance mapHandler - `new VidroMaps.Communicator({sessionToken});`
34
+ 5. Click on map
35
+
36
+ **Using mapHandler**
37
+
38
+ 6. Info`mapHandler.js` method [**`infofromcoordinates `**](https://github.com/Vidro-Software-SL/maphandler#infofromcoordinates)
39
+ ![](doc/giswaterInfo.png)
40
+
41
+ **Using API REST**
42
+
43
+ 6. Listen event [**`coordinates`**](https://github.com/Vidro-Software-SL/maphandler#coordinates)
44
+ 7. POST to API `giswater/info` with x, y, srid and device parameters.
45
+
46
+ ![](doc/giswaterInfoApi.png)
47
+
48
+
49
+ ## Giswater display layer
50
+
51
+ Display a Giswater layer using mapHandler
52
+
53
+ 1. Login to giswater - API `letsgo`
54
+ 2. Get map - API `map/{project_id}`
55
+ 3. Load iframe
56
+ 4. Instance mapHandler - `new VidroMaps.Communicator({sessionToken});`
57
+ 5. Render layer using `mapHandler.js` method [**`toggleLayer`**](https://github.com/Vidro-Software-SL/maphandler#togglelayer)
58
+
59
+ ![](doc/togglelayergiswater.png)
60
+
61
+ ## Giswater JSON layer
62
+
63
+ Giswater layers can be rendered as geojson.
64
+
65
+ 1. Login to giswater - API `letsgo`
66
+ 2. Get map - API `map/{project_id}`
67
+ 3. Load iframe
68
+ 4. Get geojson data for a layer - API `giswater/geojson/{project_id}/{layer_name}`.
69
+ 5. Instance mapHandler - `new VidroMaps.Communicator({sessionToken});`
70
+ 6. Render geojson data using `maphandler.js` method [**`addGeoJSON`**](https://github.com/Vidro-Software-SL/maphandler#addgeojson)
71
+ ![](doc/giswatergeojson.png)
72
+
73
+
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@vidro/map-handler",
3
- "version": "1.0.4",
3
+ "version": "1.0.8",
4
4
  "description": "Tool to achieve the easiest way of communication with the map",
5
5
  "homepage": "https://github.com/Vidro-Software-SL/maphandler",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/Vidro-Software-SL/maphandler.git"
9
9
  },
10
- "main": "dist/vidro-map-handler.js",
10
+ "main": "dist/map-handler.js",
11
11
  "scripts": {
12
12
  "build": "webpack"
13
13
  },