@vidro/map-handler 1.0.4 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. package/README.md +326 -118
  2. package/dist/map-handler.js +1 -1
  3. package/doc/giswater.png +0 -0
  4. package/doc/giswaterInfo.png +0 -0
  5. package/doc/giswaterInfoApi.png +0 -0
  6. package/doc/giswatergeojson.png +0 -0
  7. package/doc/multiTile.png +0 -0
  8. package/doc/multiTileNoGutter.png +0 -0
  9. package/doc/togglelayergiswater.png +0 -0
  10. package/doc/vidromaps-basic.png +0 -0
  11. package/examples/externalwms/index.js +20 -0
  12. package/examples/externalwms/index.php +88 -0
  13. package/examples/full/apidemo.js +54 -11
  14. package/examples/full/cachedToken.dat +1 -1
  15. package/examples/full/cachedTokenData.dat +1 -1
  16. package/examples/full/index.php +37 -18
  17. package/examples/full/tester.js +177 -13
  18. package/examples/integration/tool/css/dist/home.css.min.css +0 -0
  19. package/examples/integration/tool/css/dist/home.min.css +1 -0
  20. package/examples/integration/tool/css/dist/home.min.css.map +10 -0
  21. package/examples/integration/tool/css/dist/style-login.css.min.css +0 -0
  22. package/examples/integration/tool/css/dist/style-login.min.css +1 -0
  23. package/examples/integration/tool/css/dist/style-login.min.css.map +10 -0
  24. package/examples/integration/tool/css/dist/style.css.min.css +0 -0
  25. package/examples/integration/tool/css/dist/style.min.css +1 -0
  26. package/examples/integration/tool/css/dist/style.min.css.map +23 -0
  27. package/examples/integration/tool/css/master/_bottom-sheet-2.scss +103 -0
  28. package/examples/integration/tool/css/master/_bottom-sheet.scss +142 -0
  29. package/examples/integration/tool/css/master/_colors.scss +35 -0
  30. package/examples/integration/tool/css/master/_dropdown-form.scss +167 -0
  31. package/examples/integration/tool/css/master/_forms.scss +416 -0
  32. package/examples/integration/tool/css/master/_header.scss +134 -0
  33. package/examples/integration/tool/css/master/_menu-toc.scss +135 -0
  34. package/examples/integration/tool/css/master/_menu-tools.scss +187 -0
  35. package/examples/integration/tool/css/master/_mixins.scss +42 -0
  36. package/examples/integration/tool/css/master/_notifyjs.scss +39 -0
  37. package/examples/integration/tool/css/master/_ol-map-controls.scss +117 -0
  38. package/examples/integration/tool/css/master/_simplelightbox.scss +287 -0
  39. package/examples/integration/tool/css/master/_toc-config.scss +28 -0
  40. package/examples/integration/tool/css/master/_toc-layouts.scss +173 -0
  41. package/examples/integration/tool/css/master/_tooltip.scss +34 -0
  42. package/examples/integration/tool/css/master/home.scss +266 -0
  43. package/examples/integration/tool/css/master/style-login.scss +240 -0
  44. package/examples/integration/tool/css/master/style.scss +166 -0
  45. package/examples/integration/tool/img/doc-gallery-placeholder.svg +3 -0
  46. package/examples/integration/tool/img/home/ic_calendar-clock.svg +1 -0
  47. package/examples/integration/tool/img/home/ic_caret-down.svg +1 -0
  48. package/examples/integration/tool/img/home/ic_cog.svg +1 -0
  49. package/examples/integration/tool/img/home/ic_marker.svg +1 -0
  50. package/examples/integration/tool/img/home/ic_play-circle.svg +1 -0
  51. package/examples/integration/tool/img/home/ic_power.svg +1 -0
  52. package/examples/integration/tool/img/home/ic_squares.svg +1 -0
  53. package/examples/integration/tool/img/home/ic_user-pointer.svg +1 -0
  54. package/examples/integration/tool/img/home/ic_user-square.svg +1 -0
  55. package/examples/integration/tool/img/home/logo_footer.svg +1 -0
  56. package/examples/integration/tool/img/ic/accessControl.svg +1 -0
  57. package/examples/integration/tool/img/ic/account-location.svg +1 -0
  58. package/examples/integration/tool/img/ic/actionDelete.svg +64 -0
  59. package/examples/integration/tool/img/ic/actionOpen.svg +64 -0
  60. package/examples/integration/tool/img/ic/addFile.svg +100 -0
  61. package/examples/integration/tool/img/ic/addFile_off.svg +102 -0
  62. package/examples/integration/tool/img/ic/arrow-left.svg +1 -0
  63. package/examples/integration/tool/img/ic/arrow-right-drop-circle-outline.svg +1 -0
  64. package/examples/integration/tool/img/ic/bt_add_photo.svg +3 -0
  65. package/examples/integration/tool/img/ic/bug.svg +1 -0
  66. package/examples/integration/tool/img/ic/caret-down-bottomsheet.svg +3 -0
  67. package/examples/integration/tool/img/ic/checkbox-blank-outline-grey.svg +8 -0
  68. package/examples/integration/tool/img/ic/checkbox-blank-outline-white.svg +8 -0
  69. package/examples/integration/tool/img/ic/checkbox-blank-outline.svg +1 -0
  70. package/examples/integration/tool/img/ic/checkbox-marked-outline-grey.svg +8 -0
  71. package/examples/integration/tool/img/ic/checkbox-marked-outline-white.svg +8 -0
  72. package/examples/integration/tool/img/ic/checkbox-marked-outline.svg +1 -0
  73. package/examples/integration/tool/img/ic/chevron-down-grey.svg +7 -0
  74. package/examples/integration/tool/img/ic/chevron-down-white.svg +7 -0
  75. package/examples/integration/tool/img/ic/chevron-down.svg +1 -0
  76. package/examples/integration/tool/img/ic/chevron-right-grey.svg +7 -0
  77. package/examples/integration/tool/img/ic/chevron-right-white.svg +7 -0
  78. package/examples/integration/tool/img/ic/chevron-right.svg +1 -0
  79. package/examples/integration/tool/img/ic/comment-text-outline.svg +1 -0
  80. package/examples/integration/tool/img/ic/cookie.svg +1 -0
  81. package/examples/integration/tool/img/ic/delete.svg +1 -0
  82. package/examples/integration/tool/img/ic/dot.svg +1 -0
  83. package/examples/integration/tool/img/ic/dump.svg +1 -0
  84. package/examples/integration/tool/img/ic/e.svg +9 -0
  85. package/examples/integration/tool/img/ic/eye-off.svg +1 -0
  86. package/examples/integration/tool/img/ic/eye.svg +1 -0
  87. package/examples/integration/tool/img/ic/forbidden.svg +1 -0
  88. package/examples/integration/tool/img/ic/form-title-1.svg +3 -0
  89. package/examples/integration/tool/img/ic/group.svg +1 -0
  90. package/examples/integration/tool/img/ic/hamburger.svg +1 -0
  91. package/examples/integration/tool/img/ic/ic-users.svg +1 -0
  92. package/examples/integration/tool/img/ic/ic_dropdown-form-close.svg +3 -0
  93. package/examples/integration/tool/img/ic/ic_dropdown-form-link.svg +3 -0
  94. package/examples/integration/tool/img/ic/ic_feature-edit-cancel.svg +14 -0
  95. package/examples/integration/tool/img/ic/ic_feature-edit-save.svg +14 -0
  96. package/examples/integration/tool/img/ic/ic_gallery-item-delete.svg +3 -0
  97. package/examples/integration/tool/img/ic/ic_gallery-item-view.svg +3 -0
  98. package/examples/integration/tool/img/ic/ic_gps.svg +3 -0
  99. package/examples/integration/tool/img/ic/ic_search.svg +5 -0
  100. package/examples/integration/tool/img/ic/ic_selector_fechas.svg +63 -0
  101. package/examples/integration/tool/img/ic/ic_zoom-to-extent.svg +3 -0
  102. package/examples/integration/tool/img/ic/icon_reminder.png +0 -0
  103. package/examples/integration/tool/img/ic/image-gallery-placeholder.svg +55 -0
  104. package/examples/integration/tool/img/ic/imaqua.svg +87 -0
  105. package/examples/integration/tool/img/ic/incidencia.svg +77 -0
  106. package/examples/integration/tool/img/ic/info_multi_selection.svg +230 -0
  107. package/examples/integration/tool/img/ic/layers.svg +1 -0
  108. package/examples/integration/tool/img/ic/map-marker.svg +3 -0
  109. package/examples/integration/tool/img/ic/map.svg +1 -0
  110. package/examples/integration/tool/img/ic/measure_area.svg +111 -0
  111. package/examples/integration/tool/img/ic/minus.svg +7 -0
  112. package/examples/integration/tool/img/ic/notification.svg +1 -0
  113. package/examples/integration/tool/img/ic/offline.svg +3 -0
  114. package/examples/integration/tool/img/ic/online.svg +1 -0
  115. package/examples/integration/tool/img/ic/pencil.svg +3 -0
  116. package/examples/integration/tool/img/ic/plus.svg +1 -0
  117. package/examples/integration/tool/img/ic/polygon_selection.svg +68 -0
  118. package/examples/integration/tool/img/ic/power.svg +1 -0
  119. package/examples/integration/tool/img/ic/remoteLocalized.svg +4 -0
  120. package/examples/integration/tool/img/ic/remoteStartLocalize.svg +4 -0
  121. package/examples/integration/tool/img/ic/ruler.svg +125 -0
  122. package/examples/integration/tool/img/ic/selection-plus.svg +10 -0
  123. package/examples/integration/tool/img/ic/selection.svg +1 -0
  124. package/examples/integration/tool/img/ic/settings.svg +1 -0
  125. package/examples/integration/tool/img/ic/sort.svg +1 -0
  126. package/examples/integration/tool/img/ic/sort_asc.svg +1 -0
  127. package/examples/integration/tool/img/ic/sort_desc.svg +1 -0
  128. package/examples/integration/tool/img/ic/spreadsheet.svg +3 -0
  129. package/examples/integration/tool/img/ic/times.svg +1 -0
  130. package/examples/integration/tool/img/ic/toolbar/AB3.svg +1 -0
  131. package/examples/integration/tool/img/ic/toolbar/AB4.svg +1 -0
  132. package/examples/integration/tool/img/ic/toolbar/IC1.svg +1 -0
  133. package/examples/integration/tool/img/ic/toolbar/TB1.svg +1 -0
  134. package/examples/integration/tool/img/ic/toolbar/TB11.svg +5 -0
  135. package/examples/integration/tool/img/ic/toolbar/TB2.svg +1 -0
  136. package/examples/integration/tool/img/ic/toolbar/TB20.svg +1 -0
  137. package/examples/integration/tool/img/ic/toolbar/TB21.svg +54 -0
  138. package/examples/integration/tool/img/ic/toolbar/TB3.svg +1 -0
  139. package/examples/integration/tool/img/ic/toolbar/TB31.svg +1 -0
  140. package/examples/integration/tool/img/ic/toolbar/TB32.svg +57 -0
  141. package/examples/integration/tool/img/ic/toolbar/TB4.svg +1 -0
  142. package/examples/integration/tool/img/ic/toolbar/TB5.svg +1 -0
  143. package/examples/integration/tool/img/ic/toolbar/TB6.svg +1 -0
  144. package/examples/integration/tool/img/ic/toolbar/TB7.svg +1 -0
  145. package/examples/integration/tool/img/ic/toolbar/TB8.svg +1 -0
  146. package/examples/integration/tool/img/ic/tools.svg +28 -0
  147. package/examples/integration/tool/img/ic/user.svg +1 -0
  148. package/examples/integration/tool/img/ic/vector-polygon.svg +1 -0
  149. package/examples/integration/tool/img/ic/visit_manager.svg +135 -0
  150. package/examples/integration/tool/img/logo-footer-login.png +0 -0
  151. package/examples/integration/tool/img/logo-footer.png +0 -0
  152. package/examples/integration/tool/img/logo-header-login.png +0 -0
  153. package/examples/integration/tool/img/logo-header-login@2x.png +0 -0
  154. package/examples/integration/tool/img/logo-header-login@3x.png +0 -0
  155. package/examples/integration/tool/img/logo-header.png +0 -0
  156. package/examples/integration/tool/img/logo-header@2x.png +0 -0
  157. package/examples/integration/tool/img/logo-header@3x.png +0 -0
  158. package/examples/integration/tool/img/logo_project.png +0 -0
  159. package/examples/integration/tool/img/photo-gallery-placeholder.svg +3 -0
  160. package/examples/integration/tool/img/pixel.png +0 -0
  161. package/examples/integration/tool/index.html +228 -0
  162. package/examples/integration/tool/js/demo.js +238 -0
  163. package/examples/integration/tool/js/interface.js +147 -0
  164. package/examples/integration/tool/js/jquery.js +4 -0
  165. package/examples/integration/vanguardia.html +6636 -0
  166. package/examples/multipleIframes/index.js +82 -0
  167. package/examples/multipleIframes/index.php +52 -0
  168. package/examples/serverLess/dist/index.23420cfa.js +2973 -0
  169. package/examples/serverLess/dist/index.23420cfa.js.map +1 -0
  170. package/examples/serverLess/dist/index.91b6cacc.js +2 -0
  171. package/examples/serverLess/dist/index.91b6cacc.js.map +1 -0
  172. package/examples/serverLess/dist/index.html +1 -0
  173. package/examples/serverLess/index.html +39 -0
  174. package/examples/serverLess/main.js +113 -0
  175. package/examples/serverLess/package.json +18 -0
  176. package/examples/serverLess/readme.md +41 -0
  177. package/examples/simple/index.html +1 -1
  178. package/examples/simple/simple.js +63 -65
  179. package/examples/vidromap/index.js +20 -0
  180. package/examples/vidromap/index.php +48 -51
  181. package/flows.md +73 -0
  182. package/package.json +2 -2
  183. package/src/index.js +156 -42
  184. package/src/shared/iframe-communicator.js +12 -5
  185. package/examples/vidromap/vidromap.js +0 -87
package/README.md CHANGED
@@ -1,31 +1,33 @@
1
- # Map Handler #
1
+ # Map Handler
2
2
 
3
- #### Version 1.0.5 - June 2021 #####
3
+ #### Version 1.0.8 - January 2022
4
4
 
5
5
  Tool to achieve the easiest way of communication with the map iframe.
6
6
 
7
- - [Installation](#Installation)
8
- - [Events](#Events)
9
- - [Methods](#Methods)
7
+ - [Installation](#Installation)
8
+ - [Events](#Events)
9
+ - [Methods](#Methods)
10
10
 
11
- ## TL;DR ##
11
+ Some of the multiple use case flows are documented in [flows.md](flows.md)
12
+
13
+ ## TL;DR
12
14
 
13
15
  ```
14
16
  <html>
15
17
  <body>
16
18
  <iframe id="map-frame" name="map-frame" src=""></iframe>
17
19
  <button id="btZoomIn">Zoom In</button>
18
- <script src="https://unpkg.com/@vidro/map-handler@1.0.3/dist/map-handler.js"></script> -->
20
+ <script src="https://unpkg.com/@vidro/map-handler@1.0.5/dist/map-handler.js"></script> -->
19
21
  <script>
20
22
  var loadMapReq = new XMLHttpRequest();
21
23
  loadMapReq.addEventListener("load", function(){
22
24
  communicator = new VidroMaps.Communicator({this.responseText.message.sessionToken});
23
25
  document.querySelector("#map-frame").src = `${this.responseText.message.iframe}?sessionToken=${this.responseText.message.sessionToken}`;
24
-
26
+
25
27
  document.querySelector("#btZoomIn").addEventListener("click", function(){
26
28
  communicator.ZoomIn();
27
29
  });
28
-
30
+
29
31
  }
30
32
  loadMapReq.open("GET", "http://APIURL/map/PROJECT_ID",true);
31
33
  loadMapReq.setRequestHeader('Content-type', 'application/json');
@@ -36,13 +38,13 @@ Tool to achieve the easiest way of communication with the map iframe.
36
38
  </html>
37
39
  ```
38
40
 
39
- ## Installation ##
41
+ ## Installation
40
42
 
41
- ### 0. Pre-requisites ###
43
+ ### 0. Pre-requisites
42
44
 
43
- You should have one iframe already created on the DOM with the attributes `name="map-frame"`.
45
+ You should have one iframe already created on the DOM with the attributes `name="map-frame" id="map-frame"`.
44
46
 
45
- ### 1. Include the library: ###
47
+ ### 1. Include the library:
46
48
 
47
49
  You can do this inyecting directly to window:
48
50
 
@@ -55,8 +57,7 @@ Or if you're working with NPM / ES6:
55
57
  ...
56
58
  import { Communicator } from "@vidro/map-handler";
57
59
 
58
-
59
- ### 2. Instance the communicator with the sessionToken in options object: ###
60
+ ### 2. Instance the communicator with the sessionToken in options object:
60
61
 
61
62
  If you are inyecting into window:
62
63
 
@@ -66,30 +67,48 @@ If you are inyecting into window:
66
67
 
67
68
  Or if you're working with NPM / ES6:
68
69
 
69
- const communicator = new VidroMaps({
70
+ const communicator = new Communicator({
70
71
  sessionToken: "sessionToken"
71
72
  });
72
-
73
73
 
74
- ## Events ##
74
+ ### Logs
75
+
76
+ If you want to see `console.logs`, you can activate logs with `setDebug` method. Once map is loaded, invoke this method. Will create or remove a cookie. After calling `setDebug` reload the map.
75
77
 
76
- ### How to listen ###
78
+ Logs are deactivated by default.
79
+
80
+ `setDebug(debug)`
81
+
82
+ >E.G.
83
+
84
+ ```
85
+ //activate
86
+ setDebug(1);
87
+
88
+ //deactivate
89
+ setDebug(0);
90
+ ```
91
+
92
+ ## Events
93
+
94
+ ### How to listen
77
95
 
78
96
  communicator.on("onZoomChange", function(data){
79
97
  console.log("onZoomChange event",data);
80
98
  });
99
+
81
100
 
82
- ### Available events ###
101
+ ### Available events
83
102
 
84
- ##### onZoomChange #####
103
+ ##### onZoomChange
85
104
 
86
105
  Notifies zoom level changed
87
106
 
88
- ##### geomAdded #####
107
+ ##### geomAdded
89
108
 
90
109
  Notifies geometry added to map, as string
91
110
 
92
- >E.G.
111
+ > E.G.
93
112
 
94
113
  ```
95
114
  POINT(418925 4577135)
@@ -98,65 +117,94 @@ POLYGON((418391.8715694032 4576832.484383419,418721.82301488414 4577299.66760832
98
117
 
99
118
  MULTILINESTRING((419268.8979576373 4577019.482027252,419146.6929889547 4577457.250226778,418798.40365705814 4577415.776056751))
100
119
  ```
120
+ ##### loaded
121
+
122
+ Notifies when map or layers are loaded.
123
+
124
+ There're two types of events:
125
+
126
+ - `map` is dispatched when map (with background) is loaded.
127
+ - `layer` is dispatched when a layer is loaded
128
+
129
+ > `map` E.G:
130
+
131
+ ```
132
+ {what:'map'}
133
+ ```
134
+
135
+ > `layer` E.G:
136
+
137
+ ```
138
+ {what:'layer'
139
+ name:'Arc'}
140
+ ```
101
141
 
102
- ##### layers #####
142
+ ##### layers
103
143
 
104
144
  Notifies an array of displayed layers
105
145
 
106
- ##### geoJSONlayers #####
146
+ ##### geoJSONlayers
107
147
 
108
148
  Notifies an array of displayed GeoJSON layers
109
149
 
110
- ##### activeLayer #####
150
+ ##### activeLayer
111
151
 
112
152
  Notifies wich layer is marked as active
113
153
 
154
+ ##### WMSInfoAvailable
155
+
156
+ Notifies when WMS is available for this map
157
+
158
+ ##### availableWMSLayers
114
159
 
115
- ##### coordinates #####
160
+ List of available layers from WMS server
161
+
162
+ ##### coordinates
116
163
 
117
164
  Notifies clicked coordinates (x,y)
118
165
 
119
166
  First coordinate is X value.
120
167
 
121
- >E.G:
168
+ > E.G:
122
169
 
123
170
  ```
124
171
  {coordinates: (2) [419463.63262834214, 4577166.970846243]
125
172
  type: "coordinates"}
126
173
  ```
127
174
 
128
- ##### info #####
175
+ ##### info
129
176
 
130
177
  Notifies info results. There're 2 availables infos `wms` and `giswater`
131
178
 
132
- >E.G `wms`:
179
+ > E.G `wms`:
133
180
 
134
181
  ```
135
182
  {type: "info", infoType: "wms", data: "<GetFeatureInfoResponse>↵ <Layer name="Incidencia_… </Feature>↵ </Layer>↵</GetFeatureInfoResponse>↵"}
136
183
  ```
137
184
 
138
- >E.G `giswater`:
185
+ > E.G `giswater`:
139
186
 
140
187
  ```
141
188
  {type: "info", infoType: "giswater", data: {…}}
142
189
  ```
143
- ##### geolocation #####
190
+
191
+ ##### geolocation
144
192
 
145
193
  Notifies user position, coordinates (x,y)
146
194
 
147
195
  First coordinate is X value.
148
196
 
149
- >E.G
197
+ > E.G
150
198
 
151
199
  ```
152
200
 
153
201
  {type: "geolocation", coordinates: Array(2)}
154
202
  coordinates: (2) [419297.8249458591, 4576821.519666988]
155
203
  ```
156
- ##### Giswater tiled background #####
157
204
 
158
- Giswater's tiled background has two events, one for notify if is available or not, and a another one for notify if is rendered or not
205
+ ##### Giswater tiled background
159
206
 
207
+ Giswater's tiled background has two events, one for notify if is available or not, and a another one for notify if is rendered or not
160
208
 
161
209
  `giswaterTiledBackgroundAvailable` and `giswaterTiledBackgroundDisplayed`
162
210
 
@@ -166,7 +214,7 @@ Giswater's tiled background has two events, one for notify if is available or no
166
214
  {type: "giswaterTiledBackgroundDisplayed", visible: true/false}
167
215
  ```
168
216
 
169
- ##### Giswater layer Available filters #####
217
+ ##### Giswater layer Available filters
170
218
 
171
219
  List of available filters for a Giswater layer
172
220
 
@@ -175,33 +223,50 @@ List of available filters for a Giswater layer
175
223
 
176
224
  ```
177
225
 
178
- ##### error #####
226
+ ##### error
179
227
 
180
228
  Notifies errors
181
229
 
182
- >E.G.
230
+ > E.G.
183
231
 
184
232
  ```
185
233
  {type: "error", error: "No clicked coordinates"}
186
234
  ```
187
235
 
188
- ## Methods ##
236
+ ## Methods
237
+
238
+ ##### ZoomIn()
239
+
240
+ ##### ZoomOut()
241
+
242
+ ##### zoomToExtent()
243
+
244
+ ##### zoomToCoordinates(coordinates,zoomLevel)
245
+
246
+ Zooms to given coordinates
247
+
248
+ > Params
249
+
250
+ - lat (x) `<integer>`
251
+ - long (y) `<integer>`
252
+ - zoomLevel `<integer>` - zoom level
253
+
254
+ > E.G.
255
+
256
+ ```
257
+ zoomToCoordinates(419006.12985785044, 4576698.8136144625,18);
258
+
259
+ ```
260
+
261
+ ##### AddGeom(string)
189
262
 
190
- ##### ZoomIn() #####
191
-
192
- ##### ZoomOut() #####
193
-
194
- ##### zoomToExtent() #####
195
-
196
- ##### AddGeom(string) #####
197
-
198
263
  Launches drawing tools with the geometry type
199
264
 
200
- >Params
201
-
265
+ > Params
266
+
202
267
  - geom `<string>` - geometry type `Point` | `Line` | `Polygon`
203
268
 
204
- >E.G.
269
+ > E.G.
205
270
 
206
271
  ```
207
272
  AddGeom('Point');
@@ -210,66 +275,98 @@ AddGeom('Line');
210
275
 
211
276
  AddGeom('Polygon');
212
277
  ```
278
+
213
279
  An `geomAdded` event will be received after calling the method.
214
280
 
215
- ##### clear() #####
216
-
281
+ ##### clear()
282
+
217
283
  Clears drawn geometries
218
-
219
- ##### toggleLayer #####
220
-
284
+
285
+ ##### toggleLayer
286
+
221
287
  Shows/hides a layer
222
288
 
223
- >Params
289
+ > Params
224
290
 
225
291
  - layerName `<string>` - layer name
292
+ - properties `<object>` - _optional_ layer properties
293
+ - gutter `<integer>` - The size in pixels of the gutter around image tiles to ignore, only applies for multitile layer
294
+ - singletile `<boolean>` - SingleTile Layer
295
+ - transparent `<boolean>` - Transparent Layer
226
296
 
227
- >E.G.
297
+ By default, layer properties will be:
298
+
299
+ `gutter: 0`
300
+
301
+ `singletile: false` - will render a multitile layer
302
+
303
+ `transparent: true`
304
+
305
+ > E.G.
306
+
307
+ With no properties
228
308
 
229
309
  ```
230
310
  toggleLayer('somelayer_name');
231
311
  ```
232
-
233
- ##### setActiveLayer() #####
312
+
313
+ With properties
314
+
315
+ ```
316
+ toggleLayer('somelayer_name', {gutter: 10, transparent: false, singletile: false);
317
+ ```
318
+
319
+ ##### setActiveLayer()
234
320
 
235
321
  Sets a layer as acticve layer, used for infos
236
322
 
237
- >E.G.
323
+ > E.G.
238
324
 
239
325
  ```
240
326
  setActiveLayer('somelayer_name');
241
327
  ```
242
328
 
243
- ##### reloadDisplayedLayers #####
329
+ ##### reloadDisplayedLayers
244
330
 
245
331
  Reloads displayed layers
246
332
 
247
-
248
- >E.G.
333
+ > E.G.
249
334
 
250
335
  ```
251
336
  reloadDisplayedLayers();
252
337
  ```
253
338
 
254
- ##### infoFromCoordinates #####
339
+ ##### loadWMSAvailableLayers
340
+
341
+ Gets a list of available layers from WMS server
342
+
343
+ > E.G.
344
+
345
+ ```
346
+ loadWMSAvailableLayers();
347
+ ```
348
+
349
+ An `availableWMSLayers ` event will be received after calling the method.
350
+
351
+ ##### infoFromCoordinates
255
352
 
256
353
  There're two available info from coordinates `wms` or `giswater`.
257
354
 
258
355
  **Important** a `click on the map` must be done before calling this method.
259
- If you don't specify a layer, will use the layer setted as `Active layer`
356
+ If you don't specify a layer, will use the layer setted as `Active layer`
357
+
358
+ > Params
260
359
 
261
- >Params
360
+ - type `<string>` - info type
262
361
 
263
- - type `<string>` - info type
362
+ - `wms` - wms info
363
+
364
+ - `giswater` - giswater info
264
365
 
265
- - `wms` - wms info
266
-
267
- - `giswater` - giswater info
268
-
269
366
  - layer `<string>` _optional_ layer name to do info. If null, will use current active layer.
270
367
  - hitTolerance `<integer>` _optional_ for geoJSON Info, pixels inside the radius around the given will be checked for features. Default `5`.
271
368
 
272
- >E.G.
369
+ > E.G.
273
370
 
274
371
  ```
275
372
  infoFromCoordinates('wms'); //will use active layer
@@ -280,15 +377,15 @@ infoFromCoordinates('giswater','Arc');
280
377
 
281
378
  An `info` event will be received after calling the method.
282
379
 
283
- ##### Geolocalize #####
380
+ ##### Geolocalize
284
381
 
285
382
  Geolocalizes user. Will dispatch `geolocation` event .
286
383
 
287
- >Params
384
+ > Params
288
385
 
289
386
  - toggle `<Boolean>` - starts or cancels geolocation
290
387
 
291
- >E.G.
388
+ > E.G.
292
389
 
293
390
  ```
294
391
  //start
@@ -300,7 +397,7 @@ Geolocalize(false)
300
397
 
301
398
  **Important** Add ` allow="geolocation"` to html iframe tag.
302
399
 
303
- ##### Higlight #####
400
+ ##### Higlight
304
401
 
305
402
  Highlights a geometry
306
403
 
@@ -308,28 +405,29 @@ Params
308
405
 
309
406
  - options `<object>` highlight options
310
407
 
311
- - geom `<string>` - geometry string
312
-
313
- - zoom `<object>`
408
+ - geom `<string>` - geometry string
314
409
 
315
- - zoom.type `<string>` - `level | element`
410
+ - zoom `<object>`
316
411
 
317
- _level_ will zoom to zoomLevel
412
+ - zoom.type `<string>` - `level | element`
318
413
 
319
- _element_ geometry center
414
+ _level_ will zoom to zoomLevel
320
415
 
321
- - zoom.zoomLevel `<integer>` 1 to 28
416
+ _element_ geometry center
322
417
 
323
- >E.G.
418
+ - zoom.zoomLevel `<integer>` 1 to 28
324
419
 
420
+ > E.G.
325
421
 
326
422
  ```
327
423
  //Highlight a line and zoom to level 6
328
424
 
329
425
  let options = {
330
426
  'geom': 'MULTILINESTRING((418596.62555076234 4577083.383681167,419026.2319996517 4577216.795306675))',
331
- 'type':'level',
332
- 'zoomLevel':6
427
+ 'zoom':{
428
+ 'type':'level',
429
+ 'zoomLevel':6
430
+ }
333
431
  }
334
432
 
335
433
  Highlight(options);
@@ -338,13 +436,15 @@ Highlight(options);
338
436
 
339
437
  let options = {
340
438
  'geom': 'MULTILINESTRING((418596.62555076234 4577083.383681167,419026.2319996517 4577216.795306675))',
341
- 'type':'element'
439
+ 'zoom':{
440
+ 'type':'element'
441
+ }
342
442
  }
343
443
 
344
444
  Highlight(options);
345
445
  ```
346
446
 
347
- ##### toggleGiswaterTiled #####
447
+ ##### toggleGiswaterTiled
348
448
 
349
449
  Only for Giswater's maps. Toggles tiled background (in case tiled background is configured)
350
450
 
@@ -352,16 +452,14 @@ Params
352
452
 
353
453
  - toggle `<boolean>` shows/hides tiled background
354
454
 
355
-
356
- >E.G.
357
-
455
+ > E.G.
358
456
 
359
457
  ```
360
458
  toggleGiswaterTiled(true);
361
459
 
362
460
  ```
363
461
 
364
- ##### addGeoJSON #####
462
+ ##### addGeoJSON
365
463
 
366
464
  Adds geoJSON layer
367
465
 
@@ -370,13 +468,13 @@ Params
370
468
  - geoJSON `<geoJSON>` geoJSON data
371
469
 
372
470
  - options `<json>` layer options
373
- - fillcolor `<string>` fill color. If null will use red color (#ff0000)
374
- - strokecolor `<string>` strokecolor color. If null will use red color (#ff0000)
375
471
 
376
- - name `<string>` geoJson layer name, if null will use a random string
472
+ - fillcolor `<string>` fill color. If null will use red color (#ff0000)
473
+ - strokecolor `<string>` strokecolor color. If null will use red color (#ff0000)
377
474
 
378
- >E.G.
475
+ - name `<string>` geoJson layer name, if null will use a random string
379
476
 
477
+ > E.G.
380
478
 
381
479
  ```
382
480
  addGeoJSON(geoJSON,options, name);
@@ -392,7 +490,8 @@ const options = {
392
490
  addGeoJSON('GeoJSONContent', options,'name');
393
491
 
394
492
  ```
395
- ##### removeGeoJSONLayer #####
493
+
494
+ ##### removeGeoJSONLayer
396
495
 
397
496
  Removes a GeoJSON Layer
398
497
 
@@ -402,19 +501,17 @@ removeGeoJSONLayer(layerName);
402
501
  removeGeoJSONLayer('somename');
403
502
  ```
404
503
 
405
- ##### clearGeoJSON #####
504
+ ##### clearGeoJSON
406
505
 
407
506
  Clears geoJSON layers
408
507
 
409
-
410
- >E.G.
411
-
508
+ > E.G.
412
509
 
413
510
  ```
414
511
  clearGeoJSON();
415
512
  ```
416
513
 
417
- ##### setGiswaterFilters #####
514
+ ##### setGiswaterFilters
418
515
 
419
516
  Set Giswater's filters for displayed layers
420
517
 
@@ -424,56 +521,167 @@ Filters must be a JSON with valid fields. Available layer filters can be obtaine
424
521
  setGiswaterFilters(JSON);
425
522
  ```
426
523
 
427
- >E.G.
428
-
524
+ > E.G.
429
525
 
430
526
  ```
431
527
  setGiswaterFilters({"expl_id":[1,2,3]});
432
528
  ```
433
529
 
434
- ##### getGiswaterLayerAvailableFilters #####
530
+ ##### getGiswaterLayerAvailableFilters
435
531
 
436
532
  Get available WMTS filters for a Giswater layer
437
533
 
438
-
439
534
  ```
440
535
  getGiswaterLayerAvailableFilters(layername);
441
536
  ```
442
537
 
443
- >E.G.
444
-
538
+ > E.G.
445
539
 
446
540
  ```
447
541
  getGiswaterLayerAvailableFilters("Arc");
448
542
  ```
449
543
 
450
- ## Examples ##
544
+ ##### setCustomColors
545
+
546
+ Sets colors and stroke width for added & highlight geometries.
547
+
548
+ Properties:
549
+
550
+ - `geom_stroke_color` - stroke color in RGB format
551
+ - `geom_fill_color` - fill color in RGB format
552
+ - `geom_stroke_width` - stroke width in pixels, default 1.
553
+ - `geom_shape` - shape por point, `circle`(default) or `square`
554
+ - `radius` - point radius or square side in pixels. Default 4.
555
+
556
+ ```
557
+ setCustomColors({geom_stroke_color, geom_fill_color, geom_stroke_width,geom_shape});
558
+ ```
559
+
560
+ > E.G.
561
+
562
+ ```
563
+ setCustomColors({
564
+ geom_stroke_color: 'rgb(19, 39, 99,0.5)',
565
+ geom_fill_color: 'rgb(19, 39, 99,0.5)',
566
+ geom_stroke_width: 1,
567
+ geom_shape: 'circle',
568
+ radius: 2
569
+ });
570
+ ```
571
+
572
+ On Bmaps projects, default values are taken from Backoffice:
573
+
574
+ ```
575
+ geom_stroke_color -> Bmaps: geom_select_stroke_color
576
+ geom_fill_color -> Bmaps: geom_select_fill_color
577
+ ```
578
+
579
+
580
+
581
+ ### Multiple iframes
582
+
583
+ Is possible to use multiple iframe on a single page, follow this steps.
584
+
585
+ - Set to your `iframe` tags the id & value
586
+ - Add to each `iframe.src` `&domId=IFRAME_ID`
587
+ - Instantiate each iframe:
588
+
589
+ ```
590
+ var communicator = new VidroMaps.Communicator({
591
+ sessionToken: sessionToken,
592
+ id:'IFRAME_ID'
593
+ });
594
+ ```
595
+
596
+ ## Examples
451
597
 
452
- ### Simple ###
598
+ ### Simple
453
599
 
454
- `examples/simple/`
600
+ `examples/simple/`
455
601
 
456
602
  A simple integration with just zoom buttons
457
603
 
458
- ##### How it works #####
604
+ ##### How it works
459
605
 
460
606
  1. Gets user, password and API url from the url
461
607
  2. Request a user token to the API
462
608
  3. Loads the first map of the user
463
609
 
464
- [http://www.vidrosoftware.com/examples/simple/?user=USER&pwd=USER_PASWORD&api=API_URL]()
465
-
610
+ [https://www.vidrosoftware.com/examples/simple/?user=USER&pwd=USER_PASWORD&api=API_URL]()
466
611
 
467
- ### Full ###
612
+ ### Full
468
613
 
469
- `examples/full/`
614
+ `examples/full/`
470
615
 
471
616
  Full integration
472
617
 
473
- ##### How it works #####
618
+ ##### How it works
474
619
 
475
620
  1. User, password and API url are defined on the html form
476
621
  2. Stores token and last map loaded in a fake cache
477
622
  3. There's a form for choosing map and customize map parameters
478
623
 
479
- [http://www.vidrosoftware.com/examples/full/]()
624
+ [https://www.vidrosoftware.com/examples/full/]()
625
+
626
+ ### Vidromaps
627
+
628
+ `examples/vidromaps/`
629
+
630
+ Vidromaps integration
631
+
632
+ ##### How it works
633
+
634
+ 1. Paste iframe code
635
+
636
+ [https://www.vidrosoftware.com/examples/vidromaps/]()
637
+
638
+ ### Serverless
639
+
640
+ `examples/serveLess/`
641
+
642
+ Server less sample integration
643
+
644
+ ##### How it works
645
+
646
+ 1. Gets user, password and API url from the url
647
+ 2. Request a user token to the API
648
+ 3. Loads the first map of the user with one layer rendered
649
+ 4. On map click, performs an wms info, displays one attribute, highlights the clicked point and centers map on that point
650
+
651
+ ### Mutiple iframes
652
+
653
+ `examples/multipleiframes/`
654
+
655
+ Multiple iframes integration
656
+
657
+ ##### How it works
658
+
659
+ 1. Replace `YOUR_SESSION_TOKEN` with your session token code on both inputs `code1` and `code2`.
660
+
661
+ [https://www.vidrosoftware.com/examples/multipleiframes/]()
662
+
663
+ ### Known issues
664
+
665
+ - **Custom logo is not displayed**
666
+
667
+ Could be CORS issue. Check the headers sent by your server.
668
+
669
+ With Apache can be solved with and `.htaccess` file with this content:
670
+
671
+ ```
672
+ Header set Access-Control-Allow-Origin "*"
673
+ Header add Cross-Origin-Resource-Policy: "cross-origin"
674
+ Header add Cross-Origin-Embedder-Policy: "require-corp"
675
+ ```
676
+
677
+ - **QGIS Broken symbology**
678
+
679
+ QGIS multi tile layers could show broken symbology:
680
+
681
+ ![](doc/multiTileNoGutter.png)
682
+
683
+ This can be solved using `singletile: true` or adding `gutter: value in pixels` if is a multitiule layer, on toggleLayer method.
684
+
685
+ Is if is a Giswwater project, you can set this options (`Render mode` and `Gutter`) on Bmaps backoffice.
686
+
687
+ ![](doc/multiTile.png)