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