@vidro/map-handler 1.1.4 → 1.1.15

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 +178 -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,146 @@
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
+ switch(e.data.type){
21
+ case "onZoomChange": this.emitEvent("onZoomChange", e.data.zoom,e.data.domId); break;
22
+ case "geomAdded": this.emitEvent("geomAdded", e.data.geom_astext,e.data.domId); break;
23
+ case "layers": this.emitEvent("layers", e.data.layers,e.data.domId); break;
24
+ case "geoJSONlayers": this.emitEvent("geoJSONlayers", e.data.layers,e.data.domId); break;
25
+ case "info": this.emitEvent("info", e.data,e.data.domId); break;
26
+ case "error": this.emitEvent("error", e.data,e.data.domId); break;
27
+ case "coordinates": this.emitEvent("coordinates", e.data,e.data.domId); break;
28
+ case "activeLayer": this.emitEvent("activeLayer", e.data,e.data.domId); break;
29
+ case "geolocation": this.emitEvent("geolocation", e.data,e.data.domId); break;
30
+ case "WMSInfoAvailable": this.emitEvent("WMSInfoAvailable", e.data,e.data.domId); break;
31
+ case "giswaterTiledBackgroundDisplayed": this.emitEvent("giswaterTiledBackgroundDisplayed", e.data,e.data.domId); break;
32
+ case "giswaterTiledBackgroundAvailable": this.emitEvent("giswaterTiledBackgroundAvailable", e.data,e.data.domId); break;
33
+ case "GiswaterLayerAvailableFilters": this.emitEvent("GiswaterLayerAvailableFilters", e.data,e.data.domId); break;
34
+ case "loaded": this.emitEvent("loaded", e.data,e.data.domId); break;
35
+ case "unloaded": this.emitEvent("unloaded", e.data,e.data.domId); break;
36
+ case "availableWMSLayers": this.emitEvent("availableWMSLayers", e.data.layers,e.data.domId); break;
37
+ case "layerElements": this.emitEvent("layerElements", e.data,e.data.domId); break;
38
+ case "getToc": this.emitEvent("getToc", e.data,e.data.domId); break;
39
+ //case "getLegend": this.emitEvent("getLegend", e.data,e.data.domId); break;
95
40
  }
96
- };
41
+
42
+ }
97
43
 
98
- emitEvent = (type, data, domId) => {
99
- if (domId === this.domId) {
44
+ emitEvent = (type,data,domId)=>{
45
+ if(domId===this.domId){
100
46
  delete data.domId;
101
- this.emit(type, data);
47
+ this.emit(type, data);
102
48
  }
103
- };
49
+ }
104
50
 
105
51
  ZoomIn = () => {
106
52
  this.com.sendMessageToMap({
107
53
  type: "zoomIn",
108
54
  sessionToken: this.sessionToken,
109
- });
110
- };
55
+ });
111
56
 
57
+ }
58
+
112
59
  ZoomOut = () => {
113
60
  this.com.sendMessageToMap({
114
61
  type: "zoomOut",
115
62
  sessionToken: this.sessionToken,
116
- });
117
- };
63
+ });
64
+ }
118
65
 
119
66
  AddGeom = (geomtype) => {
120
67
  this.com.sendMessageToMap({
121
68
  type: "AddGeom",
122
69
  geom: geomtype,
123
70
  sessionToken: this.sessionToken,
124
- });
125
- };
71
+ });
72
+ }
126
73
 
127
- toggleLayer = (layer, properties) => {
128
- if (typeof properties === "undefined") {
74
+ toggleLayer = (layer,properties) => {
75
+ if(typeof properties==='undefined'){
129
76
  properties = {
130
77
  gutter: null,
131
78
  transparent: null,
132
- singletile: null,
133
- layerType: null,
79
+ singletile: null
134
80
  };
135
81
  }
136
82
 
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") {
83
+ if(properties.singletile!==null){
84
+ if(typeof properties.singletile!=='boolean'){
152
85
  properties.singletile = null;
153
- this.emit("error", { error: "singleTile must be a Boolean" });
86
+ this.emit("error",{error:"singleTile must be a Boolean"});
154
87
  }
155
- }
156
- if (properties.gutter !== "" && properties.gutter !== null) {
157
- if (isNaN(parseInt(properties.gutter))) {
88
+ }
89
+ if(properties.gutter!=='' && properties.gutter!==null){
90
+ if(isNaN(parseInt(properties.gutter))){
158
91
  properties.gutter = null;
159
- this.emit("error", { error: "Gutter must be a number" });
92
+ this.emit("error",{error:"Gutter must be a number"});
160
93
  }
161
- if (properties.singletile) {
94
+ if(properties.singletile){
162
95
  properties.gutter = null;
163
- this.emit("error", {
164
- error:
165
- "Gutter can only be user with multitile layers; set singletile to false",
166
- });
96
+ this.emit("error",{error:"Gutter can only be user with multitile layers; set singletile to false"});
167
97
  }
168
- }
98
+ }
169
99
 
170
- if (properties.transparent !== null) {
171
- if (typeof properties.transparent !== "boolean") {
100
+ if(properties.transparent!==null){
101
+ if(typeof properties.transparent!=='boolean'){
172
102
  properties.transparent = null;
173
- this.emit("error", { error: "transparent must be a Boolean" });
103
+ this.emit("error",{error:"transparent must be a Boolean"});
174
104
  }
175
- }
176
-
105
+ }
177
106
  this.com.sendMessageToMap({
178
107
  type: "toggleLayer",
179
108
  layer: layer,
180
- gutter: !isNaN(parseInt(properties.gutter))
181
- ? parseInt(properties.gutter)
182
- : null,
109
+ gutter: !isNaN(parseInt(properties.gutter)) ? parseInt(properties.gutter) : null,
183
110
  transparent: properties.transparent,
184
111
  singletile: properties.singletile,
185
- layerType: properties.layerType,
186
112
  sessionToken: this.sessionToken,
187
- });
188
- };
113
+ });
114
+ }
189
115
 
190
116
  setActiveLayer = (layer) => {
191
117
  this.com.sendMessageToMap({
192
118
  type: "setActiveLayer",
193
119
  layer: layer,
194
120
  sessionToken: this.sessionToken,
195
- });
196
- };
121
+ });
122
+ }
197
123
 
198
124
  getActiveLayer = () => {
199
125
  this.com.sendMessageToMap({
200
126
  type: "getActiveLayer",
201
127
  sessionToken: this.sessionToken,
202
- });
203
- };
128
+ });
129
+ }
204
130
 
205
131
  loadWMSAvailableLayers = () => {
206
132
  this.com.sendMessageToMap({
207
133
  type: "loadWMSAvailableLayers",
208
134
  sessionToken: this.sessionToken,
209
- });
210
- };
135
+ });
136
+ }
211
137
 
212
138
  clear = () => {
213
139
  this.com.sendMessageToMap({
214
140
  type: "clear",
215
141
  sessionToken: this.sessionToken,
216
- });
217
- };
142
+ });
143
+ }
218
144
 
219
145
  Highlight = (options) => {
220
146
  this.com.sendMessageToMap({
@@ -222,39 +148,36 @@ class Communicator extends EventEmitter {
222
148
  geom: options.geom,
223
149
  zoom: options.zoom,
224
150
  sessionToken: this.sessionToken,
225
- });
226
- };
151
+ });
152
+ }
227
153
 
228
154
  zoomToExtent = () => {
229
155
  this.com.sendMessageToMap({
230
156
  type: "zoomToExtent",
231
157
  sessionToken: this.sessionToken,
232
- });
233
- };
158
+ });
159
+ }
234
160
 
235
- zoomToCoordinates = (lat, lon, zoomLevel) => {
236
- if (!isNaN(parseInt(zoomLevel))) {
161
+ zoomToCoordinates= (lat,lon,zoomLevel) => {
162
+ if(!isNaN(parseInt(zoomLevel))){
237
163
  this.com.sendMessageToMap({
238
164
  type: "zoomToCoordinates",
239
165
  sessionToken: this.sessionToken,
240
- coordinates: [lat, lon],
241
- zoomLevel: zoomLevel,
242
- });
166
+ coordinates:[lat,lon],
167
+ zoomLevel: zoomLevel
168
+ });
243
169
  }
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") {
170
+ }
171
+
172
+ infoFromCoordinates = (type,layer,hitTolerance,format) => {
173
+ const _layer = (typeof layer=='undefined') ? null : layer
174
+ const _hitTolerance = (typeof hitTolerance=='undefined' || !hitTolerance) ? 5 : parseInt(hitTolerance)
175
+ const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
176
+ if(_format!=="xml" && _format!=='json'){
254
177
  console.error("Format must be 'xml' or 'json");
255
178
  return;
256
179
  }
257
- if (isNaN(_hitTolerance)) {
180
+ if(isNaN(_hitTolerance)){
258
181
  console.error("hitTolerance must be a number");
259
182
  return;
260
183
  }
@@ -265,262 +188,196 @@ class Communicator extends EventEmitter {
265
188
  format: _format,
266
189
  hitTolerance: _hitTolerance,
267
190
  sessionToken: this.sessionToken,
268
- });
269
- };
191
+ });
192
+ }
270
193
 
271
- getElementsFromLayer = (layer, limit, format) => {
272
- const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
273
- if (_format !== "xml" && _format !== "json") {
194
+ getElementsFromLayer= (layer,limit,format) => {
195
+ const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
196
+ if(_format!=="xml" && _format!=='json'){
274
197
  console.error("Format must be 'xml' or 'json");
275
198
  return;
276
199
  }
277
- if (isNaN(limit)) {
278
- console.error("Limit must be a number");
200
+ if(isNaN(limit)){
201
+ console.error("Limit must be a number");
279
202
  return;
280
203
  }
281
- const _layer = typeof layer == "undefined" ? null : layer;
204
+ const _layer = (typeof layer=='undefined') ? null : layer
282
205
  this.com.sendMessageToMap({
283
206
  type: "getElementsFromLayer",
284
207
  layer: _layer,
285
- limit: typeof limit != "undefined" ? parseInt(limit) : 100,
208
+ limit: (typeof limit!='undefined') ? parseInt(limit) : 100,
286
209
  format: format,
287
210
  sessionToken: this.sessionToken,
288
- });
289
- };
211
+ });
212
+ }
290
213
 
291
214
  Geolocalize = (toggle) => {
292
215
  this.com.sendMessageToMap({
293
216
  type: "Geolocalize",
294
217
  toggle: toggle,
295
218
  sessionToken: this.sessionToken,
296
- });
297
- };
219
+ });
220
+ }
298
221
 
299
- toggleGiswaterTiled = (toggle, tiled) => {
222
+ toggleGiswaterTiled = (toggle,tiled) => {
300
223
  this.com.sendMessageToMap({
301
224
  type: "toggleGiswaterTiled",
302
225
  toggle: toggle,
303
226
  tiled: tiled,
304
227
  sessionToken: this.sessionToken,
305
- });
306
- };
228
+ });
229
+ }
307
230
 
308
- reloadDisplayedLayers = () => {
231
+ reloadDisplayedLayers = ()=>{
309
232
  return this.com.sendMessageToMap({
310
233
  type: "reloadDisplayedLayers",
311
234
  sessionToken: this.sessionToken,
312
- });
313
- };
235
+ });
236
+ }
314
237
 
315
- addGeoJSON = (geoJSON, options, name) => {
316
- if (geoJSON) {
238
+ addGeoJSON = (geoJSON,options, name)=>{
239
+ if(geoJSON){
317
240
  return this.com.sendMessageToMap({
318
241
  type: "addGeoJSON",
319
242
  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),
243
+ options: (typeof options!='undefined') ? options : {fillcolor:null,strokecolor:null},
244
+ name: name ? name: Math.random().toString(36).substring(7),
325
245
  sessionToken: this.sessionToken,
326
- });
327
- } else {
328
- this.emit("error", { error: "No geoJSON data" });
246
+ });
247
+ }else{
248
+ this.emit("error",{error:"No geoJSON data"});
329
249
  return;
330
250
  }
331
- };
251
+ }
332
252
 
333
- clearGeoJSON = () => {
253
+ clearGeoJSON = ()=>{
334
254
  return this.com.sendMessageToMap({
335
255
  type: "clearGeoJSON",
336
256
  sessionToken: this.sessionToken,
337
- });
338
- };
257
+ });
258
+ }
339
259
 
340
- removeGeoJSONLayer = (name) => {
341
- if (name) {
260
+ removeGeoJSONLayer = (name)=>{
261
+ if(name){
342
262
  return this.com.sendMessageToMap({
343
263
  type: "removeGeoJSONLayer",
344
264
  name: name,
345
265
  sessionToken: this.sessionToken,
346
- });
347
- } else {
348
- this.emit("error", { error: "No geoJSON data" });
266
+ });
267
+ }else{
268
+ this.emit("error",{error:"No geoJSON data"});
349
269
  return;
350
270
  }
351
- };
352
-
353
- setGiswaterFilters = (filters) => {
271
+ }
272
+
273
+ setGiswaterFilters = (filters)=>{
354
274
  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" });
275
+ if(filters){
276
+ if(typeof filters!="object"){
277
+ filters = filters.trim()
278
+ filters = filters.replace(/^\s+|\s+$/g, '');
279
+ filters = filters.replace(/\\/g, '');
280
+ try{
281
+ filtersJson = JSON.parse(filters);
282
+ }catch(e){
283
+ this.emit("error",{error:"Filters is not a valid JSON"});
364
284
  return;
365
285
  }
366
286
  }
367
-
287
+
368
288
  return this.com.sendMessageToMap({
369
289
  type: "setGiswaterFilters",
370
290
  filters: filtersJson,
371
291
  sessionToken: this.sessionToken,
372
- });
373
- } else {
374
- this.emit("error", { error: "No filters" });
292
+ });
293
+ }else{
294
+ this.emit("error",{error:"No filters"});
375
295
  return;
376
296
  }
377
- };
297
+ }
378
298
 
379
- getGiswaterLayerAvailableFilters = (layer_name) => {
380
- if (layer_name) {
381
- return this.com.sendMessageToMap({
299
+ getGiswaterLayerAvailableFilters = (layer_name)=>{
300
+ if(layer_name){
301
+ return this.com.sendMessageToMap({
382
302
  type: "getGiswaterLayerAvailableFilters",
383
303
  name: layer_name,
384
304
  sessionToken: this.sessionToken,
385
- });
386
- } else {
387
- this.emit("error", { error: "No layer_name" });
305
+ });
306
+ }else{
307
+ this.emit("error",{error:"No layer_name"});
388
308
  return;
389
309
  }
390
- };
310
+ }
391
311
 
392
- getToc = () => {
312
+ getToc = ()=>{
393
313
  return this.com.sendMessageToMap({
394
314
  type: "getToc",
395
315
  sessionToken: this.sessionToken,
396
- });
397
- };
316
+ });
317
+ }
398
318
 
399
- setDebug = (what) => {
400
- if (!isNaN(parseInt(what))) {
319
+ setDebug = (what) =>{
320
+ if(!isNaN(parseInt(what))){
401
321
  this.com.sendMessageToMap({
402
322
  type: "setDebug",
403
323
  what: what,
404
324
  sessionToken: this.sessionToken,
405
325
  });
406
- } else {
326
+ }else{
407
327
  console.error("Debug is not a integer");
408
328
  }
409
- };
329
+ }
410
330
 
411
- setCustomColors = (properties) => {
331
+ setCustomColors = (properties)=>{
412
332
  //validate data
413
- if (typeof properties !== "object") {
333
+ if(typeof properties!=='object'){
414
334
  console.error("properties is not an object");
415
335
  return;
416
336
  }
417
- if (properties.hasOwnProperty("geom_stroke_width")) {
418
- if (isNaN(parseInt(properties.geom_stroke_width))) {
337
+ if(properties.hasOwnProperty('geom_stroke_width')){
338
+ if(isNaN(parseInt(properties.geom_stroke_width))){
419
339
  console.error("geom_stroke_width is not an number");
420
340
  return;
421
- } else {
341
+ }else{
422
342
  properties.geom_stroke_width = parseInt(properties.geom_stroke_width);
423
343
  }
424
- } else {
344
+ }else{
425
345
  properties.geom_stroke_width = 1;
426
346
  }
427
- if (properties.hasOwnProperty("geom_radius")) {
428
- if (isNaN(parseInt(properties.geom_radius))) {
347
+ if(properties.hasOwnProperty('geom_radius')){
348
+ if(isNaN(parseInt(properties.geom_radius))){
429
349
  console.error("geom_stroke_width is not an number");
430
350
  return;
431
- } else {
351
+ }else{
432
352
  properties.geom_radius = parseInt(properties.geom_radius);
433
353
  }
434
- } else {
354
+ }else{
435
355
  properties.geom_radius = 4;
436
356
  }
437
357
 
438
- if (properties.hasOwnProperty("geom_shape")) {
439
- if (
440
- properties.geom_shape !== "circle" &&
441
- properties.geom_shape !== "square"
442
- ) {
443
- properties.geom_shape = "circle";
358
+ if(properties.hasOwnProperty('geom_shape')){
359
+ if(properties.geom_shape!=="circle" && properties.geom_shape!=="square"){
360
+ properties.geom_shape = 'circle';
444
361
  console.error("geom_shape must be either 'circle' or 'square'");
445
362
  }
446
363
  }
447
364
  this.com.sendMessageToMap({
448
- type: "setCustomColors",
449
- properties: properties,
450
- sessionToken: this.sessionToken,
365
+ type: "setCustomColors",
366
+ properties: properties,
367
+ sessionToken: this.sessionToken,
451
368
  });
452
- };
369
+ }
453
370
 
454
- changeBackground = (newBackground) => {
371
+ changeBackground = (newBackground)=>{
455
372
  return this.com.sendMessageToMap({
456
373
  type: "changeBackground",
457
374
  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
- });
375
+ newBackground: newBackground
376
+ });
516
377
  }
517
378
 
518
- cancelMeasure= ()=>{
519
- return this.com.sendMessageToMap({
520
- type: "cancelMeasure",
521
- sessionToken: this.sessionToken,
522
- });
523
- }
524
379
  }
525
380
 
526
- export { Communicator };
381
+ export {
382
+ Communicator,
383
+ }