@vidro/map-handler 1.1.4 → 1.1.16

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 (170) hide show
  1. package/README.md +39 -101
  2. package/dist/map-handler.js +1 -1
  3. package/examples/full/cachedToken.dat +1 -1
  4. package/examples/full/cachedTokenData.dat +1 -1
  5. package/examples/full/index.php +9 -78
  6. package/examples/full/tester.js +12 -177
  7. package/examples/serverLess/dist/index.23420cfa.js +117 -120
  8. package/examples/serverLess/dist/index.23420cfa.js.map +1 -1
  9. package/examples/serverLess/dist/index.html +1 -38
  10. package/examples/serverLess/index.html +1 -2
  11. package/examples/serverLess/main.js +2 -2
  12. package/examples/simple/index.html +1 -1
  13. package/examples/taigua/index.html +46 -8
  14. package/examples/taigua/main.js +467 -18
  15. package/examples/vidromap/index.php +1 -1
  16. package/package.json +1 -1
  17. package/src/index.js +180 -321
  18. package/examples/externalwms/index.js +0 -20
  19. package/examples/externalwms/index.php +0 -88
  20. package/examples/integration/tool/css/dist/home.css.min.css +0 -0
  21. package/examples/integration/tool/css/dist/home.min.css +0 -1
  22. package/examples/integration/tool/css/dist/home.min.css.map +0 -10
  23. package/examples/integration/tool/css/dist/style-login.css.min.css +0 -0
  24. package/examples/integration/tool/css/dist/style-login.min.css +0 -1
  25. package/examples/integration/tool/css/dist/style-login.min.css.map +0 -10
  26. package/examples/integration/tool/css/dist/style.css.min.css +0 -0
  27. package/examples/integration/tool/css/dist/style.min.css +0 -1
  28. package/examples/integration/tool/css/dist/style.min.css.map +0 -23
  29. package/examples/integration/tool/css/master/_bottom-sheet-2.scss +0 -103
  30. package/examples/integration/tool/css/master/_bottom-sheet.scss +0 -142
  31. package/examples/integration/tool/css/master/_colors.scss +0 -35
  32. package/examples/integration/tool/css/master/_dropdown-form.scss +0 -167
  33. package/examples/integration/tool/css/master/_forms.scss +0 -416
  34. package/examples/integration/tool/css/master/_header.scss +0 -134
  35. package/examples/integration/tool/css/master/_menu-toc.scss +0 -135
  36. package/examples/integration/tool/css/master/_menu-tools.scss +0 -187
  37. package/examples/integration/tool/css/master/_mixins.scss +0 -42
  38. package/examples/integration/tool/css/master/_notifyjs.scss +0 -39
  39. package/examples/integration/tool/css/master/_ol-map-controls.scss +0 -117
  40. package/examples/integration/tool/css/master/_simplelightbox.scss +0 -287
  41. package/examples/integration/tool/css/master/_toc-config.scss +0 -28
  42. package/examples/integration/tool/css/master/_toc-layouts.scss +0 -173
  43. package/examples/integration/tool/css/master/_tooltip.scss +0 -34
  44. package/examples/integration/tool/css/master/home.scss +0 -266
  45. package/examples/integration/tool/css/master/style-login.scss +0 -240
  46. package/examples/integration/tool/css/master/style.scss +0 -166
  47. package/examples/integration/tool/img/doc-gallery-placeholder.svg +0 -3
  48. package/examples/integration/tool/img/home/ic_calendar-clock.svg +0 -1
  49. package/examples/integration/tool/img/home/ic_caret-down.svg +0 -1
  50. package/examples/integration/tool/img/home/ic_cog.svg +0 -1
  51. package/examples/integration/tool/img/home/ic_marker.svg +0 -1
  52. package/examples/integration/tool/img/home/ic_play-circle.svg +0 -1
  53. package/examples/integration/tool/img/home/ic_power.svg +0 -1
  54. package/examples/integration/tool/img/home/ic_squares.svg +0 -1
  55. package/examples/integration/tool/img/home/ic_user-pointer.svg +0 -1
  56. package/examples/integration/tool/img/home/ic_user-square.svg +0 -1
  57. package/examples/integration/tool/img/home/logo_footer.svg +0 -1
  58. package/examples/integration/tool/img/ic/accessControl.svg +0 -1
  59. package/examples/integration/tool/img/ic/account-location.svg +0 -1
  60. package/examples/integration/tool/img/ic/actionDelete.svg +0 -64
  61. package/examples/integration/tool/img/ic/actionOpen.svg +0 -64
  62. package/examples/integration/tool/img/ic/addFile.svg +0 -100
  63. package/examples/integration/tool/img/ic/addFile_off.svg +0 -102
  64. package/examples/integration/tool/img/ic/arrow-left.svg +0 -1
  65. package/examples/integration/tool/img/ic/arrow-right-drop-circle-outline.svg +0 -1
  66. package/examples/integration/tool/img/ic/bt_add_photo.svg +0 -3
  67. package/examples/integration/tool/img/ic/bug.svg +0 -1
  68. package/examples/integration/tool/img/ic/caret-down-bottomsheet.svg +0 -3
  69. package/examples/integration/tool/img/ic/checkbox-blank-outline-grey.svg +0 -8
  70. package/examples/integration/tool/img/ic/checkbox-blank-outline-white.svg +0 -8
  71. package/examples/integration/tool/img/ic/checkbox-blank-outline.svg +0 -1
  72. package/examples/integration/tool/img/ic/checkbox-marked-outline-grey.svg +0 -8
  73. package/examples/integration/tool/img/ic/checkbox-marked-outline-white.svg +0 -8
  74. package/examples/integration/tool/img/ic/checkbox-marked-outline.svg +0 -1
  75. package/examples/integration/tool/img/ic/chevron-down-grey.svg +0 -7
  76. package/examples/integration/tool/img/ic/chevron-down-white.svg +0 -7
  77. package/examples/integration/tool/img/ic/chevron-down.svg +0 -1
  78. package/examples/integration/tool/img/ic/chevron-right-grey.svg +0 -7
  79. package/examples/integration/tool/img/ic/chevron-right-white.svg +0 -7
  80. package/examples/integration/tool/img/ic/chevron-right.svg +0 -1
  81. package/examples/integration/tool/img/ic/comment-text-outline.svg +0 -1
  82. package/examples/integration/tool/img/ic/cookie.svg +0 -1
  83. package/examples/integration/tool/img/ic/delete.svg +0 -1
  84. package/examples/integration/tool/img/ic/dot.svg +0 -1
  85. package/examples/integration/tool/img/ic/dump.svg +0 -1
  86. package/examples/integration/tool/img/ic/e.svg +0 -9
  87. package/examples/integration/tool/img/ic/eye-off.svg +0 -1
  88. package/examples/integration/tool/img/ic/eye.svg +0 -1
  89. package/examples/integration/tool/img/ic/forbidden.svg +0 -1
  90. package/examples/integration/tool/img/ic/form-title-1.svg +0 -3
  91. package/examples/integration/tool/img/ic/group.svg +0 -1
  92. package/examples/integration/tool/img/ic/hamburger.svg +0 -1
  93. package/examples/integration/tool/img/ic/ic-users.svg +0 -1
  94. package/examples/integration/tool/img/ic/ic_dropdown-form-close.svg +0 -3
  95. package/examples/integration/tool/img/ic/ic_dropdown-form-link.svg +0 -3
  96. package/examples/integration/tool/img/ic/ic_feature-edit-cancel.svg +0 -14
  97. package/examples/integration/tool/img/ic/ic_feature-edit-save.svg +0 -14
  98. package/examples/integration/tool/img/ic/ic_gallery-item-delete.svg +0 -3
  99. package/examples/integration/tool/img/ic/ic_gallery-item-view.svg +0 -3
  100. package/examples/integration/tool/img/ic/ic_gps.svg +0 -3
  101. package/examples/integration/tool/img/ic/ic_search.svg +0 -5
  102. package/examples/integration/tool/img/ic/ic_selector_fechas.svg +0 -63
  103. package/examples/integration/tool/img/ic/ic_zoom-to-extent.svg +0 -3
  104. package/examples/integration/tool/img/ic/icon_reminder.png +0 -0
  105. package/examples/integration/tool/img/ic/image-gallery-placeholder.svg +0 -55
  106. package/examples/integration/tool/img/ic/imaqua.svg +0 -87
  107. package/examples/integration/tool/img/ic/incidencia.svg +0 -77
  108. package/examples/integration/tool/img/ic/info_multi_selection.svg +0 -230
  109. package/examples/integration/tool/img/ic/layers.svg +0 -1
  110. package/examples/integration/tool/img/ic/map-marker.svg +0 -3
  111. package/examples/integration/tool/img/ic/map.svg +0 -1
  112. package/examples/integration/tool/img/ic/measure_area.svg +0 -111
  113. package/examples/integration/tool/img/ic/minus.svg +0 -7
  114. package/examples/integration/tool/img/ic/notification.svg +0 -1
  115. package/examples/integration/tool/img/ic/offline.svg +0 -3
  116. package/examples/integration/tool/img/ic/online.svg +0 -1
  117. package/examples/integration/tool/img/ic/pencil.svg +0 -3
  118. package/examples/integration/tool/img/ic/plus.svg +0 -1
  119. package/examples/integration/tool/img/ic/polygon_selection.svg +0 -68
  120. package/examples/integration/tool/img/ic/power.svg +0 -1
  121. package/examples/integration/tool/img/ic/remoteLocalized.svg +0 -4
  122. package/examples/integration/tool/img/ic/remoteStartLocalize.svg +0 -4
  123. package/examples/integration/tool/img/ic/ruler.svg +0 -125
  124. package/examples/integration/tool/img/ic/selection-plus.svg +0 -10
  125. package/examples/integration/tool/img/ic/selection.svg +0 -1
  126. package/examples/integration/tool/img/ic/settings.svg +0 -1
  127. package/examples/integration/tool/img/ic/sort.svg +0 -1
  128. package/examples/integration/tool/img/ic/sort_asc.svg +0 -1
  129. package/examples/integration/tool/img/ic/sort_desc.svg +0 -1
  130. package/examples/integration/tool/img/ic/spreadsheet.svg +0 -3
  131. package/examples/integration/tool/img/ic/times.svg +0 -1
  132. package/examples/integration/tool/img/ic/toolbar/AB3.svg +0 -1
  133. package/examples/integration/tool/img/ic/toolbar/AB4.svg +0 -1
  134. package/examples/integration/tool/img/ic/toolbar/IC1.svg +0 -1
  135. package/examples/integration/tool/img/ic/toolbar/TB1.svg +0 -1
  136. package/examples/integration/tool/img/ic/toolbar/TB11.svg +0 -5
  137. package/examples/integration/tool/img/ic/toolbar/TB2.svg +0 -1
  138. package/examples/integration/tool/img/ic/toolbar/TB20.svg +0 -1
  139. package/examples/integration/tool/img/ic/toolbar/TB21.svg +0 -54
  140. package/examples/integration/tool/img/ic/toolbar/TB3.svg +0 -1
  141. package/examples/integration/tool/img/ic/toolbar/TB31.svg +0 -1
  142. package/examples/integration/tool/img/ic/toolbar/TB32.svg +0 -57
  143. package/examples/integration/tool/img/ic/toolbar/TB4.svg +0 -1
  144. package/examples/integration/tool/img/ic/toolbar/TB5.svg +0 -1
  145. package/examples/integration/tool/img/ic/toolbar/TB6.svg +0 -1
  146. package/examples/integration/tool/img/ic/toolbar/TB7.svg +0 -1
  147. package/examples/integration/tool/img/ic/toolbar/TB8.svg +0 -1
  148. package/examples/integration/tool/img/ic/tools.svg +0 -28
  149. package/examples/integration/tool/img/ic/user.svg +0 -1
  150. package/examples/integration/tool/img/ic/vector-polygon.svg +0 -1
  151. package/examples/integration/tool/img/ic/visit_manager.svg +0 -135
  152. package/examples/integration/tool/img/logo-footer-login.png +0 -0
  153. package/examples/integration/tool/img/logo-footer.png +0 -0
  154. package/examples/integration/tool/img/logo-header-login.png +0 -0
  155. package/examples/integration/tool/img/logo-header-login@2x.png +0 -0
  156. package/examples/integration/tool/img/logo-header-login@3x.png +0 -0
  157. package/examples/integration/tool/img/logo-header.png +0 -0
  158. package/examples/integration/tool/img/logo-header@2x.png +0 -0
  159. package/examples/integration/tool/img/logo-header@3x.png +0 -0
  160. package/examples/integration/tool/img/logo_project.png +0 -0
  161. package/examples/integration/tool/img/photo-gallery-placeholder.svg +0 -3
  162. package/examples/integration/tool/img/pixel.png +0 -0
  163. package/examples/integration/tool/index.html +0 -228
  164. package/examples/integration/tool/js/demo.js +0 -238
  165. package/examples/integration/tool/js/interface.js +0 -147
  166. package/examples/integration/tool/js/jquery.js +0 -4
  167. package/examples/integration/vanguardia.html +0 -6636
  168. package/examples/taigua/global.css +0 -10
  169. package/examples/xavi/index.html +0 -37
  170. package/examples/xavi/main.js +0 -168
package/src/index.js CHANGED
@@ -1,220 +1,148 @@
1
- import { EventEmitter } from "events";
1
+ import { EventEmitter } from "events"
2
2
  import { iframeCommunicator } from "./shared/iframe-communicator";
3
3
  class Communicator extends EventEmitter {
4
- constructor(data) {
4
+
5
+ constructor(data){
5
6
  super();
6
- this.domId = "map-frame";
7
- if (typeof window === "undefined") {
7
+ this.domId = 'map-frame';
8
+ if(typeof window === 'undefined'){
8
9
  return;
9
- }
10
- if (typeof data.id === "string") {
10
+ };
11
+ if(typeof data.id==="string"){
11
12
  this.domId = data.id;
12
- }
13
- this.com = new iframeCommunicator(data);
14
- window.addEventListener("message", (e) => this.onMessageReceived(e));
13
+ }
14
+ this.com = new iframeCommunicator(data)
15
+ window.addEventListener("message", e => this.onMessageReceived(e));
15
16
  this.sessionToken = data.sessionToken;
16
- this.setMaxListeners(100);
17
17
  }
18
18
 
19
- onMessageReceived = (e) => {
20
- switch (e.data.type) {
21
- case "onZoomChange":
22
- this.emitEvent("onZoomChange", e.data, e.data.domId);
23
- break;
24
- case "onCenterChange":
25
- this.emitEvent("onCenterChange", e.data, e.data.domId);
26
- break;
27
- case "geomAdded":
28
- this.emitEvent("geomAdded", e.data, e.data.domId);
29
- break;
30
- case "layers":
31
- this.emitEvent("layers", e.data, e.data.domId);
32
- break;
33
- case "geoJSONlayers":
34
- this.emitEvent("geoJSONlayers", e.data, e.data.domId);
35
- break;
36
- case "info":
37
- this.emitEvent("info", e.data, e.data.domId);
38
- break;
39
- case "error":
40
- this.emitEvent("error", e.data, e.data.domId);
41
- break;
42
- case "coordinates":
43
- this.emitEvent("coordinates", e.data, e.data.domId);
44
- break;
45
- case "activeLayer":
46
- this.emitEvent("activeLayer", e.data, e.data.domId);
47
- break;
48
- case "geolocation":
49
- this.emitEvent("geolocation", e.data, e.data.domId);
50
- break;
51
- case "WMSInfoAvailable":
52
- this.emitEvent("WMSInfoAvailable", e.data, e.data.domId);
53
- break;
54
- case "giswaterTiledBackgroundDisplayed":
55
- this.emitEvent(
56
- "giswaterTiledBackgroundDisplayed",
57
- e.data,
58
- e.data.domId
59
- );
60
- break;
61
- case "giswaterTiledBackgroundAvailable":
62
- this.emitEvent(
63
- "giswaterTiledBackgroundAvailable",
64
- e.data,
65
- e.data.domId
66
- );
67
- break;
68
- case "GiswaterLayerAvailableFilters":
69
- this.emitEvent("GiswaterLayerAvailableFilters", e.data, e.data.domId);
70
- break;
71
- case "loaded":
72
- this.emitEvent("loaded", e.data, e.data.domId);
73
- break;
74
- case "availableWMSLayers":
75
- this.emitEvent("availableWMSLayers", e.data, e.data.domId);
76
- break;
77
- case "layerElements":
78
- this.emitEvent("layerElements", e.data, e.data.domId);
79
- break;
80
- case "getToc":
81
- this.emitEvent("getToc", e.data, e.data.domId);
82
- break;
83
- case "capabilities":
84
- this.emitEvent("capabilities", e.data, e.data.domId);
85
- break;
86
- case "GiswaterFiltersApplied":
87
- this.emitEvent("GiswaterFiltersApplied", e.data, e.data.domId);
88
- break;
89
- case "MeasureEnd":
90
- this.emitEvent("MeasureEnd", e.data, e.data.domId);
91
- break;
92
- case "MeasureStart":
93
- this.emitEvent("MeasureStart", e.data, e.data.domId);
94
- break;
19
+ onMessageReceived = e => {
20
+ console.log("event arrived to mapHandler",e)
21
+ switch(e.data.type){
22
+
23
+ case "onZoomChange": this.emitEvent("onZoomChange", e.data.zoom,e.data.domId); break;
24
+ case "geomAdded": this.emitEvent("geomAdded", e.data.geom_astext,e.data.domId); break;
25
+ case "layers": this.emitEvent("layers", e.data.layers,e.data.domId); break;
26
+ case "geoJSONlayers": this.emitEvent("geoJSONlayers", e.data.layers,e.data.domId); break;
27
+ case "info": this.emitEvent("info", e.data,e.data.domId); break;
28
+ case "error": this.emitEvent("error", e.data,e.data.domId); break;
29
+ case "coordinates": this.emitEvent("coordinates", e.data,e.data.domId); break;
30
+ case "activeLayer": this.emitEvent("activeLayer", e.data,e.data.domId); break;
31
+ case "geolocation": this.emitEvent("geolocation", e.data,e.data.domId); break;
32
+ case "WMSInfoAvailable": this.emitEvent("WMSInfoAvailable", e.data,e.data.domId); break;
33
+ case "giswaterTiledBackgroundDisplayed": this.emitEvent("giswaterTiledBackgroundDisplayed", e.data,e.data.domId); break;
34
+ case "giswaterTiledBackgroundAvailable": this.emitEvent("giswaterTiledBackgroundAvailable", e.data,e.data.domId); break;
35
+ case "GiswaterLayerAvailableFilters": this.emitEvent("GiswaterLayerAvailableFilters", e.data,e.data.domId); break;
36
+ case "loaded": this.emitEvent("loaded", e.data,e.data.domId); break;
37
+ case "unloaded": this.emitEvent("unloaded", e.data,e.data.domId); break;
38
+ case "availableWMSLayers": this.emitEvent("availableWMSLayers", e.data.layers,e.data.domId); break;
39
+ case "layerElements": this.emitEvent("layerElements", e.data,e.data.domId); break;
40
+ case "getToc": this.emitEvent("getToc", e.data,e.data.domId); break;
41
+ //case "getLegend": this.emitEvent("getLegend", e.data,e.data.domId); break;
95
42
  }
96
- };
43
+
44
+ }
97
45
 
98
- emitEvent = (type, data, domId) => {
99
- if (domId === this.domId) {
46
+ emitEvent = (type,data,domId)=>{
47
+ if(domId===this.domId){
100
48
  delete data.domId;
101
- this.emit(type, data);
49
+ this.emit(type, data);
102
50
  }
103
- };
51
+ }
104
52
 
105
53
  ZoomIn = () => {
106
54
  this.com.sendMessageToMap({
107
55
  type: "zoomIn",
108
56
  sessionToken: this.sessionToken,
109
- });
110
- };
57
+ });
111
58
 
59
+ }
60
+
112
61
  ZoomOut = () => {
113
62
  this.com.sendMessageToMap({
114
63
  type: "zoomOut",
115
64
  sessionToken: this.sessionToken,
116
- });
117
- };
65
+ });
66
+ }
118
67
 
119
68
  AddGeom = (geomtype) => {
120
69
  this.com.sendMessageToMap({
121
70
  type: "AddGeom",
122
71
  geom: geomtype,
123
72
  sessionToken: this.sessionToken,
124
- });
125
- };
73
+ });
74
+ }
126
75
 
127
- toggleLayer = (layer, properties) => {
128
- if (typeof properties === "undefined") {
76
+ toggleLayer = (layer,properties) => {
77
+ if(typeof properties==='undefined'){
129
78
  properties = {
130
79
  gutter: null,
131
80
  transparent: null,
132
- singletile: null,
133
- layerType: null,
81
+ singletile: null
134
82
  };
135
83
  }
136
84
 
137
- if (properties.layerType !== null) {
138
- if (
139
- properties.layerType !== "wms" &&
140
- properties.layerType !== "vector"
141
- ) {
142
- this.emit("error", { error: "layerType must be 'wms' or 'vector'" });
143
- return;
144
- }
145
- }
146
-
147
- if (
148
- properties.singletile !== null &&
149
- properties.layerType !== "vector"
150
- ) {
151
- if (typeof properties.singletile !== "boolean") {
85
+ if(properties.singletile!==null){
86
+ if(typeof properties.singletile!=='boolean'){
152
87
  properties.singletile = null;
153
- this.emit("error", { error: "singleTile must be a Boolean" });
88
+ this.emit("error",{error:"singleTile must be a Boolean"});
154
89
  }
155
- }
156
- if (properties.gutter !== "" && properties.gutter !== null) {
157
- if (isNaN(parseInt(properties.gutter))) {
90
+ }
91
+ if(properties.gutter!=='' && properties.gutter!==null){
92
+ if(isNaN(parseInt(properties.gutter))){
158
93
  properties.gutter = null;
159
- this.emit("error", { error: "Gutter must be a number" });
94
+ this.emit("error",{error:"Gutter must be a number"});
160
95
  }
161
- if (properties.singletile) {
96
+ if(properties.singletile){
162
97
  properties.gutter = null;
163
- this.emit("error", {
164
- error:
165
- "Gutter can only be user with multitile layers; set singletile to false",
166
- });
98
+ this.emit("error",{error:"Gutter can only be user with multitile layers; set singletile to false"});
167
99
  }
168
- }
100
+ }
169
101
 
170
- if (properties.transparent !== null) {
171
- if (typeof properties.transparent !== "boolean") {
102
+ if(properties.transparent!==null){
103
+ if(typeof properties.transparent!=='boolean'){
172
104
  properties.transparent = null;
173
- this.emit("error", { error: "transparent must be a Boolean" });
105
+ this.emit("error",{error:"transparent must be a Boolean"});
174
106
  }
175
- }
176
-
107
+ }
177
108
  this.com.sendMessageToMap({
178
109
  type: "toggleLayer",
179
110
  layer: layer,
180
- gutter: !isNaN(parseInt(properties.gutter))
181
- ? parseInt(properties.gutter)
182
- : null,
111
+ gutter: !isNaN(parseInt(properties.gutter)) ? parseInt(properties.gutter) : null,
183
112
  transparent: properties.transparent,
184
113
  singletile: properties.singletile,
185
- layerType: properties.layerType,
186
114
  sessionToken: this.sessionToken,
187
- });
188
- };
115
+ });
116
+ }
189
117
 
190
118
  setActiveLayer = (layer) => {
191
119
  this.com.sendMessageToMap({
192
120
  type: "setActiveLayer",
193
121
  layer: layer,
194
122
  sessionToken: this.sessionToken,
195
- });
196
- };
123
+ });
124
+ }
197
125
 
198
126
  getActiveLayer = () => {
199
127
  this.com.sendMessageToMap({
200
128
  type: "getActiveLayer",
201
129
  sessionToken: this.sessionToken,
202
- });
203
- };
130
+ });
131
+ }
204
132
 
205
133
  loadWMSAvailableLayers = () => {
206
134
  this.com.sendMessageToMap({
207
135
  type: "loadWMSAvailableLayers",
208
136
  sessionToken: this.sessionToken,
209
- });
210
- };
137
+ });
138
+ }
211
139
 
212
140
  clear = () => {
213
141
  this.com.sendMessageToMap({
214
142
  type: "clear",
215
143
  sessionToken: this.sessionToken,
216
- });
217
- };
144
+ });
145
+ }
218
146
 
219
147
  Highlight = (options) => {
220
148
  this.com.sendMessageToMap({
@@ -222,39 +150,36 @@ class Communicator extends EventEmitter {
222
150
  geom: options.geom,
223
151
  zoom: options.zoom,
224
152
  sessionToken: this.sessionToken,
225
- });
226
- };
153
+ });
154
+ }
227
155
 
228
156
  zoomToExtent = () => {
229
157
  this.com.sendMessageToMap({
230
158
  type: "zoomToExtent",
231
159
  sessionToken: this.sessionToken,
232
- });
233
- };
160
+ });
161
+ }
234
162
 
235
- zoomToCoordinates = (lat, lon, zoomLevel) => {
236
- if (!isNaN(parseInt(zoomLevel))) {
163
+ zoomToCoordinates= (lat,lon,zoomLevel) => {
164
+ if(!isNaN(parseInt(zoomLevel))){
237
165
  this.com.sendMessageToMap({
238
166
  type: "zoomToCoordinates",
239
167
  sessionToken: this.sessionToken,
240
- coordinates: [lat, lon],
241
- zoomLevel: zoomLevel,
242
- });
168
+ coordinates:[lat,lon],
169
+ zoomLevel: zoomLevel
170
+ });
243
171
  }
244
- };
245
-
246
- infoFromCoordinates = (type, layer, hitTolerance, format) => {
247
- const _layer = typeof layer == "undefined" ? null : layer;
248
- const _hitTolerance =
249
- typeof hitTolerance == "undefined" || !hitTolerance
250
- ? 5
251
- : parseInt(hitTolerance);
252
- const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
253
- if (_format !== "xml" && _format !== "json") {
172
+ }
173
+
174
+ infoFromCoordinates = (type,layer,hitTolerance,format) => {
175
+ const _layer = (typeof layer=='undefined') ? null : layer
176
+ const _hitTolerance = (typeof hitTolerance=='undefined' || !hitTolerance) ? 5 : parseInt(hitTolerance)
177
+ const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
178
+ if(_format!=="xml" && _format!=='json'){
254
179
  console.error("Format must be 'xml' or 'json");
255
180
  return;
256
181
  }
257
- if (isNaN(_hitTolerance)) {
182
+ if(isNaN(_hitTolerance)){
258
183
  console.error("hitTolerance must be a number");
259
184
  return;
260
185
  }
@@ -265,262 +190,196 @@ class Communicator extends EventEmitter {
265
190
  format: _format,
266
191
  hitTolerance: _hitTolerance,
267
192
  sessionToken: this.sessionToken,
268
- });
269
- };
193
+ });
194
+ }
270
195
 
271
- getElementsFromLayer = (layer, limit, format) => {
272
- const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
273
- if (_format !== "xml" && _format !== "json") {
196
+ getElementsFromLayer= (layer,limit,format) => {
197
+ const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
198
+ if(_format!=="xml" && _format!=='json'){
274
199
  console.error("Format must be 'xml' or 'json");
275
200
  return;
276
201
  }
277
- if (isNaN(limit)) {
278
- console.error("Limit must be a number");
202
+ if(isNaN(limit)){
203
+ console.error("Limit must be a number");
279
204
  return;
280
205
  }
281
- const _layer = typeof layer == "undefined" ? null : layer;
206
+ const _layer = (typeof layer=='undefined') ? null : layer
282
207
  this.com.sendMessageToMap({
283
208
  type: "getElementsFromLayer",
284
209
  layer: _layer,
285
- limit: typeof limit != "undefined" ? parseInt(limit) : 100,
210
+ limit: (typeof limit!='undefined') ? parseInt(limit) : 100,
286
211
  format: format,
287
212
  sessionToken: this.sessionToken,
288
- });
289
- };
213
+ });
214
+ }
290
215
 
291
216
  Geolocalize = (toggle) => {
292
217
  this.com.sendMessageToMap({
293
218
  type: "Geolocalize",
294
219
  toggle: toggle,
295
220
  sessionToken: this.sessionToken,
296
- });
297
- };
221
+ });
222
+ }
298
223
 
299
- toggleGiswaterTiled = (toggle, tiled) => {
224
+ toggleGiswaterTiled = (toggle,tiled) => {
300
225
  this.com.sendMessageToMap({
301
226
  type: "toggleGiswaterTiled",
302
227
  toggle: toggle,
303
228
  tiled: tiled,
304
229
  sessionToken: this.sessionToken,
305
- });
306
- };
230
+ });
231
+ }
307
232
 
308
- reloadDisplayedLayers = () => {
233
+ reloadDisplayedLayers = ()=>{
309
234
  return this.com.sendMessageToMap({
310
235
  type: "reloadDisplayedLayers",
311
236
  sessionToken: this.sessionToken,
312
- });
313
- };
237
+ });
238
+ }
314
239
 
315
- addGeoJSON = (geoJSON, options, name) => {
316
- if (geoJSON) {
240
+ addGeoJSON = (geoJSON,options, name)=>{
241
+ if(geoJSON){
317
242
  return this.com.sendMessageToMap({
318
243
  type: "addGeoJSON",
319
244
  geoJSON: geoJSON,
320
- options:
321
- typeof options != "undefined"
322
- ? options
323
- : { fillcolor: null, strokecolor: null },
324
- name: name ? name : Math.random().toString(36).substring(7),
245
+ options: (typeof options!='undefined') ? options : {fillcolor:null,strokecolor:null},
246
+ name: name ? name: Math.random().toString(36).substring(7),
325
247
  sessionToken: this.sessionToken,
326
- });
327
- } else {
328
- this.emit("error", { error: "No geoJSON data" });
248
+ });
249
+ }else{
250
+ this.emit("error",{error:"No geoJSON data"});
329
251
  return;
330
252
  }
331
- };
253
+ }
332
254
 
333
- clearGeoJSON = () => {
255
+ clearGeoJSON = ()=>{
334
256
  return this.com.sendMessageToMap({
335
257
  type: "clearGeoJSON",
336
258
  sessionToken: this.sessionToken,
337
- });
338
- };
259
+ });
260
+ }
339
261
 
340
- removeGeoJSONLayer = (name) => {
341
- if (name) {
262
+ removeGeoJSONLayer = (name)=>{
263
+ if(name){
342
264
  return this.com.sendMessageToMap({
343
265
  type: "removeGeoJSONLayer",
344
266
  name: name,
345
267
  sessionToken: this.sessionToken,
346
- });
347
- } else {
348
- this.emit("error", { error: "No geoJSON data" });
268
+ });
269
+ }else{
270
+ this.emit("error",{error:"No geoJSON data"});
349
271
  return;
350
272
  }
351
- };
352
-
353
- setGiswaterFilters = (filters) => {
273
+ }
274
+
275
+ setGiswaterFilters = (filters)=>{
354
276
  var filtersJson = filters;
355
- if (filters) {
356
- if (typeof filters != "object") {
357
- filters = filters.trim();
358
- filters = filters.replace(/^\s+|\s+$/g, "");
359
- filters = filters.replace(/\\/g, "");
360
- try {
361
- filtersJson = JSON.parse(filters);
362
- } catch (e) {
363
- this.emit("error", { error: "Filters is not a valid JSON" });
277
+ if(filters){
278
+ if(typeof filters!="object"){
279
+ filters = filters.trim()
280
+ filters = filters.replace(/^\s+|\s+$/g, '');
281
+ filters = filters.replace(/\\/g, '');
282
+ try{
283
+ filtersJson = JSON.parse(filters);
284
+ }catch(e){
285
+ this.emit("error",{error:"Filters is not a valid JSON"});
364
286
  return;
365
287
  }
366
288
  }
367
-
289
+
368
290
  return this.com.sendMessageToMap({
369
291
  type: "setGiswaterFilters",
370
292
  filters: filtersJson,
371
293
  sessionToken: this.sessionToken,
372
- });
373
- } else {
374
- this.emit("error", { error: "No filters" });
294
+ });
295
+ }else{
296
+ this.emit("error",{error:"No filters"});
375
297
  return;
376
298
  }
377
- };
299
+ }
378
300
 
379
- getGiswaterLayerAvailableFilters = (layer_name) => {
380
- if (layer_name) {
381
- return this.com.sendMessageToMap({
301
+ getGiswaterLayerAvailableFilters = (layer_name)=>{
302
+ if(layer_name){
303
+ return this.com.sendMessageToMap({
382
304
  type: "getGiswaterLayerAvailableFilters",
383
305
  name: layer_name,
384
306
  sessionToken: this.sessionToken,
385
- });
386
- } else {
387
- this.emit("error", { error: "No layer_name" });
307
+ });
308
+ }else{
309
+ this.emit("error",{error:"No layer_name"});
388
310
  return;
389
311
  }
390
- };
312
+ }
391
313
 
392
- getToc = () => {
314
+ getToc = ()=>{
393
315
  return this.com.sendMessageToMap({
394
316
  type: "getToc",
395
317
  sessionToken: this.sessionToken,
396
- });
397
- };
318
+ });
319
+ }
398
320
 
399
- setDebug = (what) => {
400
- if (!isNaN(parseInt(what))) {
321
+ setDebug = (what) =>{
322
+ if(!isNaN(parseInt(what))){
401
323
  this.com.sendMessageToMap({
402
324
  type: "setDebug",
403
325
  what: what,
404
326
  sessionToken: this.sessionToken,
405
327
  });
406
- } else {
328
+ }else{
407
329
  console.error("Debug is not a integer");
408
330
  }
409
- };
331
+ }
410
332
 
411
- setCustomColors = (properties) => {
333
+ setCustomColors = (properties)=>{
412
334
  //validate data
413
- if (typeof properties !== "object") {
335
+ if(typeof properties!=='object'){
414
336
  console.error("properties is not an object");
415
337
  return;
416
338
  }
417
- if (properties.hasOwnProperty("geom_stroke_width")) {
418
- if (isNaN(parseInt(properties.geom_stroke_width))) {
339
+ if(properties.hasOwnProperty('geom_stroke_width')){
340
+ if(isNaN(parseInt(properties.geom_stroke_width))){
419
341
  console.error("geom_stroke_width is not an number");
420
342
  return;
421
- } else {
343
+ }else{
422
344
  properties.geom_stroke_width = parseInt(properties.geom_stroke_width);
423
345
  }
424
- } else {
346
+ }else{
425
347
  properties.geom_stroke_width = 1;
426
348
  }
427
- if (properties.hasOwnProperty("geom_radius")) {
428
- if (isNaN(parseInt(properties.geom_radius))) {
349
+ if(properties.hasOwnProperty('geom_radius')){
350
+ if(isNaN(parseInt(properties.geom_radius))){
429
351
  console.error("geom_stroke_width is not an number");
430
352
  return;
431
- } else {
353
+ }else{
432
354
  properties.geom_radius = parseInt(properties.geom_radius);
433
355
  }
434
- } else {
356
+ }else{
435
357
  properties.geom_radius = 4;
436
358
  }
437
359
 
438
- if (properties.hasOwnProperty("geom_shape")) {
439
- if (
440
- properties.geom_shape !== "circle" &&
441
- properties.geom_shape !== "square"
442
- ) {
443
- properties.geom_shape = "circle";
360
+ if(properties.hasOwnProperty('geom_shape')){
361
+ if(properties.geom_shape!=="circle" && properties.geom_shape!=="square"){
362
+ properties.geom_shape = 'circle';
444
363
  console.error("geom_shape must be either 'circle' or 'square'");
445
364
  }
446
365
  }
447
366
  this.com.sendMessageToMap({
448
- type: "setCustomColors",
449
- properties: properties,
450
- sessionToken: this.sessionToken,
367
+ type: "setCustomColors",
368
+ properties: properties,
369
+ sessionToken: this.sessionToken,
451
370
  });
452
- };
371
+ }
453
372
 
454
- changeBackground = (newBackground) => {
373
+ changeBackground = (newBackground)=>{
455
374
  return this.com.sendMessageToMap({
456
375
  type: "changeBackground",
457
376
  sessionToken: this.sessionToken,
458
- newBackground: newBackground,
459
- });
460
- };
461
-
462
- centerMap = (coordinates) => {
463
- //validate data
464
- if (typeof coordinates !== "object") {
465
- console.error("properties is not an object");
466
- return;
467
- }
468
- return this.com.sendMessageToMap({
469
- type: "centerMap",
470
- sessionToken: this.sessionToken,
471
- coordinates: coordinates,
472
- });
473
- };
474
-
475
- drawGeometryInLayer = (uuid, layerName, geom_astext, label, style) => {
476
- return this.com.sendMessageToMap({
477
- type: "drawGeometryInLayer",
478
- sessionToken: this.sessionToken,
479
- uuid,
480
- layerName,
481
- geom_astext,
482
- label,
483
- style,
484
- });
485
- };
486
-
487
- removeGeometryFromLayer = (uuid, layerName) => {
488
- return this.com.sendMessageToMap({
489
- type: "removeGeometryFromLayer",
490
- sessionToken: this.sessionToken,
491
- uuid,
492
- layerName,
493
- });
494
- };
495
-
496
- initMeasure = (type,textStart,textContinue)=>{
497
- if(type!=='line' && type!=='area'){
498
- console.error( );
499
- return;
500
- }
501
- let text = null;
502
- if(textStart && textContinue){
503
-
504
- text = {
505
- textStart: textStart,
506
- textContinue: textContinue,
507
- }
508
- }
509
-
510
- return this.com.sendMessageToMap({
511
- type: "initMeasure",
512
- sessionToken: this.sessionToken,
513
- measure: type,
514
- text: text ? text: null,
515
- });
377
+ newBackground: newBackground
378
+ });
516
379
  }
517
380
 
518
- cancelMeasure= ()=>{
519
- return this.com.sendMessageToMap({
520
- type: "cancelMeasure",
521
- sessionToken: this.sessionToken,
522
- });
523
- }
524
381
  }
525
382
 
526
- export { Communicator };
383
+ export {
384
+ Communicator,
385
+ }