mapixa 1.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/LICENSE +21 -0
- package/README.md +276 -0
- package/dist/components/DrawTools/DrawCircleControl.d.ts +18 -0
- package/dist/components/DrawTools/DrawLineControl.d.ts +17 -0
- package/dist/components/DrawTools/DrawMarkerControl.d.ts +19 -0
- package/dist/components/DrawTools/DrawPolygonControl.d.ts +18 -0
- package/dist/components/DrawTools/DrawRectangleControl.d.ts +19 -0
- package/dist/components/DrawTools/FreeDrawControl.d.ts +8 -0
- package/dist/components/DrawTools/IntersectionControl.d.ts +8 -0
- package/dist/components/DrawTools/MapDrawTools.d.ts +9 -0
- package/dist/components/ExpandableBox.d.ts +11 -0
- package/dist/components/ExtraActionButtons.d.ts +7 -0
- package/dist/components/ExtraTools/CaptureAreaControl.d.ts +8 -0
- package/dist/components/ExtraTools/DrawRulerControl.d.ts +8 -0
- package/dist/components/ExtraTools/ExtraMapTools.d.ts +9 -0
- package/dist/components/ExtraTools/GoToControl.d.ts +7 -0
- package/dist/components/ExtraTools/ImageOverlayControl.d.ts +18 -0
- package/dist/components/LayerVisibilityControl/LayerVisibilityControl.d.ts +6 -0
- package/dist/components/MapControlBox.d.ts +14 -0
- package/dist/components/MapLibreTools.d.ts +85 -0
- package/dist/components/NavigationTools/CoordinateDisplay.d.ts +7 -0
- package/dist/components/NavigationTools/MapFlatViewEnforcer.d.ts +5 -0
- package/dist/components/NavigationTools/MapNavigator.d.ts +7 -0
- package/dist/components/NavigationTools/MapResizeHandler.d.ts +5 -0
- package/dist/components/NavigationTools/MapViewControl.d.ts +3 -0
- package/dist/components/ui/Icons.d.ts +36 -0
- package/dist/components/ui/Modal.d.ts +11 -0
- package/dist/components/ui/Popover.d.ts +10 -0
- package/dist/context/AccordionGroupContext.d.ts +8 -0
- package/dist/context/LayerVisibilityContext.d.ts +20 -0
- package/dist/context/MapToolContext.d.ts +32 -0
- package/dist/index.cjs +9311 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +52894 -0
- package/dist/index.js.map +1 -0
- package/dist/mapixa.css +1 -0
- package/dist/types/events.d.ts +32 -0
- package/dist/types/tools.d.ts +59 -0
- package/dist/utils/exportUtils.d.ts +17 -0
- package/dist/utils/generateMarkerSvg.d.ts +12 -0
- package/dist/utils/geoCalculations.d.ts +25 -0
- package/dist/utils/mapToolButtonStyles.d.ts +4 -0
- package/package.json +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 maplibre-gl-tools Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# πΊοΈ Mapixa
|
|
2
|
+
|
|
3
|
+
> A feature-rich, extensible suite of drawing, measurement, navigation, and layer visibility tools for **MapLibre GL JS** and **React**. Built with pure CSS, vanilla JavaScript, and Lucide icons.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/mapixa)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## β¨ Features
|
|
11
|
+
|
|
12
|
+
- π **Full Draw Suite**:
|
|
13
|
+
- **Markers**: Custom SVG pins (star, circle, square, classic pin), customizable color, size, opacity, and label.
|
|
14
|
+
- **Polylines**: Live drafting line, double-click or finish button, custom width, color, and real-time distance calculation.
|
|
15
|
+
- **Polygons**: Interactive vertex handles, live perimeter drafting, and real-time spherical area calculation ($m^2$ and $km^2$).
|
|
16
|
+
- **Circles**: Center-point & radius drafting, calculated area, and 64-vertex GeoJSON Polygon generation.
|
|
17
|
+
- **Rectangles**: Two-point bounding box dragging with live area metrics.
|
|
18
|
+
- **Freehand Pen**: Smooth freehand brush sketching with configurable stroke width and color.
|
|
19
|
+
- **Intersections**: Segment intersection detector that flags and computes coordinates of line crossings.
|
|
20
|
+
- π **Measurement & Utilities**:
|
|
21
|
+
- **Distance Ruler**: Segment distances and total distance calculation in kilometers.
|
|
22
|
+
- **Area Capture**: Drag-to-select map canvas crop and high-resolution PNG export.
|
|
23
|
+
- **GoTo Coordinates**: Smooth fly-to navigation with coordinate validation (DD/DMS).
|
|
24
|
+
- **Image Overlays**: Place, drag, scale, rotate, and adjust opacity of custom image overlays on map coordinates.
|
|
25
|
+
- ποΈ **Layer Visibility System**:
|
|
26
|
+
- Toggle visibility for all markers, lines, polygons, circles, rectangles, freehand sketches, rulers, and overlays.
|
|
27
|
+
- Programmatic control via `useLayerVisibility()` and controlled `visibility` prop on the root component.
|
|
28
|
+
- β‘ **"After Draw" Action Lifecycle**:
|
|
29
|
+
- `onDrawEnd` event fired whenever any drawing completes, providing the complete GeoJSON feature and calculated metrics.
|
|
30
|
+
- Multiple modes: `'modal'` (styling modal), `'auto-save'` (silent commit), or `'callback'`.
|
|
31
|
+
- Inject custom action buttons (`extraActions`) into tool dialogs (e.g., _Save to Cloud API_, _Buffer 500m_, _Download GeoJSON_, _Export KML_).
|
|
32
|
+
- π§ **Navigation Controls**:
|
|
33
|
+
- Reset View (Home), Zoom In/Out, Locate User (GPS), Box Zoom (Shift + Drag), Reset North (Compass).
|
|
34
|
+
- **Live Coordinate Display**: Cursor hover coordinates with click-to-copy to clipboard.
|
|
35
|
+
- π¨ **Pure CSS & Zero Framework Bloat**:
|
|
36
|
+
- No Material UI, No Emotion, No Tailwind requirement.
|
|
37
|
+
- Modern glassmorphic floating UI with buttery-smooth CSS Grid accordion animations.
|
|
38
|
+
- Powered by **lucide-react** icons.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## π¦ Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install mapixa maplibre-gl react-map-gl
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
_or with yarn:_
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
yarn add mapixa maplibre-gl react-map-gl
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
_or with pnpm:_
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm add mapixa maplibre-gl react-map-gl
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## π Quick Start
|
|
63
|
+
|
|
64
|
+
Wrap your application with MapLibre and mount `<Mapixa />` (or `<MapLibreTools />`) directly inside:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import React from "react";
|
|
68
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
69
|
+
import "mapixa/style.css";
|
|
70
|
+
import maplibregl from "maplibre-gl";
|
|
71
|
+
import { Map } from "react-map-gl/maplibre";
|
|
72
|
+
import { Mapixa } from "mapixa";
|
|
73
|
+
|
|
74
|
+
export function MyMap() {
|
|
75
|
+
return (
|
|
76
|
+
<div style={{ width: "100vw", height: "100vh" }}>
|
|
77
|
+
<Map
|
|
78
|
+
mapLib={maplibregl}
|
|
79
|
+
initialViewState={{
|
|
80
|
+
longitude: 51.389,
|
|
81
|
+
latitude: 35.6892,
|
|
82
|
+
zoom: 12,
|
|
83
|
+
}}
|
|
84
|
+
mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
|
|
85
|
+
style={{ width: "100%", height: "100%" }}
|
|
86
|
+
>
|
|
87
|
+
{/* Mount all tools in one line */}
|
|
88
|
+
<Mapixa
|
|
89
|
+
afterDrawMode="modal"
|
|
90
|
+
onDrawEnd={(event) => {
|
|
91
|
+
console.log("After draw happened:", event.tool, event.feature);
|
|
92
|
+
}}
|
|
93
|
+
visibility={{ polyine: true, circle: false }}
|
|
94
|
+
toolbarGap={12}
|
|
95
|
+
/>
|
|
96
|
+
</Map>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## β‘ Handling "After Draw" Actions
|
|
105
|
+
|
|
106
|
+
You can customize what happens after the user completes a drawing:
|
|
107
|
+
|
|
108
|
+
### 1. `onDrawEnd` Lifecycle Hook
|
|
109
|
+
|
|
110
|
+
Receives a `DrawEndEvent` containing the feature, coordinates, and calculated GIS metrics:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Mapixa
|
|
114
|
+
onDrawEnd={(event) => {
|
|
115
|
+
console.log("Tool used:", event.tool); // 'marker' | 'line' | 'polygon' | 'circle' | etc.
|
|
116
|
+
console.log("GeoJSON Feature:", event.feature);
|
|
117
|
+
console.log("Calculated metrics:", event.metrics);
|
|
118
|
+
// event.metrics?.areaSqKm -> area in square kilometers
|
|
119
|
+
// event.metrics?.distanceKm -> distance in kilometers
|
|
120
|
+
// event.metrics?.radiusKm -> circle radius
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 2. Custom Action Buttons (`extraActions`)
|
|
126
|
+
|
|
127
|
+
Inject custom action buttons directly into tool dialogs:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
const customActions = [
|
|
131
|
+
{
|
|
132
|
+
id: "save-to-db",
|
|
133
|
+
label: "Save to Backend",
|
|
134
|
+
variant: "contained",
|
|
135
|
+
color: "primary",
|
|
136
|
+
onClick: async ({ tool, feature, metrics, closeModal }) => {
|
|
137
|
+
await fetch("/api/features", {
|
|
138
|
+
method: "POST",
|
|
139
|
+
body: JSON.stringify({ tool, feature, metrics }),
|
|
140
|
+
});
|
|
141
|
+
alert("Feature saved to server!");
|
|
142
|
+
closeModal?.();
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "export-geojson",
|
|
147
|
+
label: "Download GeoJSON",
|
|
148
|
+
variant: "outlined",
|
|
149
|
+
onClick: ({ tool, feature }) => {
|
|
150
|
+
downloadGeoJSON(feature, `${tool}.geojson`);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
<Mapixa extraActions={customActions} />;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 3. `afterDrawMode` Modes
|
|
159
|
+
|
|
160
|
+
- `'modal'` _(default)_: Opens the tool's dialog allowing the user to configure styles, view measurements, and trigger custom extra actions.
|
|
161
|
+
- `'auto-save'`: Automatically saves the feature to the map and fires `onDrawEnd` immediately without blocking the user.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## ποΈ Layer Visibility Control
|
|
166
|
+
|
|
167
|
+
Every tool has visibility management configured directly via code and props:
|
|
168
|
+
|
|
169
|
+
### 1. Controlled Visibility Prop
|
|
170
|
+
|
|
171
|
+
Pass the `visibility` prop directly to `<Mapixa />`. It accepts tool keys and aliases (e.g. `line`, `polyline`, `polyine`, `circle`, `polygon`, `marker`, etc.):
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
<Mapixa
|
|
175
|
+
afterDrawMode="modal"
|
|
176
|
+
extraActions={extraActions}
|
|
177
|
+
onDrawEnd={handleDrawEnd}
|
|
178
|
+
visibility={{
|
|
179
|
+
polyine: true, // polylines visible
|
|
180
|
+
circle: false, // circles hidden
|
|
181
|
+
marker: true, // markers visible
|
|
182
|
+
polygon: true, // polygons visible
|
|
183
|
+
}}
|
|
184
|
+
toolbarGap={12} // customizable gap in px between accordion toolbars (default: 12px)
|
|
185
|
+
/>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 2. Programmatic Control with `useLayerVisibility`
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import { useLayerVisibility } from "mapixa";
|
|
192
|
+
|
|
193
|
+
function MyComponent() {
|
|
194
|
+
const {
|
|
195
|
+
visibility,
|
|
196
|
+
toggleToolVisibility,
|
|
197
|
+
setToolVisibility,
|
|
198
|
+
setAllVisibility,
|
|
199
|
+
} = useLayerVisibility();
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<button onClick={() => toggleToolVisibility("polygon")}>
|
|
203
|
+
Toggle Polygons ({visibility.polygon ? "Visible" : "Hidden"})
|
|
204
|
+
</button>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## π§© Modular Components
|
|
212
|
+
|
|
213
|
+
If you prefer custom layouts rather than the all-in-one `<Mapixa />`, you can import individual components:
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import {
|
|
217
|
+
MapControlBox,
|
|
218
|
+
MapDrawTools,
|
|
219
|
+
ExtraMapTools,
|
|
220
|
+
LayerVisibilityControl,
|
|
221
|
+
MapNavigator,
|
|
222
|
+
CoordinateDisplay,
|
|
223
|
+
} from "mapixa";
|
|
224
|
+
|
|
225
|
+
<MapControlBox position="top-right">
|
|
226
|
+
<MapDrawTools />
|
|
227
|
+
<ExtraMapTools />
|
|
228
|
+
<LayerVisibilityControl />
|
|
229
|
+
</MapControlBox>;
|
|
230
|
+
|
|
231
|
+
<MapControlBox position="bottom-left">
|
|
232
|
+
<CoordinateDisplay />
|
|
233
|
+
</MapControlBox>;
|
|
234
|
+
|
|
235
|
+
<MapControlBox position="top-left">
|
|
236
|
+
<MapNavigator />
|
|
237
|
+
</MapControlBox>;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## π οΈ Exported Utilities
|
|
243
|
+
|
|
244
|
+
- `calculateDistanceKm(p1, p2)`: Haversine distance in km.
|
|
245
|
+
- `calculateLineDistanceKm(coordinates)`: Total line distance in km.
|
|
246
|
+
- `calculatePolygonAreaSqM(coordinates)`: Spherical polygon area in $m^2$.
|
|
247
|
+
- `createGeoJSONCircle(center, radiusKm)`: GeoJSON Polygon circle generator.
|
|
248
|
+
- `downloadGeoJSON(data, filename)`: Triggers browser download of GeoJSON.
|
|
249
|
+
- `copyToClipboard(text)`: Cross-browser clipboard copy.
|
|
250
|
+
- `downloadCanvasArea(canvas, rect, filename)`: Canvas crop export.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## π’ Publishing to NPM
|
|
255
|
+
|
|
256
|
+
To publish this package to NPM under the name **mapixa**:
|
|
257
|
+
|
|
258
|
+
1. Build the distributable bundle:
|
|
259
|
+
```bash
|
|
260
|
+
npm run build:lib
|
|
261
|
+
```
|
|
262
|
+
2. Check the bundle contents:
|
|
263
|
+
```bash
|
|
264
|
+
npm pack --dry-run
|
|
265
|
+
```
|
|
266
|
+
3. Login and publish:
|
|
267
|
+
```bash
|
|
268
|
+
npm login
|
|
269
|
+
npm publish --access public
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## π License
|
|
275
|
+
|
|
276
|
+
MIT Β© [Open Source](LICENSE)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface CircleItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
center: [number, number];
|
|
7
|
+
radiusKm: number;
|
|
8
|
+
fillColor: string;
|
|
9
|
+
fillOpacity: number;
|
|
10
|
+
outlineColor: string;
|
|
11
|
+
areaSqKm?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DrawCircleControlProps {
|
|
14
|
+
config?: ToolConfig;
|
|
15
|
+
extraActions?: ExtraActionItem[];
|
|
16
|
+
}
|
|
17
|
+
export declare const DrawCircleControl: FC<DrawCircleControlProps>;
|
|
18
|
+
export default DrawCircleControl;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface LineItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
lineColor: string;
|
|
7
|
+
lineWidth: number;
|
|
8
|
+
opacity: number;
|
|
9
|
+
coordinates: number[][];
|
|
10
|
+
distanceKm?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface DrawLineControlProps {
|
|
13
|
+
config?: ToolConfig;
|
|
14
|
+
extraActions?: ExtraActionItem[];
|
|
15
|
+
}
|
|
16
|
+
export declare const DrawLineControl: FC<DrawLineControlProps>;
|
|
17
|
+
export default DrawLineControl;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface MarkerItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
lat: number;
|
|
7
|
+
lon: number;
|
|
8
|
+
markerColor: string;
|
|
9
|
+
iconType: "star" | "circle" | "square" | "pin";
|
|
10
|
+
iconColor: string;
|
|
11
|
+
size: number;
|
|
12
|
+
opacity: number;
|
|
13
|
+
}
|
|
14
|
+
export interface DrawMarkerControlProps {
|
|
15
|
+
config?: ToolConfig;
|
|
16
|
+
extraActions?: ExtraActionItem[];
|
|
17
|
+
}
|
|
18
|
+
export declare const DrawMarkerControl: FC<DrawMarkerControlProps>;
|
|
19
|
+
export default DrawMarkerControl;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface PolygonItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
fillColor: string;
|
|
7
|
+
fillOpacity: number;
|
|
8
|
+
outlineColor: string;
|
|
9
|
+
vertices: number[][];
|
|
10
|
+
areaSqM?: number;
|
|
11
|
+
areaSqKm?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DrawPolygonControlProps {
|
|
14
|
+
config?: ToolConfig;
|
|
15
|
+
extraActions?: ExtraActionItem[];
|
|
16
|
+
}
|
|
17
|
+
export declare const DrawPolygonControl: FC<DrawPolygonControlProps>;
|
|
18
|
+
export default DrawPolygonControl;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface RectangleItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
p1: [number, number];
|
|
7
|
+
p2: [number, number];
|
|
8
|
+
fillColor: string;
|
|
9
|
+
fillOpacity: number;
|
|
10
|
+
outlineColor: string;
|
|
11
|
+
areaSqKm?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const getRectCoordinates: (p1: [number, number], p2: [number, number]) => number[][];
|
|
14
|
+
export interface DrawRectangleControlProps {
|
|
15
|
+
config?: ToolConfig;
|
|
16
|
+
extraActions?: ExtraActionItem[];
|
|
17
|
+
}
|
|
18
|
+
export declare const DrawRectangleControl: FC<DrawRectangleControlProps>;
|
|
19
|
+
export default DrawRectangleControl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface FreeDrawControlProps {
|
|
4
|
+
config?: ToolConfig;
|
|
5
|
+
extraActions?: ExtraActionItem[];
|
|
6
|
+
}
|
|
7
|
+
export declare const FreeDrawControl: FC<FreeDrawControlProps>;
|
|
8
|
+
export default FreeDrawControl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface IntersectionControlProps {
|
|
4
|
+
config?: ToolConfig;
|
|
5
|
+
extraActions?: ExtraActionItem[];
|
|
6
|
+
}
|
|
7
|
+
export declare const IntersectionControl: FC<IntersectionControlProps>;
|
|
8
|
+
export default IntersectionControl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ToolsConfiguration, ExtraActionItem } from '../../types/tools';
|
|
3
|
+
export interface MapDrawToolsProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
config?: ToolsConfiguration;
|
|
6
|
+
extraActions?: ExtraActionItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare const MapDrawTools: FC<MapDrawToolsProps>;
|
|
9
|
+
export default MapDrawTools;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export interface ExpandableBoxProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
accordionText: string;
|
|
5
|
+
accordionIcon: ReactNode;
|
|
6
|
+
id?: string;
|
|
7
|
+
tooltip?: string;
|
|
8
|
+
footer?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const ExpandableBox: FC<ExpandableBoxProps>;
|
|
11
|
+
export default ExpandableBox;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExtraActionItem, ActionContext } from '../types/tools';
|
|
2
|
+
export interface ExtraActionButtonsProps {
|
|
3
|
+
actions?: ExtraActionItem[];
|
|
4
|
+
context: ActionContext;
|
|
5
|
+
}
|
|
6
|
+
export declare function ExtraActionButtons({ actions, context, }: ExtraActionButtonsProps): import("react").JSX.Element;
|
|
7
|
+
export default ExtraActionButtons;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface CaptureAreaControlProps {
|
|
4
|
+
config?: ToolConfig;
|
|
5
|
+
extraActions?: ExtraActionItem[];
|
|
6
|
+
}
|
|
7
|
+
export declare const CaptureAreaControl: FC<CaptureAreaControlProps>;
|
|
8
|
+
export default CaptureAreaControl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface DrawRulerControlProps {
|
|
4
|
+
config?: ToolConfig;
|
|
5
|
+
extraActions?: ExtraActionItem[];
|
|
6
|
+
}
|
|
7
|
+
export declare const DrawRulerControl: FC<DrawRulerControlProps>;
|
|
8
|
+
export default DrawRulerControl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ToolsConfiguration, ExtraActionItem } from '../../types/tools';
|
|
3
|
+
export interface ExtraMapToolsProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
config?: ToolsConfiguration;
|
|
6
|
+
extraActions?: ExtraActionItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare const ExtraMapTools: FC<ExtraMapToolsProps>;
|
|
9
|
+
export default ExtraMapTools;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ExtraActionItem, ToolConfig } from '../../types/tools';
|
|
3
|
+
export interface OverlayImageItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
src: string;
|
|
7
|
+
lng: number;
|
|
8
|
+
lat: number;
|
|
9
|
+
scale: number;
|
|
10
|
+
rotation: number;
|
|
11
|
+
opacity: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ImageOverlayControlProps {
|
|
14
|
+
config?: ToolConfig;
|
|
15
|
+
extraActions?: ExtraActionItem[];
|
|
16
|
+
}
|
|
17
|
+
export declare const ImageOverlayControl: FC<ImageOverlayControlProps>;
|
|
18
|
+
export default ImageOverlayControl;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface LayerVisibilityControlProps {
|
|
2
|
+
buttonSize?: number;
|
|
3
|
+
placement?: "left" | "right" | "top" | "bottom";
|
|
4
|
+
}
|
|
5
|
+
export declare function LayerVisibilityControl({ buttonSize, }: LayerVisibilityControlProps): import("react").JSX.Element;
|
|
6
|
+
export default LayerVisibilityControl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ControlPosition } from 'react-map-gl/maplibre';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface MapControlBoxProps {
|
|
4
|
+
position?: ControlPosition;
|
|
5
|
+
margin?: {
|
|
6
|
+
top: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
left: number;
|
|
9
|
+
right: number;
|
|
10
|
+
};
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function MapControlBox({ position, margin, children, }: MapControlBoxProps): import('react').ReactPortal;
|
|
14
|
+
export default MapControlBox;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ControlPosition } from 'react-map-gl/maplibre';
|
|
3
|
+
import { ToolsConfiguration, LayerVisibilityState, AfterDrawMode, ExtraActionItem, ToolType } from '../types/tools';
|
|
4
|
+
import { DrawEndEvent, DrawChangeEvent, DrawDeleteEvent } from '../types/events';
|
|
5
|
+
export interface MapLibreToolsProps {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Position for the main draw and extra toolbars.
|
|
9
|
+
* Defaults to 'top-right'
|
|
10
|
+
*/
|
|
11
|
+
toolbarPosition?: ControlPosition;
|
|
12
|
+
/**
|
|
13
|
+
* Position for navigator zoom/home controls.
|
|
14
|
+
* Defaults to 'top-left'
|
|
15
|
+
*/
|
|
16
|
+
navigatorPosition?: ControlPosition;
|
|
17
|
+
/**
|
|
18
|
+
* Position for live coordinate display.
|
|
19
|
+
* Defaults to 'bottom-left'
|
|
20
|
+
*/
|
|
21
|
+
coordinatePosition?: ControlPosition;
|
|
22
|
+
/**
|
|
23
|
+
* Position for fullscreen control.
|
|
24
|
+
* Defaults to 'bottom-right'
|
|
25
|
+
*/
|
|
26
|
+
viewControlPosition?: ControlPosition;
|
|
27
|
+
/**
|
|
28
|
+
* Controlled or initial visibility of tool layers (markers, lines, polygons, etc.)
|
|
29
|
+
* Example: visibility={{ polyine: true, circle: false }} or visibility={{ line: true, circle: false }}
|
|
30
|
+
*/
|
|
31
|
+
visibility?: Partial<LayerVisibilityState>;
|
|
32
|
+
/**
|
|
33
|
+
* Initial visibility of tool layers (fallback for uncontrolled)
|
|
34
|
+
*/
|
|
35
|
+
initialVisibility?: Partial<LayerVisibilityState>;
|
|
36
|
+
/**
|
|
37
|
+
* Gap between toolbar accordion boxes in pixels.
|
|
38
|
+
* Defaults to 12.
|
|
39
|
+
*/
|
|
40
|
+
toolbarGap?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Tool configurations (enabled/disabled, custom extraActions per tool)
|
|
43
|
+
*/
|
|
44
|
+
toolsConfig?: ToolsConfiguration;
|
|
45
|
+
/**
|
|
46
|
+
* Behavior after finishing a draw action:
|
|
47
|
+
* - 'modal': opens configuration/styling modal with extra actions
|
|
48
|
+
* - 'auto-save': automatically commits the feature and triggers onDrawEnd
|
|
49
|
+
* - 'callback': triggers onDrawEnd immediately
|
|
50
|
+
*/
|
|
51
|
+
afterDrawMode?: AfterDrawMode;
|
|
52
|
+
/**
|
|
53
|
+
* Global extra actions injected into all tool modals
|
|
54
|
+
*/
|
|
55
|
+
extraActions?: ExtraActionItem[];
|
|
56
|
+
/**
|
|
57
|
+
* Callback fired when any tool finishes drawing a shape, marker, or measurement
|
|
58
|
+
*/
|
|
59
|
+
onDrawEnd?: (event: DrawEndEvent) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Callback fired when a tool starts drawing
|
|
62
|
+
*/
|
|
63
|
+
onDrawStart?: (tool: ToolType) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Callback fired when features change
|
|
66
|
+
*/
|
|
67
|
+
onDrawChange?: (event: DrawChangeEvent) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Callback fired when a feature is deleted
|
|
70
|
+
*/
|
|
71
|
+
onDrawDelete?: (event: DrawDeleteEvent) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Callback fired when layer visibility toggles
|
|
74
|
+
*/
|
|
75
|
+
onVisibilityChange?: (tool: ToolType, visible: boolean, allState: LayerVisibilityState) => void;
|
|
76
|
+
showDrawTools?: boolean;
|
|
77
|
+
showExtraTools?: boolean;
|
|
78
|
+
showNavigator?: boolean;
|
|
79
|
+
showCoordinates?: boolean;
|
|
80
|
+
showFullscreen?: boolean;
|
|
81
|
+
enforceFlatView?: boolean;
|
|
82
|
+
autoResize?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare const MapLibreTools: FC<MapLibreToolsProps>;
|
|
85
|
+
export default MapLibreTools;
|