@vidro/map-handler 1.2.10 → 1.2.19
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.
- package/README.md +442 -32
- package/dist/map-handler.js +1 -1
- package/doc/animation.png +0 -0
- package/doc/confirmComponent.png +0 -0
- package/examples/full/apidemo.js +46 -43
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/cachedTokenData.dat +1 -1
- package/examples/full/docker/Docker_compose.yml +14 -0
- package/examples/full/docker/Dockerfile +27 -0
- package/examples/full/index.php +5 -4
- package/examples/full/tester.css +74 -0
- package/examples/full/tester.js +2 -2
- package/examples/react-next/README.md +282 -0
- package/examples/react-next/components/AuthComponent.js +88 -0
- package/examples/react-next/components/MapButtons.js +161 -0
- package/examples/react-next/components/MapFilters.js +120 -0
- package/examples/react-next/components/MapIframe.js +25 -0
- package/examples/react-next/components/MapInfo.js +36 -0
- package/examples/react-next/components/MapLayers.js +60 -0
- package/examples/react-next/components/MapList.js +43 -0
- package/examples/react-next/contexts/auth.js +101 -0
- package/examples/react-next/contexts/maps.js +158 -0
- package/examples/react-next/contexts/messages.js +340 -0
- package/examples/react-next/env.sample +3 -0
- package/examples/react-next/eslint.config.mjs +14 -0
- package/examples/react-next/hooks/useMapEvents.js +118 -0
- package/examples/react-next/jsconfig.json +7 -0
- package/examples/react-next/next.config.mjs +6 -0
- package/examples/react-next/package.json +24 -0
- package/examples/react-next/pages/_app.js +5 -0
- package/examples/react-next/pages/index.js +87 -0
- package/examples/react-next/postcss.config.mjs +8 -0
- package/examples/react-next/public/discord.svg +8 -0
- package/examples/react-next/public/favicon.ico +0 -0
- package/examples/react-next/public/file.svg +1 -0
- package/examples/react-next/public/logo.png +0 -0
- package/examples/react-next/public/next.svg +1 -0
- package/examples/react-next/shared/constants.js +47 -0
- package/examples/react-next/styles/globals.css +24 -0
- package/examples/react-next/tailwind.config.mjs +17 -0
- package/helpers.md +45 -0
- package/package.json +1 -1
- package/src/index.js +305 -20
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Map Handler
|
2
2
|
|
3
|
-
#### Version 1.
|
3
|
+
#### Version 1.2.180 - February 2025
|
4
4
|
|
5
5
|
Tool to achieve the easiest way of communication with the map iframe.
|
6
6
|
|
@@ -99,22 +99,51 @@ setDebug(0);
|
|
99
99
|
|
100
100
|
### Available events
|
101
101
|
|
102
|
+
### Available Events
|
103
|
+
|
102
104
|
##### onZoomChange
|
103
105
|
|
104
|
-
|
106
|
+
The `onZoomChange` event is triggered whenever the zoom level of the map changes. This event provides detailed metadata about the new zoom state, including the current zoom level, map extent, resolution, and scale.
|
105
107
|
|
106
|
-
##### geomAdded
|
107
108
|
|
108
|
-
Notifies geometry added to map, as string
|
109
109
|
|
110
|
-
|
110
|
+
The event returns an object with the following properties:
|
111
|
+
|
112
|
+
| Property | Type | Description |
|
113
|
+
|-------------|--------|-------------|
|
114
|
+
| `type` | string | The event type, always `"onZoomChange"`. |
|
115
|
+
| `zoom` | number | The current zoom level after the change. |
|
116
|
+
| `maxZoom` | number | The maximum zoom level allowed in the map. |
|
117
|
+
| `minZoom` | number | The minimum zoom level allowed in the map. |
|
118
|
+
| `extent` | array | The map extent after zooming, represented as `[minX, minY, maxX, maxY]`. |
|
119
|
+
| `resolution` | number | The resolution of the map at the current zoom level. |
|
120
|
+
| `scale` | string | The approximate scale of the map in the format `"1:xxxx"`. |
|
111
121
|
|
122
|
+
|
123
|
+
```
|
124
|
+
{
|
125
|
+
"type": "onZoomChange",
|
126
|
+
"zoom": 15.035190437015496,
|
127
|
+
"maxZoom": 25,
|
128
|
+
"minZoom": 0,
|
129
|
+
"extent": [448455.99940588913, 4595273.644846473, 456909.8853950997, 4602082.14362973],
|
130
|
+
"resolution": 4.656975911940399,
|
131
|
+
"scale": "1:17600"
|
132
|
+
}
|
112
133
|
```
|
113
|
-
POINT(418925 4577135)
|
114
134
|
|
115
|
-
|
135
|
+
##### geomAdded
|
136
|
+
|
137
|
+
Notifies geometry added to map and featureId
|
116
138
|
|
117
|
-
|
139
|
+
When this tool is used, NO geom is added when drawing finishes. In case you want to add it, use `Highlight` tool
|
140
|
+
|
141
|
+
> E.G.
|
142
|
+
|
143
|
+
```
|
144
|
+
geom_astext: "POLYGON((418391.8715694032 4576832.484383419,418721.82301488414 4577299.667608328,418727.18131229794 4576947.724919814,418391.8715694032 4576832.484383419))"
|
145
|
+
featureId: "uuid of geometry added'
|
146
|
+
srid: 'EPSG:25831'
|
118
147
|
```
|
119
148
|
|
120
149
|
##### loaded
|
@@ -125,8 +154,10 @@ There're two types of events:
|
|
125
154
|
|
126
155
|
- `map` is dispatched when map (with background) is loaded.
|
127
156
|
- `layer` is dispatched when a layer is loaded
|
157
|
+
- `zIndex`: layer z-index
|
128
158
|
- `tiled` is dispatched when a tiled is loaded
|
129
159
|
|
160
|
+
|
130
161
|
> `map` E.G:
|
131
162
|
|
132
163
|
```
|
@@ -137,7 +168,8 @@ There're two types of events:
|
|
137
168
|
|
138
169
|
```
|
139
170
|
{what:'layer'
|
140
|
-
name:'Arc'
|
171
|
+
name:'Arc'
|
172
|
+
zIndex:998}
|
141
173
|
```
|
142
174
|
|
143
175
|
##### unloaded
|
@@ -182,14 +214,19 @@ Formatted Layers TOC (table of contents)
|
|
182
214
|
|
183
215
|
##### coordinates
|
184
216
|
|
185
|
-
Notifies clicked coordinates (x,y)
|
217
|
+
Notifies clicked coordinates (x,y), a BBOX in WKT and map srid
|
218
|
+
|
219
|
+
BBOX by default is a 20m box. You can customize this value with method `setBboxSize`
|
186
220
|
|
187
221
|
First coordinate is X value.
|
188
222
|
|
189
223
|
> E.G:
|
190
224
|
|
191
225
|
```
|
192
|
-
{
|
226
|
+
{
|
227
|
+
coordinates: (2) [419463.63262834214, 4577166.970846243],
|
228
|
+
bbox: "POLYGON((452249.04604797193 4599115.704682493,452254.04604797193 4599115.704682493,452254.04604797193 4599120.704682493,452249.04604797193 4599120.704682493,452249.04604797193 4599115.704682493))",
|
229
|
+
srid: "EPSG:25831",
|
193
230
|
type: "coordinates"}
|
194
231
|
```
|
195
232
|
|
@@ -266,6 +303,32 @@ Notifies errors
|
|
266
303
|
|
267
304
|
Notifies map status, as tiled loaded, background visible, etc..
|
268
305
|
|
306
|
+
##### hover
|
307
|
+
|
308
|
+
When user puts mouse pointer over a feauture for more than 1 second, a `hover` event is dispatched.
|
309
|
+
|
310
|
+
If is no hover any feature event is dispatched with `feature:null`
|
311
|
+
|
312
|
+
|
313
|
+
> E.G
|
314
|
+
|
315
|
+
```
|
316
|
+
|
317
|
+
{type: "hover", feature: {'property':'somevalue',...}
|
318
|
+
```
|
319
|
+
|
320
|
+
##### screenshot <a id="screenshot-event"></a>
|
321
|
+
|
322
|
+
This feature provides screenshot data, encoded as a PNG in Base64 format.
|
323
|
+
|
324
|
+
|
325
|
+
> E.G
|
326
|
+
|
327
|
+
```
|
328
|
+
|
329
|
+
{type: "screenshot", content: 'png in base64'
|
330
|
+
```
|
331
|
+
|
269
332
|
## Methods
|
270
333
|
|
271
334
|
##### ZoomIn()
|
@@ -290,7 +353,26 @@ Zooms to given coordinates
|
|
290
353
|
zoomToCoordinates(419006.12985785044, 4576698.8136144625,18);
|
291
354
|
|
292
355
|
```
|
293
|
-
|
356
|
+
|
357
|
+
##### zoomToGeometry
|
358
|
+
|
359
|
+
Zooms to a given geometry
|
360
|
+
|
361
|
+
> Params
|
362
|
+
|
363
|
+
- geom `<string>` WKT geometry
|
364
|
+
- limits `<json>` max/min zoom level
|
365
|
+
- max `<integer>`
|
366
|
+
- min `<integer>`
|
367
|
+
|
368
|
+
> E.G.
|
369
|
+
|
370
|
+
```
|
371
|
+
zoomToCoordinates(419006.12985785044, 4576698.8136144625,18);
|
372
|
+
|
373
|
+
```
|
374
|
+
|
375
|
+
##### zoomToGeometry(lat,long)
|
294
376
|
|
295
377
|
center map to given coordinates
|
296
378
|
|
@@ -305,6 +387,34 @@ center map to given coordinates
|
|
305
387
|
CenterMap(419006.12985785044, 4576698.8136144625,18);
|
306
388
|
|
307
389
|
```
|
390
|
+
##### zoomToScale(scale)
|
391
|
+
|
392
|
+
Sets the zoom level to a specified scale.
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
> **Allowed Scales:**
|
397
|
+
|
398
|
+
- `1:100`
|
399
|
+
- `1:200`
|
400
|
+
- `1:400`
|
401
|
+
- `1:500`
|
402
|
+
- `1:1000`
|
403
|
+
- `1:2000`
|
404
|
+
- `1:5000`
|
405
|
+
- `1:10000`
|
406
|
+
- `1:50000`
|
407
|
+
|
408
|
+
> Params
|
409
|
+
|
410
|
+
- **`scale`** `<string>` - The scale to set the zoom level.
|
411
|
+
|
412
|
+
|
413
|
+
E.G:
|
414
|
+
|
415
|
+
```javascript
|
416
|
+
zoomToScale('1:100');
|
417
|
+
```
|
308
418
|
|
309
419
|
|
310
420
|
##### AddGeom(string)
|
@@ -315,6 +425,32 @@ Launches drawing tools with the geometry type
|
|
315
425
|
|
316
426
|
- geom `<string>` - geometry type `Point` | `Line` | `Polygon`
|
317
427
|
|
428
|
+
Optional parameters
|
429
|
+
|
430
|
+
- `texts` (`object`): Texts to be displayed with draw tools.
|
431
|
+
- `start` (`string`): E.G. "Click to start drawing"
|
432
|
+
- `continnue`:(`string`): E.G. "Click to to continue drawing"
|
433
|
+
- `center` (`object`): Center options.
|
434
|
+
- `style` (`object`):
|
435
|
+
- `fill` (`string`): The fill color for the drawn geometry.
|
436
|
+
- `stroke` (`string`): The stroke color for the drawn geometry.
|
437
|
+
- `drawOnEnd` (`boolean`): Is is set to `false` geometry will not be added on end drawing. The event with the drawn geometry will still be emitted
|
438
|
+
- `showConfirm` (`boolean`): show or hide component for end drawing. If is set to false, `CancelAddGeom()` must be handled by the user.
|
439
|
+
|
440
|
+
Confirm component:
|
441
|
+

|
442
|
+
|
443
|
+
#### CancelAddGeom
|
444
|
+
|
445
|
+
Cancels draw geometry
|
446
|
+
|
447
|
+
> E.G.
|
448
|
+
|
449
|
+
```
|
450
|
+
CancelAddGeom();
|
451
|
+
|
452
|
+
```
|
453
|
+
|
318
454
|
> E.G.
|
319
455
|
|
320
456
|
```
|
@@ -323,17 +459,56 @@ AddGeom('Point');
|
|
323
459
|
AddGeom('Line');
|
324
460
|
|
325
461
|
AddGeom('Polygon');
|
462
|
+
|
463
|
+
//Draw polygon with no showConfirm
|
464
|
+
AddGeom('Polygon', {showConfirm: false});
|
326
465
|
```
|
327
466
|
|
328
467
|
An `geomAdded` event will be received after calling the method.
|
329
468
|
|
469
|
+
##### addIcon(icon,coordinates)
|
470
|
+
|
471
|
+
Add an icon on a given coordinates
|
472
|
+
|
473
|
+
> Params
|
474
|
+
|
475
|
+
- icon `<ArrayBuffer>` - The binary data of the icon image, typically obtained by converting an image file (e.g., PNG) to an `ArrayBuffer`. This should represent the visual marker to be displayed on the map.
|
476
|
+
- coordintes `<array>` - An array specifying the location where the icon should be added. Format: `[longitude, latitude]`. Ensure the coordinates are in the same SRID (Spatial Reference Identifier) as the map being used (e.g., EPSG:4326 for geographic coordinates). Transform the coordinates if necessary before passing them to this method.
|
477
|
+
|
478
|
+
```
|
479
|
+
|
480
|
+
// Fetch and process the image as binary data
|
481
|
+
const iconBinaryData = convert to binary method (`path/images/icons/anIcon.png`);
|
482
|
+
|
483
|
+
addIcon(iconBinaryData, [2, 4.6]);
|
484
|
+
|
485
|
+
```
|
486
|
+
[ArrayBuffer conversion examples](helpers.md)
|
487
|
+
|
488
|
+
|
489
|
+
##### setBboxSize
|
490
|
+
|
491
|
+
Set the BBOX size of clicked coordinates. When the receives a click events, calculates an bounding box of bboxsize meters.
|
492
|
+
|
493
|
+
> E.G.
|
494
|
+
|
495
|
+
```
|
496
|
+
setBboxSize(5); //set a bbox of 5 meters
|
497
|
+
```
|
498
|
+
|
330
499
|
##### clear()
|
331
500
|
|
332
501
|
Clears drawn geometries
|
333
502
|
|
334
503
|
##### toggleLayer
|
335
504
|
|
336
|
-
Shows/hides a layer
|
505
|
+
Shows/hides a layer.
|
506
|
+
|
507
|
+
**\*Important**
|
508
|
+
|
509
|
+
This method loads a single layer. If you need to load multiple layers, use `loadMultipleLayers()` method
|
510
|
+
|
511
|
+
If ypu need to load multiple layers
|
337
512
|
|
338
513
|
> Params
|
339
514
|
|
@@ -342,6 +517,7 @@ Shows/hides a layer
|
|
342
517
|
- gutter `<integer>` - The size in pixels of the gutter around image tiles to ignore, only applies for multitile layer
|
343
518
|
- singletile `<boolean>` - SingleTile Layer
|
344
519
|
- transparent `<boolean>` - Transparent Layer
|
520
|
+
- type `<string>` - layer type (wms, geojson...)
|
345
521
|
|
346
522
|
By default, layer properties will be:
|
347
523
|
|
@@ -365,6 +541,20 @@ With properties
|
|
365
541
|
toggleLayer('somelayer_name', {gutter: 10, transparent: false, singletile: false);
|
366
542
|
```
|
367
543
|
|
544
|
+
##### toggleGroup
|
545
|
+
|
546
|
+
Toggles (show/hide) a list of layers. Layers must be loaded before with `loadMultipleLayers`
|
547
|
+
|
548
|
+
- ## layers `<array>`:
|
549
|
+
|
550
|
+
##### loadMultipleLayers()
|
551
|
+
|
552
|
+
Loads multiple layers. Use this method if you want to load multiple layers.
|
553
|
+
|
554
|
+
> Params
|
555
|
+
|
556
|
+
- layers `<array>`: array of layers, each layer with same proerties than `toggleLayer` method.
|
557
|
+
|
368
558
|
##### setActiveLayer()
|
369
559
|
|
370
560
|
Sets a layer as acticve layer, used for infos
|
@@ -375,6 +565,27 @@ Sets a layer as acticve layer, used for infos
|
|
375
565
|
setActiveLayer('somelayer_name');
|
376
566
|
```
|
377
567
|
|
568
|
+
##### removeLayer(layer_name)
|
569
|
+
|
570
|
+
Removes a layer
|
571
|
+
|
572
|
+
> E.G.
|
573
|
+
|
574
|
+
```
|
575
|
+
removeLayer('somelayer_name');
|
576
|
+
```
|
577
|
+
|
578
|
+
##### displayLayer(layer_name)
|
579
|
+
|
580
|
+
Displays a layer
|
581
|
+
|
582
|
+
> E.G.
|
583
|
+
|
584
|
+
```
|
585
|
+
displayLayer('somelayer_name');
|
586
|
+
```
|
587
|
+
|
588
|
+
|
378
589
|
##### reloadDisplayedLayers
|
379
590
|
|
380
591
|
Reloads displayed layers
|
@@ -397,6 +608,34 @@ loadWMSAvailableLayers();
|
|
397
608
|
|
398
609
|
An `availableWMSLayers ` event will be received after calling the method.
|
399
610
|
|
611
|
+
##### bringLayerToTop
|
612
|
+
|
613
|
+
> Params
|
614
|
+
|
615
|
+
- layer_name `<string>`: layer name
|
616
|
+
|
617
|
+
Brings layer to top.
|
618
|
+
|
619
|
+
> E.G.
|
620
|
+
|
621
|
+
```
|
622
|
+
bringLayerToTop('somelayer_name');
|
623
|
+
```
|
624
|
+
|
625
|
+
##### bringLayerToBottom
|
626
|
+
|
627
|
+
> Params
|
628
|
+
|
629
|
+
- layer_name `<string>`: layer name
|
630
|
+
|
631
|
+
Brings layer to bottom.
|
632
|
+
|
633
|
+
> E.G.
|
634
|
+
|
635
|
+
```
|
636
|
+
bringLayerToBottom('somelayer_name');
|
637
|
+
```
|
638
|
+
|
400
639
|
##### getToc
|
401
640
|
|
402
641
|
Gets a formatted Layers TOC (Table of contents)
|
@@ -466,12 +705,15 @@ Geolocalizes user. Will dispatch `geolocation` event .
|
|
466
705
|
> Params
|
467
706
|
|
468
707
|
- toggle `<Boolean>` - starts or cancels geolocation
|
708
|
+
- options `<json>` - optional
|
709
|
+
- track `<Boolean>` - will track user position or geolocalize only once
|
469
710
|
|
470
711
|
> E.G.
|
471
712
|
|
472
713
|
```
|
473
714
|
//start
|
474
715
|
Geolocalize(true)
|
716
|
+
Geolocalize(true, {track:true})
|
475
717
|
|
476
718
|
//cancel
|
477
719
|
Geolocalize(false)
|
@@ -481,23 +723,38 @@ Geolocalize(false)
|
|
481
723
|
|
482
724
|
##### Higlight
|
483
725
|
|
484
|
-
Highlights a geometry
|
726
|
+
Highlights & draws a geometry. Allows animation and zoom to element.
|
727
|
+
If you want to draw a geom, just use `DrawGeometries` method
|
485
728
|
|
486
729
|
Params
|
487
730
|
|
488
|
-
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
731
|
+
- `geom` (`string`): The geometry string in WKT to highlight.
|
732
|
+
|
733
|
+
Optional parameters
|
734
|
+
|
735
|
+
- `zoom` (`object`): Zoom options.
|
736
|
+
- `type` (`string`): The type of zoom (`level` or `element`).
|
737
|
+
- `level`: Zoom to a specific zoom level.
|
738
|
+
- `element`: Zoom to the center of the geometry.
|
739
|
+
- `zoomLevel` (`number`, optional): The zoom level (1 to 28). Required if `type` is set to `level`.
|
740
|
+
- `center` (`object`): Center options.
|
741
|
+
- `false` will not center map to element
|
742
|
+
- `1` will center always map to element
|
743
|
+
- `2` will center element only if is outside current view extent
|
744
|
+
- `data` (`object`): Additional data associated with the highlight.
|
745
|
+
- `feautureId` (`string`): The ID of the feature.
|
746
|
+
- `name` (`string`): The name of the feature.
|
747
|
+
- ... any extra data will be added to feature
|
748
|
+
- style (`object`): geometry styling options
|
749
|
+
- `fill` (`string`): The fill color for the highlighted geometry.
|
750
|
+
- `stroke` (`string`): The stroke color for the highlighted geometry.
|
751
|
+
- `animate` (`boolean`): Indicates whether to animate the highlight.
|
752
|
+
- `duration`: time of the animation in milliseconds
|
753
|
+
- `repeat`: true/false for repeteating animation
|
754
|
+
|
755
|
+
Example of animation
|
756
|
+
|
757
|
+

|
501
758
|
|
502
759
|
> E.G.
|
503
760
|
|
@@ -526,6 +783,120 @@ let options = {
|
|
526
783
|
Highlight(options);
|
527
784
|
```
|
528
785
|
|
786
|
+
##### DrawGeometry - DEPRECATED
|
787
|
+
|
788
|
+
**use `DrawGeometries`**
|
789
|
+
|
790
|
+
Draws a single geometry, in case you want to draw multiple geometries simultaneusly use `DrawGeometries ` method
|
791
|
+
|
792
|
+
> E.G.
|
793
|
+
|
794
|
+
```
|
795
|
+
//Draw a geometry with yellow stroke
|
796
|
+
|
797
|
+
const geom = 'MULTILINESTRING((418596.62555076234 4577083.383681167,419026.2319996517 4577216.795306675))'
|
798
|
+
|
799
|
+
const style = {
|
800
|
+
stroke_color: "rgb(233, 244, 75)"
|
801
|
+
}
|
802
|
+
}
|
803
|
+
|
804
|
+
DrawGeometry(geom,style,'sampleName','mockId');
|
805
|
+
|
806
|
+
```
|
807
|
+
|
808
|
+
##### DrawGeometries
|
809
|
+
|
810
|
+
Draws geometries
|
811
|
+
|
812
|
+
> Params
|
813
|
+
|
814
|
+
- geoms `<array>`:
|
815
|
+
- item `<object>`:
|
816
|
+
- geom `<string>` - geometry string
|
817
|
+
- style `<object>`
|
818
|
+
- stroke_color `<string>`
|
819
|
+
- fill_color `<string>`
|
820
|
+
- geom_radius `<integer>`
|
821
|
+
- stroke_width `<integer>`
|
822
|
+
- font_color `<string>`
|
823
|
+
- font `<string>`
|
824
|
+
- placement `<string>`
|
825
|
+
- fontFillColor `<string>`
|
826
|
+
- fontStrokeColor `<string>`
|
827
|
+
- display `<string>`
|
828
|
+
- fontStrokeWidth `<integer>`
|
829
|
+
- offsetY `<integer>`
|
830
|
+
- baseline `<string>`
|
831
|
+
- align `<string>`
|
832
|
+
- name `<string>` feauture name
|
833
|
+
- id `<string>` feauture id
|
834
|
+
|
835
|
+
> E.G.
|
836
|
+
|
837
|
+
```
|
838
|
+
//Draw a geometry with yellow stroke
|
839
|
+
|
840
|
+
const geom = 'MULTILINESTRING((418596.62555076234 4577083.383681167,419026.2319996517 4577216.795306675))'
|
841
|
+
|
842
|
+
const style = {
|
843
|
+
stroke_color: "rgb(233, 244, 75)"
|
844
|
+
}
|
845
|
+
}
|
846
|
+
const item = {geom,style,'sampleName','mockId'};
|
847
|
+
DrawGeometries([item]);
|
848
|
+
```
|
849
|
+
|
850
|
+
##### RemoveGeometry
|
851
|
+
|
852
|
+
Removes a geometry by ID
|
853
|
+
|
854
|
+
Params
|
855
|
+
|
856
|
+
- id `<string>` - rendered geometry unique
|
857
|
+
- layer `<string>` - layer name, optional
|
858
|
+
|
859
|
+
> E.G.
|
860
|
+
|
861
|
+
```
|
862
|
+
RemoveGeometry('25', 'somlayer')
|
863
|
+
```
|
864
|
+
|
865
|
+
##### RemoveGeometriesByProperty
|
866
|
+
|
867
|
+
Removes geometries by property value
|
868
|
+
|
869
|
+
Params
|
870
|
+
|
871
|
+
- layer `<string>` - layer name, optional
|
872
|
+
- property `<string>` - property name
|
873
|
+
- value - property value
|
874
|
+
|
875
|
+
> E.G.
|
876
|
+
|
877
|
+
```
|
878
|
+
RemoveGeometriesByProperty( 'somlayer','type','something')
|
879
|
+
```
|
880
|
+
|
881
|
+
##### UpdateGeometriesByProperty
|
882
|
+
|
883
|
+
Update geometry style based on property value
|
884
|
+
|
885
|
+
Params
|
886
|
+
|
887
|
+
- layer `<string>` - layer name, optional
|
888
|
+
- property `<string>` - property name
|
889
|
+
- value - property value
|
890
|
+
- style `<object>` - stroke_color `<string>` - fill_color `<string>` - geom_radius `<integer>` - stroke_width `<integer>` - font_color `<string>` - font `<string>` - placement `<string>` - fontFillColor `<string>` - fontStrokeColor `<string>` - display `<string>` - fontStrokeWidth `<integer>` - offsetY `<integer>` - baseline `<string>` - align `<string>`
|
891
|
+
|
892
|
+
> E.G.
|
893
|
+
|
894
|
+
```
|
895
|
+
UpdateGeometriesByProperty( 'somlayer','type','something',{
|
896
|
+
stroke_color: "rgb(255, 0, 0)"}
|
897
|
+
)
|
898
|
+
```
|
899
|
+
|
529
900
|
##### toggleTiled
|
530
901
|
|
531
902
|
Deprecated `toggleGiswaterTiled`
|
@@ -546,14 +917,12 @@ toggleTiled(true);
|
|
546
917
|
|
547
918
|
##### toggleSecondaryBackground
|
548
919
|
|
549
|
-
|
550
920
|
Toggles secondary background (in case secondary background is configured)
|
551
921
|
|
552
922
|
Params
|
553
923
|
|
554
924
|
- toggle `<boolean>` shows/hides secondary background
|
555
925
|
|
556
|
-
|
557
926
|
> E.G.
|
558
927
|
|
559
928
|
```
|
@@ -561,7 +930,6 @@ toggleSecondaryBackground(true);
|
|
561
930
|
|
562
931
|
```
|
563
932
|
|
564
|
-
|
565
933
|
##### addGeoJSON
|
566
934
|
|
567
935
|
Adds geoJSON layer
|
@@ -615,13 +983,23 @@ clearGeoJSON();
|
|
615
983
|
```
|
616
984
|
|
617
985
|
##### setFilters
|
618
|
-
Deprecated `setGiswaterFilters`
|
619
986
|
|
987
|
+
Deprecated `setGiswaterFilters`
|
620
988
|
|
621
989
|
Set filters for displayed layers
|
622
990
|
|
623
991
|
Filters must be a JSON with valid fields. On Giswater/QGIS projects, available layer filters can be obtained with method `getGiswaterLayerAvailableFilters`
|
624
992
|
|
993
|
+
Each filter must have this format:
|
994
|
+
|
995
|
+
- layer_id <integer>
|
996
|
+
- layer*name <string> - *`qgis_name` property\_
|
997
|
+
- filters: <array>
|
998
|
+
- name <string>: field name
|
999
|
+
- condition <string>: `=`,`!=`,`<`,`>`,`<=`,`>=`,`in`,`between`
|
1000
|
+
- value: value to be filtered
|
1001
|
+
- value2: second value, only for `between` conditions
|
1002
|
+
|
625
1003
|
```
|
626
1004
|
setFilters(JSON);
|
627
1005
|
```
|
@@ -629,7 +1007,32 @@ setFilters(JSON);
|
|
629
1007
|
> E.G.
|
630
1008
|
|
631
1009
|
```
|
632
|
-
setFilters(
|
1010
|
+
setFilters([
|
1011
|
+
{
|
1012
|
+
layer_id: 1,
|
1013
|
+
layer_name: "mylayer",
|
1014
|
+
filters: [
|
1015
|
+
{
|
1016
|
+
name: 'exp_id',
|
1017
|
+
condition: 'in',
|
1018
|
+
value: "'1','4'",
|
1019
|
+
value2: null
|
1020
|
+
},
|
1021
|
+
{
|
1022
|
+
name: 'status',
|
1023
|
+
condition: '=',
|
1024
|
+
value: 'active',
|
1025
|
+
value2: null
|
1026
|
+
},
|
1027
|
+
{
|
1028
|
+
name: 'anotherField',
|
1029
|
+
condition: 'between',
|
1030
|
+
value: '100',
|
1031
|
+
value2: '200'
|
1032
|
+
}
|
1033
|
+
]
|
1034
|
+
}
|
1035
|
+
]);
|
633
1036
|
```
|
634
1037
|
|
635
1038
|
##### getGiswaterLayerAvailableFilters
|
@@ -715,6 +1118,13 @@ Stop measure tools
|
|
715
1118
|
cancelMeasure();
|
716
1119
|
```
|
717
1120
|
|
1121
|
+
##### screenshot
|
1122
|
+
|
1123
|
+
Will do an screenshot of the current map encoded as a PNG in Base64 format. Result will be encapsulated [`screenshot`](#screenshot-event)
|
1124
|
+
|
1125
|
+
```
|
1126
|
+
screenshot({});
|
1127
|
+
```
|
718
1128
|
### Multiple iframes
|
719
1129
|
|
720
1130
|
Is possible to use multiple iframe on a single page, follow this steps.
|