@vidro/map-handler 1.3.14 → 2.0.0
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 +67 -1
- package/map-handler.d.ts +134 -0
- package/package.json +10 -4
- package/src/types.d.ts +63 -0
- package/.babelrc +0 -6
- package/doc/animation.png +0 -0
- package/doc/confirmComponent.png +0 -0
- package/doc/giswater.png +0 -0
- package/doc/giswaterInfo.png +0 -0
- package/doc/giswaterInfoApi.png +0 -0
- package/doc/giswatergeojson.png +0 -0
- package/doc/multiTile.png +0 -0
- package/doc/multiTileNoGutter.png +0 -0
- package/doc/togglelayergiswater.png +0 -0
- package/doc/vidromaps-basic.png +0 -0
- package/examples/full/apidemo.js +0 -387
- package/examples/full/cachedToken.dat +0 -1
- package/examples/full/cachedTokenData.dat +0 -1
- package/examples/full/docker/Docker_compose.yml +0 -14
- package/examples/full/docker/Dockerfile +0 -27
- package/examples/full/index.php +0 -200
- package/examples/full/storeToken.php +0 -6
- package/examples/full/tester.css +0 -74
- package/examples/full/tester.js +0 -658
- package/examples/multipleIframes/index.js +0 -82
- package/examples/multipleIframes/index.php +0 -52
- package/examples/react-next/README.md +0 -282
- package/examples/react-next/atoms/PrintLayoutSelector.js +0 -51
- package/examples/react-next/atoms/PrintPaperSizeSelector.js +0 -49
- package/examples/react-next/atoms/PrintScaleSelector.js +0 -61
- package/examples/react-next/atoms/ZoomToScaleButton.js +0 -57
- package/examples/react-next/components/AuthComponent.js +0 -88
- package/examples/react-next/components/MapButtons.js +0 -108
- package/examples/react-next/components/MapFilters.js +0 -120
- package/examples/react-next/components/MapIframe.js +0 -25
- package/examples/react-next/components/MapInfo.js +0 -36
- package/examples/react-next/components/MapLayers.js +0 -60
- package/examples/react-next/components/MapList.js +0 -51
- package/examples/react-next/components/MapPrint.js +0 -50
- package/examples/react-next/contexts/auth.js +0 -147
- package/examples/react-next/contexts/maps.js +0 -185
- package/examples/react-next/contexts/messages.js +0 -358
- package/examples/react-next/contexts/print.js +0 -125
- package/examples/react-next/env.sample +0 -3
- package/examples/react-next/eslint.config.mjs +0 -14
- package/examples/react-next/hooks/useMapEvents.js +0 -118
- package/examples/react-next/jsconfig.json +0 -7
- package/examples/react-next/next.config.mjs +0 -6
- package/examples/react-next/package.json +0 -25
- package/examples/react-next/pages/_app.js +0 -5
- package/examples/react-next/pages/index.js +0 -97
- package/examples/react-next/postcss.config.mjs +0 -8
- package/examples/react-next/public/discord.svg +0 -8
- package/examples/react-next/public/favicon.ico +0 -0
- package/examples/react-next/public/file.svg +0 -1
- package/examples/react-next/public/logo.png +0 -0
- package/examples/react-next/public/next.svg +0 -1
- package/examples/react-next/shared/constants.js +0 -48
- package/examples/react-next/shared/cookies.js +0 -23
- package/examples/react-next/styles/globals.css +0 -24
- package/examples/react-next/tailwind.config.mjs +0 -17
- package/examples/serverLess/dist/index.23420cfa.js +0 -2973
- package/examples/serverLess/dist/index.23420cfa.js.map +0 -1
- package/examples/serverLess/dist/index.91b6cacc.js +0 -2
- package/examples/serverLess/dist/index.91b6cacc.js.map +0 -1
- package/examples/serverLess/dist/index.html +0 -1
- package/examples/serverLess/index.html +0 -39
- package/examples/serverLess/main.js +0 -113
- package/examples/serverLess/package.json +0 -18
- package/examples/serverLess/readme.md +0 -41
- package/examples/simple/index.html +0 -23
- package/examples/simple/simple.js +0 -80
- package/examples/taigua/index.html +0 -55
- package/examples/taigua/main.js +0 -490
- package/examples/tester.css +0 -74
- package/examples/vidromap/index.js +0 -20
- package/examples/vidromap/index.php +0 -111
- package/flows.md +0 -73
- package/helpers.md +0 -45
- package/src/index.js +0 -882
- package/src/shared/iframe-communicator.js +0 -18
- package/webpack.config.js +0 -22
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Map Handler
|
|
2
2
|
|
|
3
|
-
#### Version 1.
|
|
3
|
+
#### Version 1.3.15 - March 2025
|
|
4
4
|
|
|
5
5
|
Tool to achieve the easiest way of communication with the map iframe.
|
|
6
6
|
|
|
@@ -329,6 +329,23 @@ This feature provides screenshot data, encoded as a PNG in Base64 format.
|
|
|
329
329
|
{type: "screenshot", content: 'png in base64'
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
+
##### print <a id="print-event"></a>
|
|
333
|
+
|
|
334
|
+
Print events, when print process is active `print:true` and when print is ready `print:false, file: png file`
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
{type: "print", content: {print:true/false, file:file})
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
##### dpi
|
|
342
|
+
|
|
343
|
+
Map DPI changed
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
{type: "dpi", content: 96)
|
|
348
|
+
```
|
|
332
349
|
## Methods
|
|
333
350
|
|
|
334
351
|
##### ZoomIn()
|
|
@@ -1125,6 +1142,55 @@ Will do an screenshot of the current map encoded as a PNG in Base64 format. Resu
|
|
|
1125
1142
|
```
|
|
1126
1143
|
screenshot({});
|
|
1127
1144
|
```
|
|
1145
|
+
|
|
1146
|
+
##### setDpi
|
|
1147
|
+
|
|
1148
|
+
Change the map DPI resolution to improve quality in prints.
|
|
1149
|
+
|
|
1150
|
+
Properties:
|
|
1151
|
+
- `dpi` - in pixels, default value is 96.
|
|
1152
|
+
|
|
1153
|
+
```
|
|
1154
|
+
`¡setDpi(96)
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
##### Print
|
|
1158
|
+
|
|
1159
|
+
The print process consists of two steps:
|
|
1160
|
+
|
|
1161
|
+
1. Choose the area to be printed based on the paper size and layout.
|
|
1162
|
+
2. Capture a screenshot of the selected area and emit a print event with the PNG file.
|
|
1163
|
+
|
|
1164
|
+
We recommend increasing the DPI before starting the print process using setDpi(300). Once the file is generated, restore the DPI to its default value using setDpi(96).
|
|
1165
|
+
|
|
1166
|
+
###### Step 1 - startPrint
|
|
1167
|
+
|
|
1168
|
+
This step will block map zoom and pan, and a draggable rectangle with the required size and proportions will be rendered.
|
|
1169
|
+
|
|
1170
|
+
Properties:
|
|
1171
|
+
- `paperSize` - paper size `A3` | `A4`
|
|
1172
|
+
- `paperLayout` - layout `landscape` | `portrait`
|
|
1173
|
+
|
|
1174
|
+
```
|
|
1175
|
+
startPrint({paperSize:'A4', paperLayout:'landscape'});
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
###### Step 2 - Print
|
|
1179
|
+
|
|
1180
|
+
This step will remove the rectangle and generate a PNG file with the contents of the rectangle. Once ready, it will emit a print event with the file. Zoom and pan will be re-enabled.
|
|
1181
|
+
|
|
1182
|
+
```
|
|
1183
|
+
print()
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
##### cancelPrint
|
|
1187
|
+
|
|
1188
|
+
Cancel the print process. This will remove the rectangle and release zoom and pan.
|
|
1189
|
+
|
|
1190
|
+
```
|
|
1191
|
+
cancelPrint()
|
|
1192
|
+
```
|
|
1193
|
+
|
|
1128
1194
|
### Multiple iframes
|
|
1129
1195
|
|
|
1130
1196
|
Is possible to use multiple iframe on a single page, follow this steps.
|
package/map-handler.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
declare module '@vidro/map-handler' {
|
|
4
|
+
import {
|
|
5
|
+
CommunicatorOptions,
|
|
6
|
+
Geometry,
|
|
7
|
+
HighlightOptions,
|
|
8
|
+
MapEventData,
|
|
9
|
+
AddGeomOptions,
|
|
10
|
+
LayerProperties,
|
|
11
|
+
PrintOptions,
|
|
12
|
+
IconOptions,
|
|
13
|
+
CustomColorsProperties,
|
|
14
|
+
ScreenshotOptions,
|
|
15
|
+
DpiOptions,
|
|
16
|
+
} from './src/types';
|
|
17
|
+
|
|
18
|
+
export class Communicator extends EventEmitter {
|
|
19
|
+
constructor(data: CommunicatorOptions);
|
|
20
|
+
|
|
21
|
+
// Event management
|
|
22
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
23
|
+
on(event: string, listener: (data: MapEventData) => void): this;
|
|
24
|
+
off(event: string, listener: (data: MapEventData) => void): this;
|
|
25
|
+
|
|
26
|
+
// Map controls
|
|
27
|
+
ZoomIn(): void;
|
|
28
|
+
ZoomOut(): void;
|
|
29
|
+
zoomToExtent(): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
|
|
32
|
+
// Geometry operations
|
|
33
|
+
AddGeom(geomtype: string, options?: AddGeomOptions): void;
|
|
34
|
+
CancelAddGeom(s?: any): void;
|
|
35
|
+
Highlight(options: HighlightOptions): void;
|
|
36
|
+
DrawGeometries(geoms: Geometry[]): void;
|
|
37
|
+
DrawGeometry(geom: any, styles: any, name?: string, id?: string): void;
|
|
38
|
+
RemoveGeometry(id: string, layer?: string | null): void;
|
|
39
|
+
RemoveGeometriesByProperty(layer: string, property: string, value: any): void;
|
|
40
|
+
UpdateGeometriesByProperty(layer: string, property: string, value: any, style: any): void;
|
|
41
|
+
|
|
42
|
+
// Layer management
|
|
43
|
+
loadMultipleLayers(layers: any[]): void;
|
|
44
|
+
toggleGroup(layers: any[]): void;
|
|
45
|
+
toggleLayer(layer: string, properties?: LayerProperties): void;
|
|
46
|
+
removeLayer(layer: string): void;
|
|
47
|
+
displayLayer(layer: string): void;
|
|
48
|
+
setActiveLayer(layer: string): void;
|
|
49
|
+
getActiveLayer(): void;
|
|
50
|
+
bringLayerToTop(layer: string): void;
|
|
51
|
+
bringLayerToBottom(layer: string): void;
|
|
52
|
+
loadWMSAvailableLayers(): void;
|
|
53
|
+
reloadDisplayedLayers(): void;
|
|
54
|
+
|
|
55
|
+
// Navigation
|
|
56
|
+
zoomToCoordinates(lat: number, lon: number, zoomLevel?: number): void;
|
|
57
|
+
zoomToGeometry(geom: any, limits?: any): void;
|
|
58
|
+
zoomToScale(scale: string): void;
|
|
59
|
+
CenterMap(lat: number, lon: number): void;
|
|
60
|
+
|
|
61
|
+
// Information
|
|
62
|
+
infoFromCoordinates(type: string, layer?: string, hitTolerance?: number, format?: string): void;
|
|
63
|
+
getElementsFromLayer(layer?: string, limit?: number, format?: string): void;
|
|
64
|
+
|
|
65
|
+
// Geolocation
|
|
66
|
+
Geolocalize(toggle: any, options?: any): void;
|
|
67
|
+
|
|
68
|
+
// Background
|
|
69
|
+
toggleGiswaterTiled(toggle: any, tiled: any): void;
|
|
70
|
+
toggleTiled(toggle: any, tiled: any): void;
|
|
71
|
+
getTiled(): void;
|
|
72
|
+
toggleSecondaryBackground(toggle: any): void;
|
|
73
|
+
getSecondaryBackground(): void;
|
|
74
|
+
changeBackground(newBackground: any): void;
|
|
75
|
+
getBackground(): void;
|
|
76
|
+
|
|
77
|
+
// GeoJSON
|
|
78
|
+
addGeoJSON(geoJSON: any, options?: any, name?: string): void;
|
|
79
|
+
clearGeoJSON(name: string): void;
|
|
80
|
+
removeGeoJSONLayer(name: string): void;
|
|
81
|
+
|
|
82
|
+
// Filters
|
|
83
|
+
setGiswaterFilters(filters: any): void;
|
|
84
|
+
setFilters(filters: any): void;
|
|
85
|
+
getGiswaterLayerAvailableFilters(layer_name: string): void;
|
|
86
|
+
|
|
87
|
+
// TOC
|
|
88
|
+
getToc(): void;
|
|
89
|
+
|
|
90
|
+
// Debug & Configuration
|
|
91
|
+
setDebug(what: number): void;
|
|
92
|
+
setCustomColors(properties: CustomColorsProperties): void;
|
|
93
|
+
|
|
94
|
+
// Measure tools
|
|
95
|
+
initMeasure(measure: any, textStart: string, textContinue: string): void;
|
|
96
|
+
cancelMeasure(): void;
|
|
97
|
+
setBboxSize(bbox: number): void;
|
|
98
|
+
|
|
99
|
+
// Icons
|
|
100
|
+
addIcon(options: IconOptions): void;
|
|
101
|
+
|
|
102
|
+
// Screenshot & Print
|
|
103
|
+
screenshot(options?: ScreenshotOptions): void;
|
|
104
|
+
setDpi(options?: DpiOptions): void;
|
|
105
|
+
print(options?: PrintOptions): void;
|
|
106
|
+
startPrint(options?: PrintOptions): void;
|
|
107
|
+
cancelPrint(options?: PrintOptions): void;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Export constants if they exist
|
|
111
|
+
export const MAP_EVENTS: {
|
|
112
|
+
ZOOM_CHANGE: string;
|
|
113
|
+
LOADED: string;
|
|
114
|
+
CAPABILITIES: string;
|
|
115
|
+
ERROR: string;
|
|
116
|
+
GEOLOCATION: string;
|
|
117
|
+
END_MEASURE: string;
|
|
118
|
+
START_MEASURE: string;
|
|
119
|
+
UNLOADED: string;
|
|
120
|
+
COORDINATES: string;
|
|
121
|
+
CENTER_CHANGE: string;
|
|
122
|
+
ACTIVE_LAYER: string;
|
|
123
|
+
WMS_LAYERS: string;
|
|
124
|
+
STATUS: string;
|
|
125
|
+
INFO: string;
|
|
126
|
+
GEOM_ADDED: string;
|
|
127
|
+
LAYERS: string;
|
|
128
|
+
VERSION: string;
|
|
129
|
+
HOVER: string;
|
|
130
|
+
SCREENSHOT: string;
|
|
131
|
+
PRINT: string;
|
|
132
|
+
DPI: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vidro/map-handler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Tool to achieve the easiest way of communication with the map",
|
|
5
5
|
"homepage": "https://github.com/Vidro-Software-SL/maphandler",
|
|
6
6
|
"repository": {
|
|
@@ -8,11 +8,17 @@
|
|
|
8
8
|
"url": "https://github.com/Vidro-Software-SL/maphandler.git"
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/map-handler.js",
|
|
11
|
+
"types": "map-handler.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"map-handler.d.ts",
|
|
15
|
+
"src/types.d.ts"
|
|
16
|
+
],
|
|
11
17
|
"scripts": {
|
|
12
18
|
"build": "webpack"
|
|
13
19
|
},
|
|
14
|
-
"keywords": [],
|
|
15
|
-
"author": "",
|
|
20
|
+
"keywords": ["map", "gis", "communicator", "typescript"],
|
|
21
|
+
"author": "Vidro Software SL",
|
|
16
22
|
"license": "ISC",
|
|
17
23
|
"devDependencies": {
|
|
18
24
|
"@babel/core": "^7.12.16",
|
|
@@ -25,4 +31,4 @@
|
|
|
25
31
|
"dependencies": {
|
|
26
32
|
"events": "^3.2.0"
|
|
27
33
|
}
|
|
28
|
-
}
|
|
34
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface CommunicatorOptions {
|
|
2
|
+
sessionToken: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Geometry {
|
|
7
|
+
geom: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
featureId?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface HighlightOptions {
|
|
14
|
+
geom: string;
|
|
15
|
+
zoom?: number | null;
|
|
16
|
+
center?: boolean;
|
|
17
|
+
animate?: boolean;
|
|
18
|
+
data?: string;
|
|
19
|
+
style?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MapEventData {
|
|
23
|
+
type: string;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AddGeomOptions {
|
|
28
|
+
texts?: any;
|
|
29
|
+
style?: any;
|
|
30
|
+
drawOnEnd?: boolean;
|
|
31
|
+
showConfirm?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LayerProperties {
|
|
35
|
+
gutter?: number | null;
|
|
36
|
+
transparent?: boolean | null;
|
|
37
|
+
singletile?: boolean | null;
|
|
38
|
+
zIndex?: number | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PrintOptions {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IconOptions {
|
|
46
|
+
icon: ArrayBuffer;
|
|
47
|
+
coordinates: [number, number];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CustomColorsProperties {
|
|
51
|
+
geom_stroke_width?: number;
|
|
52
|
+
geom_radius?: number;
|
|
53
|
+
geom_shape?: 'circle' | 'square';
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ScreenshotOptions {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DpiOptions {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}
|
package/.babelrc
DELETED
package/doc/animation.png
DELETED
|
Binary file
|
package/doc/confirmComponent.png
DELETED
|
Binary file
|
package/doc/giswater.png
DELETED
|
Binary file
|
package/doc/giswaterInfo.png
DELETED
|
Binary file
|
package/doc/giswaterInfoApi.png
DELETED
|
Binary file
|
package/doc/giswatergeojson.png
DELETED
|
Binary file
|
package/doc/multiTile.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/doc/vidromaps-basic.png
DELETED
|
Binary file
|