@geolonia/maps-react 0.2.0 → 0.3.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 +6 -2
- package/dist/index.js +39 -29
- package/package.json +9 -11
- package/dist/index.cjs +0 -965
- package/dist/index.d.cts +0 -176
package/README.md
CHANGED
|
@@ -8,7 +8,11 @@ React component wrapper for [Geolonia Maps](https://geolonia.com/). Provides dec
|
|
|
8
8
|
npm install @geolonia/maps-react maplibre-gl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
**Peer dependencies:** `react >= 18`, `react-dom >= 18`, `maplibre-gl
|
|
11
|
+
**Peer dependencies:** `react >= 18`, `react-dom >= 18`, `maplibre-gl ^6.0.0`
|
|
12
|
+
|
|
13
|
+
This package is ESM-only. There is no `require()` entry.
|
|
14
|
+
|
|
15
|
+
MapLibre GL JS v6 loads its worker from a real URL, so most bundlers need a one-time `setWorkerUrl` call before the first `<Map>` renders. Without it the map never finishes loading. See [Worker setup in `@geolonia/maps-core`](https://github.com/geolonia/maps-core#worker-setup) for Vite and webpack.
|
|
12
16
|
|
|
13
17
|
## Usage
|
|
14
18
|
|
|
@@ -148,7 +152,7 @@ Hook to access the parent `<Source>` ID from `SourceContext`. Useful for custom
|
|
|
148
152
|
|
|
149
153
|
```bash
|
|
150
154
|
npm install
|
|
151
|
-
npm run build # ESM +
|
|
155
|
+
npm run build # ESM + DTS
|
|
152
156
|
npm run test # Vitest unit tests
|
|
153
157
|
npm run test:coverage # Vitest with coverage report
|
|
154
158
|
npm run e2e # Playwright E2E tests
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,7 @@ function Control({
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// src/components/controls.tsx
|
|
62
|
-
import maplibregl from "maplibre-gl";
|
|
62
|
+
import * as maplibregl from "maplibre-gl";
|
|
63
63
|
import { useEffect as useEffect2 } from "react";
|
|
64
64
|
function useControl(factory, options) {
|
|
65
65
|
const map = useMap();
|
|
@@ -85,7 +85,7 @@ function safeRemoveControl(map, ctrl) {
|
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function NavigationControl2({
|
|
89
89
|
position = "top-right",
|
|
90
90
|
showCompass,
|
|
91
91
|
showZoom,
|
|
@@ -103,7 +103,7 @@ function NavigationControl({
|
|
|
103
103
|
}, [map, position, showCompass, showZoom, visualizePitch]);
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function GeolocateControl2({
|
|
107
107
|
position = "top-right",
|
|
108
108
|
positionOptions,
|
|
109
109
|
fitBoundsOptions,
|
|
@@ -137,7 +137,7 @@ function GeolocateControl({
|
|
|
137
137
|
]);
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function FullscreenControl2({
|
|
141
141
|
position = "top-right",
|
|
142
142
|
container
|
|
143
143
|
} = {}) {
|
|
@@ -151,7 +151,7 @@ function FullscreenControl({
|
|
|
151
151
|
}, [map, position, container]);
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function ScaleControl2({
|
|
155
155
|
position = "bottom-left",
|
|
156
156
|
maxWidth,
|
|
157
157
|
unit
|
|
@@ -166,7 +166,7 @@ function ScaleControl({
|
|
|
166
166
|
}, [map, position, maxWidth, unit]);
|
|
167
167
|
return null;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function AttributionControl2({
|
|
170
170
|
position = "bottom-right",
|
|
171
171
|
compact,
|
|
172
172
|
customAttribution
|
|
@@ -312,6 +312,7 @@ import {
|
|
|
312
312
|
DEFAULT_STAGE,
|
|
313
313
|
GeoloniaMap
|
|
314
314
|
} from "@geolonia/maps-core";
|
|
315
|
+
import { MapMouseEvent } from "maplibre-gl";
|
|
315
316
|
import {
|
|
316
317
|
forwardRef,
|
|
317
318
|
useContext as useContext3,
|
|
@@ -321,8 +322,8 @@ import {
|
|
|
321
322
|
useState as useState2
|
|
322
323
|
} from "react";
|
|
323
324
|
import { jsx } from "react/jsx-runtime";
|
|
324
|
-
var DEFAULT_CENTER = [
|
|
325
|
-
var DEFAULT_ZOOM =
|
|
325
|
+
var DEFAULT_CENTER = [0, 0];
|
|
326
|
+
var DEFAULT_ZOOM = 0;
|
|
326
327
|
var HANDLER_NAMES = {
|
|
327
328
|
onClick: "click",
|
|
328
329
|
onDblClick: "dblclick",
|
|
@@ -444,12 +445,6 @@ var Map = forwardRef((props, ref) => {
|
|
|
444
445
|
const wrappers = [];
|
|
445
446
|
for (const [propName, eventName] of Object.entries(HANDLER_NAMES)) {
|
|
446
447
|
if (propName === "onMouseEnter" || propName === "onMouseLeave") {
|
|
447
|
-
const wrapper2 = (e) => {
|
|
448
|
-
if (interactiveLayerIdsRef.current?.length) return;
|
|
449
|
-
handlersRef.current[propName]?.(e);
|
|
450
|
-
};
|
|
451
|
-
instance.on(eventName, wrapper2);
|
|
452
|
-
wrappers.push([eventName, wrapper2]);
|
|
453
448
|
continue;
|
|
454
449
|
}
|
|
455
450
|
const wrapper = (e) => {
|
|
@@ -477,17 +472,32 @@ var Map = forwardRef((props, ref) => {
|
|
|
477
472
|
};
|
|
478
473
|
instance.on("mousemove", hoverMove);
|
|
479
474
|
wrappers.push(["mousemove", hoverMove]);
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
if (
|
|
475
|
+
const container = containerRef.current;
|
|
476
|
+
const onContainerEnter = (ev) => {
|
|
477
|
+
if (interactiveLayerIdsRef.current?.length) return;
|
|
478
|
+
handlersRef.current.onMouseEnter?.(
|
|
479
|
+
new MapMouseEvent("mouseenter", instance, ev)
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
const onContainerLeave = (ev) => {
|
|
483
|
+
if (interactiveLayerIdsRef.current?.length) {
|
|
484
|
+
if (!hoverState.over) return;
|
|
483
485
|
hoverState.over = false;
|
|
484
|
-
handlersRef.current.onMouseLeave?.(
|
|
486
|
+
handlersRef.current.onMouseLeave?.(
|
|
487
|
+
new MapMouseEvent("mouseleave", instance, ev, { features: [] })
|
|
488
|
+
);
|
|
489
|
+
return;
|
|
485
490
|
}
|
|
491
|
+
handlersRef.current.onMouseLeave?.(
|
|
492
|
+
new MapMouseEvent("mouseleave", instance, ev)
|
|
493
|
+
);
|
|
486
494
|
};
|
|
487
|
-
|
|
488
|
-
|
|
495
|
+
container.addEventListener("mouseenter", onContainerEnter);
|
|
496
|
+
container.addEventListener("mouseleave", onContainerLeave);
|
|
489
497
|
setMap(instance);
|
|
490
498
|
return () => {
|
|
499
|
+
container.removeEventListener("mouseenter", onContainerEnter);
|
|
500
|
+
container.removeEventListener("mouseleave", onContainerLeave);
|
|
491
501
|
for (const [eventName, wrapper] of wrappers) {
|
|
492
502
|
instance.off(eventName, wrapper);
|
|
493
503
|
}
|
|
@@ -601,7 +611,7 @@ function MapProvider({ children }) {
|
|
|
601
611
|
|
|
602
612
|
// src/components/marker.tsx
|
|
603
613
|
import { GeoloniaMarker } from "@geolonia/maps-core";
|
|
604
|
-
import maplibregl2 from "maplibre-gl";
|
|
614
|
+
import * as maplibregl2 from "maplibre-gl";
|
|
605
615
|
import { useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
606
616
|
import { createPortal as createPortal2 } from "react-dom";
|
|
607
617
|
function Marker(props) {
|
|
@@ -708,7 +718,7 @@ function Marker(props) {
|
|
|
708
718
|
}
|
|
709
719
|
|
|
710
720
|
// src/components/popup.tsx
|
|
711
|
-
import maplibregl3 from "maplibre-gl";
|
|
721
|
+
import * as maplibregl3 from "maplibre-gl";
|
|
712
722
|
import { useEffect as useEffect6, useRef as useRef4 } from "react";
|
|
713
723
|
import { createPortal as createPortal3 } from "react-dom";
|
|
714
724
|
function defined2(obj) {
|
|
@@ -718,7 +728,7 @@ function defined2(obj) {
|
|
|
718
728
|
}
|
|
719
729
|
return out;
|
|
720
730
|
}
|
|
721
|
-
function
|
|
731
|
+
function Popup3(props) {
|
|
722
732
|
const {
|
|
723
733
|
lat,
|
|
724
734
|
lng,
|
|
@@ -898,19 +908,19 @@ function Source({ id, children, ...spec }) {
|
|
|
898
908
|
return /* @__PURE__ */ jsx3(SourceContext.Provider, { value: id, children: ready && children });
|
|
899
909
|
}
|
|
900
910
|
export {
|
|
901
|
-
AttributionControl,
|
|
911
|
+
AttributionControl2 as AttributionControl,
|
|
902
912
|
Control,
|
|
903
|
-
FullscreenControl,
|
|
904
|
-
GeolocateControl,
|
|
913
|
+
FullscreenControl2 as FullscreenControl,
|
|
914
|
+
GeolocateControl2 as GeolocateControl,
|
|
905
915
|
Layer,
|
|
906
916
|
Map,
|
|
907
917
|
MapContext,
|
|
908
918
|
MapProvider,
|
|
909
919
|
MapProviderContext,
|
|
910
920
|
Marker,
|
|
911
|
-
NavigationControl,
|
|
912
|
-
Popup,
|
|
913
|
-
ScaleControl,
|
|
921
|
+
NavigationControl2 as NavigationControl,
|
|
922
|
+
Popup3 as Popup,
|
|
923
|
+
ScaleControl2 as ScaleControl,
|
|
914
924
|
Source,
|
|
915
925
|
SourceContext,
|
|
916
926
|
useControl,
|
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolonia/maps-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.cjs",
|
|
6
5
|
"module": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
9
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
10
|
+
"import": "./dist/index.js"
|
|
13
11
|
}
|
|
14
12
|
},
|
|
15
13
|
"files": [
|
|
16
14
|
"dist"
|
|
17
15
|
],
|
|
18
16
|
"dependencies": {
|
|
19
|
-
"@geolonia/maps-core": "^0.
|
|
17
|
+
"@geolonia/maps-core": "^0.6.0"
|
|
20
18
|
},
|
|
21
19
|
"peerDependencies": {
|
|
22
|
-
"maplibre-gl": "^
|
|
20
|
+
"maplibre-gl": "^6.0.0",
|
|
23
21
|
"react": ">=18",
|
|
24
22
|
"react-dom": ">=18"
|
|
25
23
|
},
|
|
@@ -30,18 +28,18 @@
|
|
|
30
28
|
"@types/react": "^18",
|
|
31
29
|
"@types/react-dom": "^18",
|
|
32
30
|
"@vitejs/plugin-react": "^5.1.4",
|
|
33
|
-
"@vitest/coverage-v8": "^
|
|
31
|
+
"@vitest/coverage-v8": "^5.0.2",
|
|
34
32
|
"jsdom": "^29.0.1",
|
|
35
|
-
"maplibre-gl": "
|
|
33
|
+
"maplibre-gl": "6.11.2",
|
|
36
34
|
"react": "^18",
|
|
37
35
|
"react-dom": "^18",
|
|
38
36
|
"tsup": "^8",
|
|
39
37
|
"typescript": "^5.8",
|
|
40
|
-
"vite": "^7.3.
|
|
41
|
-
"vitest": "^
|
|
38
|
+
"vite": "^7.3.6",
|
|
39
|
+
"vitest": "^5.0.2"
|
|
42
40
|
},
|
|
43
41
|
"scripts": {
|
|
44
|
-
"build": "tsup src/index.ts --format esm
|
|
42
|
+
"build": "tsup src/index.ts --format esm --dts --clean --external react --external react-dom --external maplibre-gl",
|
|
45
43
|
"check:externals": "node scripts/check-externals.mjs",
|
|
46
44
|
"smoke": "node scripts/smoke.mjs",
|
|
47
45
|
"verify": "npm run build && npm run check:externals && npm run smoke",
|
package/dist/index.cjs
DELETED
|
@@ -1,965 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
AttributionControl: () => AttributionControl,
|
|
34
|
-
Control: () => Control,
|
|
35
|
-
FullscreenControl: () => FullscreenControl,
|
|
36
|
-
GeolocateControl: () => GeolocateControl,
|
|
37
|
-
Layer: () => Layer,
|
|
38
|
-
Map: () => Map,
|
|
39
|
-
MapContext: () => MapContext,
|
|
40
|
-
MapProvider: () => MapProvider,
|
|
41
|
-
MapProviderContext: () => MapProviderContext,
|
|
42
|
-
Marker: () => Marker,
|
|
43
|
-
NavigationControl: () => NavigationControl,
|
|
44
|
-
Popup: () => Popup,
|
|
45
|
-
ScaleControl: () => ScaleControl,
|
|
46
|
-
Source: () => Source,
|
|
47
|
-
SourceContext: () => SourceContext,
|
|
48
|
-
useControl: () => useControl,
|
|
49
|
-
useMap: () => useMap,
|
|
50
|
-
useMaps: () => useMaps,
|
|
51
|
-
useSourceId: () => useSourceId
|
|
52
|
-
});
|
|
53
|
-
module.exports = __toCommonJS(index_exports);
|
|
54
|
-
|
|
55
|
-
// src/components/control.tsx
|
|
56
|
-
var import_react2 = require("react");
|
|
57
|
-
var import_react_dom = require("react-dom");
|
|
58
|
-
|
|
59
|
-
// src/map-context.ts
|
|
60
|
-
var import_react = require("react");
|
|
61
|
-
var MapContext = (0, import_react.createContext)(null);
|
|
62
|
-
var MapProviderContext = (0, import_react.createContext)(null);
|
|
63
|
-
function useMap() {
|
|
64
|
-
const map = (0, import_react.useContext)(MapContext);
|
|
65
|
-
if (!map) {
|
|
66
|
-
throw new Error("useMap must be used within a <Map> component");
|
|
67
|
-
}
|
|
68
|
-
return map;
|
|
69
|
-
}
|
|
70
|
-
function useMaps() {
|
|
71
|
-
const current = (0, import_react.useContext)(MapContext) ?? void 0;
|
|
72
|
-
const registry = (0, import_react.useContext)(MapProviderContext);
|
|
73
|
-
return {
|
|
74
|
-
...current ? { current } : {},
|
|
75
|
-
maps: { ...registry?.maps ?? {} }
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// src/components/control.tsx
|
|
80
|
-
function Control({
|
|
81
|
-
position = "top-right",
|
|
82
|
-
onAdd,
|
|
83
|
-
onRemove,
|
|
84
|
-
children
|
|
85
|
-
}) {
|
|
86
|
-
const map = useMap();
|
|
87
|
-
const [container, setContainer] = (0, import_react2.useState)(null);
|
|
88
|
-
(0, import_react2.useEffect)(() => {
|
|
89
|
-
let el = null;
|
|
90
|
-
const control = {
|
|
91
|
-
onAdd: (m) => {
|
|
92
|
-
el = onAdd ? onAdd(m) : (() => {
|
|
93
|
-
const div = document.createElement("div");
|
|
94
|
-
div.className = "maplibregl-ctrl";
|
|
95
|
-
return div;
|
|
96
|
-
})();
|
|
97
|
-
setContainer(el);
|
|
98
|
-
return el;
|
|
99
|
-
},
|
|
100
|
-
onRemove: (m) => {
|
|
101
|
-
onRemove?.(m);
|
|
102
|
-
el?.remove();
|
|
103
|
-
el = null;
|
|
104
|
-
setContainer(null);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
map.addControl(control, position);
|
|
108
|
-
return () => {
|
|
109
|
-
map.removeControl(control);
|
|
110
|
-
};
|
|
111
|
-
}, [map]);
|
|
112
|
-
return container ? (0, import_react_dom.createPortal)(children, container) : null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/components/controls.tsx
|
|
116
|
-
var import_maplibre_gl = __toESM(require("maplibre-gl"), 1);
|
|
117
|
-
var import_react3 = require("react");
|
|
118
|
-
function useControl(factory, options) {
|
|
119
|
-
const map = useMap();
|
|
120
|
-
const position = options?.position;
|
|
121
|
-
(0, import_react3.useEffect)(() => {
|
|
122
|
-
const ctrl = factory();
|
|
123
|
-
map.addControl(ctrl, position);
|
|
124
|
-
return () => {
|
|
125
|
-
safeRemoveControl(map, ctrl);
|
|
126
|
-
};
|
|
127
|
-
}, [map, position]);
|
|
128
|
-
}
|
|
129
|
-
function defined(obj) {
|
|
130
|
-
const out = {};
|
|
131
|
-
for (const k of Object.keys(obj)) {
|
|
132
|
-
if (obj[k] !== void 0) out[k] = obj[k];
|
|
133
|
-
}
|
|
134
|
-
return out;
|
|
135
|
-
}
|
|
136
|
-
function safeRemoveControl(map, ctrl) {
|
|
137
|
-
try {
|
|
138
|
-
map.removeControl(ctrl);
|
|
139
|
-
} catch {
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function NavigationControl({
|
|
143
|
-
position = "top-right",
|
|
144
|
-
showCompass,
|
|
145
|
-
showZoom,
|
|
146
|
-
visualizePitch
|
|
147
|
-
} = {}) {
|
|
148
|
-
const map = useMap();
|
|
149
|
-
(0, import_react3.useEffect)(() => {
|
|
150
|
-
const ctrl = new import_maplibre_gl.default.NavigationControl(
|
|
151
|
-
defined({ showCompass, showZoom, visualizePitch })
|
|
152
|
-
);
|
|
153
|
-
map.addControl(ctrl, position);
|
|
154
|
-
return () => {
|
|
155
|
-
safeRemoveControl(map, ctrl);
|
|
156
|
-
};
|
|
157
|
-
}, [map, position, showCompass, showZoom, visualizePitch]);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
function GeolocateControl({
|
|
161
|
-
position = "top-right",
|
|
162
|
-
positionOptions,
|
|
163
|
-
fitBoundsOptions,
|
|
164
|
-
trackUserLocation,
|
|
165
|
-
showAccuracyCircle,
|
|
166
|
-
showUserLocation
|
|
167
|
-
} = {}) {
|
|
168
|
-
const map = useMap();
|
|
169
|
-
(0, import_react3.useEffect)(() => {
|
|
170
|
-
const ctrl = new import_maplibre_gl.default.GeolocateControl(
|
|
171
|
-
defined({
|
|
172
|
-
positionOptions,
|
|
173
|
-
fitBoundsOptions,
|
|
174
|
-
trackUserLocation,
|
|
175
|
-
showAccuracyCircle,
|
|
176
|
-
showUserLocation
|
|
177
|
-
})
|
|
178
|
-
);
|
|
179
|
-
map.addControl(ctrl, position);
|
|
180
|
-
return () => {
|
|
181
|
-
safeRemoveControl(map, ctrl);
|
|
182
|
-
};
|
|
183
|
-
}, [
|
|
184
|
-
map,
|
|
185
|
-
position,
|
|
186
|
-
positionOptions,
|
|
187
|
-
fitBoundsOptions,
|
|
188
|
-
trackUserLocation,
|
|
189
|
-
showAccuracyCircle,
|
|
190
|
-
showUserLocation
|
|
191
|
-
]);
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
function FullscreenControl({
|
|
195
|
-
position = "top-right",
|
|
196
|
-
container
|
|
197
|
-
} = {}) {
|
|
198
|
-
const map = useMap();
|
|
199
|
-
(0, import_react3.useEffect)(() => {
|
|
200
|
-
const ctrl = new import_maplibre_gl.default.FullscreenControl(defined({ container }));
|
|
201
|
-
map.addControl(ctrl, position);
|
|
202
|
-
return () => {
|
|
203
|
-
safeRemoveControl(map, ctrl);
|
|
204
|
-
};
|
|
205
|
-
}, [map, position, container]);
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
function ScaleControl({
|
|
209
|
-
position = "bottom-left",
|
|
210
|
-
maxWidth,
|
|
211
|
-
unit
|
|
212
|
-
} = {}) {
|
|
213
|
-
const map = useMap();
|
|
214
|
-
(0, import_react3.useEffect)(() => {
|
|
215
|
-
const ctrl = new import_maplibre_gl.default.ScaleControl(defined({ maxWidth, unit }));
|
|
216
|
-
map.addControl(ctrl, position);
|
|
217
|
-
return () => {
|
|
218
|
-
safeRemoveControl(map, ctrl);
|
|
219
|
-
};
|
|
220
|
-
}, [map, position, maxWidth, unit]);
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
function AttributionControl({
|
|
224
|
-
position = "bottom-right",
|
|
225
|
-
compact,
|
|
226
|
-
customAttribution
|
|
227
|
-
} = {}) {
|
|
228
|
-
const map = useMap();
|
|
229
|
-
(0, import_react3.useEffect)(() => {
|
|
230
|
-
const ctrl = new import_maplibre_gl.default.AttributionControl(
|
|
231
|
-
defined({ compact, customAttribution })
|
|
232
|
-
);
|
|
233
|
-
map.addControl(ctrl, position);
|
|
234
|
-
return () => {
|
|
235
|
-
safeRemoveControl(map, ctrl);
|
|
236
|
-
};
|
|
237
|
-
}, [map, position, compact, customAttribution]);
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// src/components/layer.tsx
|
|
242
|
-
var import_react5 = require("react");
|
|
243
|
-
|
|
244
|
-
// src/source-context.ts
|
|
245
|
-
var import_react4 = require("react");
|
|
246
|
-
var SourceContext = (0, import_react4.createContext)(null);
|
|
247
|
-
function useSourceId() {
|
|
248
|
-
return (0, import_react4.useContext)(SourceContext);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// src/components/layer.tsx
|
|
252
|
-
function shallowEqual(a, b) {
|
|
253
|
-
if (a === b) return true;
|
|
254
|
-
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
255
|
-
const ka = Object.keys(a);
|
|
256
|
-
const kb = Object.keys(b);
|
|
257
|
-
if (ka.length !== kb.length) return false;
|
|
258
|
-
for (const k of ka) {
|
|
259
|
-
if (a[k] !== b[k]) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
function deepEqual(a, b) {
|
|
266
|
-
if (a === b) return true;
|
|
267
|
-
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
268
|
-
return false;
|
|
269
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
270
|
-
const ka = Object.keys(a);
|
|
271
|
-
const kb = Object.keys(b);
|
|
272
|
-
if (ka.length !== kb.length) return false;
|
|
273
|
-
for (const k of ka) {
|
|
274
|
-
if (!deepEqual(
|
|
275
|
-
a[k],
|
|
276
|
-
b[k]
|
|
277
|
-
)) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
function Layer({ beforeId, ...layerSpec }) {
|
|
284
|
-
const map = useMap();
|
|
285
|
-
const ctxSourceId = useSourceId();
|
|
286
|
-
const spec = ctxSourceId && !("source" in layerSpec && layerSpec.source) ? { ...layerSpec, source: ctxSourceId } : layerSpec;
|
|
287
|
-
const prevRef = (0, import_react5.useRef)({});
|
|
288
|
-
(0, import_react5.useEffect)(() => {
|
|
289
|
-
map.addLayer(spec, beforeId);
|
|
290
|
-
prevRef.current = {
|
|
291
|
-
paint: layerSpec.paint ?? void 0,
|
|
292
|
-
layout: layerSpec.layout ?? void 0,
|
|
293
|
-
filter: layerSpec.filter,
|
|
294
|
-
minzoom: layerSpec.minzoom,
|
|
295
|
-
maxzoom: layerSpec.maxzoom,
|
|
296
|
-
beforeId
|
|
297
|
-
};
|
|
298
|
-
return () => {
|
|
299
|
-
try {
|
|
300
|
-
if (map.getLayer(layerSpec.id)) {
|
|
301
|
-
map.removeLayer(layerSpec.id);
|
|
302
|
-
}
|
|
303
|
-
} catch {
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
}, [map, layerSpec.id]);
|
|
307
|
-
(0, import_react5.useEffect)(() => {
|
|
308
|
-
try {
|
|
309
|
-
if (!map.getLayer(layerSpec.id)) return;
|
|
310
|
-
const prev = prevRef.current;
|
|
311
|
-
const id = layerSpec.id;
|
|
312
|
-
const nextPaint = layerSpec.paint ?? {};
|
|
313
|
-
const prevPaint = prev.paint ?? {};
|
|
314
|
-
if (!shallowEqual(prevPaint, nextPaint)) {
|
|
315
|
-
const keys = /* @__PURE__ */ new Set([
|
|
316
|
-
...Object.keys(prevPaint),
|
|
317
|
-
...Object.keys(nextPaint)
|
|
318
|
-
]);
|
|
319
|
-
for (const k of keys) {
|
|
320
|
-
if (prevPaint[k] !== nextPaint[k]) {
|
|
321
|
-
map.setPaintProperty(id, k, nextPaint[k]);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
const nextLayout = layerSpec.layout ?? {};
|
|
326
|
-
const prevLayout = prev.layout ?? {};
|
|
327
|
-
if (!shallowEqual(prevLayout, nextLayout)) {
|
|
328
|
-
const keys = /* @__PURE__ */ new Set([
|
|
329
|
-
...Object.keys(prevLayout),
|
|
330
|
-
...Object.keys(nextLayout)
|
|
331
|
-
]);
|
|
332
|
-
for (const k of keys) {
|
|
333
|
-
if (prevLayout[k] !== nextLayout[k]) {
|
|
334
|
-
map.setLayoutProperty(id, k, nextLayout[k]);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
const nextFilter = layerSpec.filter;
|
|
339
|
-
if (!deepEqual(prev.filter, nextFilter)) {
|
|
340
|
-
map.setFilter(id, nextFilter ?? null);
|
|
341
|
-
}
|
|
342
|
-
const nextMin = layerSpec.minzoom;
|
|
343
|
-
const nextMax = layerSpec.maxzoom;
|
|
344
|
-
if (prev.minzoom !== nextMin || prev.maxzoom !== nextMax) {
|
|
345
|
-
map.setLayerZoomRange(id, nextMin ?? 0, nextMax ?? 24);
|
|
346
|
-
}
|
|
347
|
-
if (prev.beforeId !== beforeId) {
|
|
348
|
-
map.moveLayer(id, beforeId);
|
|
349
|
-
}
|
|
350
|
-
prevRef.current = {
|
|
351
|
-
paint: nextPaint,
|
|
352
|
-
layout: nextLayout,
|
|
353
|
-
filter: nextFilter,
|
|
354
|
-
minzoom: nextMin,
|
|
355
|
-
maxzoom: nextMax,
|
|
356
|
-
beforeId
|
|
357
|
-
};
|
|
358
|
-
} catch {
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// src/components/map.tsx
|
|
365
|
-
var import_maps_core = require("@geolonia/maps-core");
|
|
366
|
-
var import_react6 = require("react");
|
|
367
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
368
|
-
var DEFAULT_CENTER = [139.767125, 35.681236];
|
|
369
|
-
var DEFAULT_ZOOM = 14;
|
|
370
|
-
var HANDLER_NAMES = {
|
|
371
|
-
onClick: "click",
|
|
372
|
-
onDblClick: "dblclick",
|
|
373
|
-
onMouseDown: "mousedown",
|
|
374
|
-
onMouseUp: "mouseup",
|
|
375
|
-
onMouseMove: "mousemove",
|
|
376
|
-
onMouseEnter: "mouseenter",
|
|
377
|
-
onMouseLeave: "mouseleave",
|
|
378
|
-
onMouseOver: "mouseover",
|
|
379
|
-
onMouseOut: "mouseout",
|
|
380
|
-
onContextMenu: "contextmenu",
|
|
381
|
-
onWheel: "wheel",
|
|
382
|
-
onTouchStart: "touchstart",
|
|
383
|
-
onTouchEnd: "touchend",
|
|
384
|
-
onTouchMove: "touchmove",
|
|
385
|
-
onTouchCancel: "touchcancel",
|
|
386
|
-
onMoveStart: "movestart",
|
|
387
|
-
onMove: "move",
|
|
388
|
-
onMoveEnd: "moveend",
|
|
389
|
-
onZoomStart: "zoomstart",
|
|
390
|
-
onZoom: "zoom",
|
|
391
|
-
onZoomEnd: "zoomend",
|
|
392
|
-
onRotateStart: "rotatestart",
|
|
393
|
-
onRotate: "rotate",
|
|
394
|
-
onRotateEnd: "rotateend",
|
|
395
|
-
onPitchStart: "pitchstart",
|
|
396
|
-
onPitch: "pitch",
|
|
397
|
-
onPitchEnd: "pitchend",
|
|
398
|
-
onDragStart: "dragstart",
|
|
399
|
-
onDrag: "drag",
|
|
400
|
-
onDragEnd: "dragend",
|
|
401
|
-
onError: "error",
|
|
402
|
-
onIdle: "idle",
|
|
403
|
-
onRender: "render",
|
|
404
|
-
onResize: "resize",
|
|
405
|
-
onData: "data",
|
|
406
|
-
onStyleData: "styledata",
|
|
407
|
-
onSourceData: "sourcedata"
|
|
408
|
-
};
|
|
409
|
-
var POINTER_HANDLERS = /* @__PURE__ */ new Set([
|
|
410
|
-
"onClick",
|
|
411
|
-
"onDblClick",
|
|
412
|
-
"onMouseDown",
|
|
413
|
-
"onMouseUp",
|
|
414
|
-
"onMouseMove",
|
|
415
|
-
"onMouseOver",
|
|
416
|
-
"onMouseOut",
|
|
417
|
-
"onContextMenu"
|
|
418
|
-
]);
|
|
419
|
-
function toLngLatTuple(c) {
|
|
420
|
-
if (!c) return void 0;
|
|
421
|
-
if (Array.isArray(c)) return [c[0], c[1]];
|
|
422
|
-
if ("lng" in c) return [c.lng, c.lat];
|
|
423
|
-
if ("lon" in c) return [c.lon, c.lat];
|
|
424
|
-
return void 0;
|
|
425
|
-
}
|
|
426
|
-
var Map = (0, import_react6.forwardRef)((props, ref) => {
|
|
427
|
-
const {
|
|
428
|
-
id,
|
|
429
|
-
className,
|
|
430
|
-
containerStyle,
|
|
431
|
-
interactiveLayerIds,
|
|
432
|
-
cursor,
|
|
433
|
-
transitionType,
|
|
434
|
-
onLoad,
|
|
435
|
-
children,
|
|
436
|
-
...rest
|
|
437
|
-
} = props;
|
|
438
|
-
const containerRef = (0, import_react6.useRef)(null);
|
|
439
|
-
const [map, setMap] = (0, import_react6.useState)(null);
|
|
440
|
-
const registry = (0, import_react6.useContext)(MapProviderContext);
|
|
441
|
-
const registryRef = (0, import_react6.useRef)(registry);
|
|
442
|
-
registryRef.current = registry;
|
|
443
|
-
const handlersRef = (0, import_react6.useRef)({});
|
|
444
|
-
for (const key of Object.keys(HANDLER_NAMES)) {
|
|
445
|
-
handlersRef.current[key] = props[key];
|
|
446
|
-
}
|
|
447
|
-
const interactiveLayerIdsRef = (0, import_react6.useRef)(
|
|
448
|
-
interactiveLayerIds
|
|
449
|
-
);
|
|
450
|
-
interactiveLayerIdsRef.current = interactiveLayerIds;
|
|
451
|
-
const layerIdsKey = interactiveLayerIds?.join("|") ?? "";
|
|
452
|
-
const hoverStateRef = (0, import_react6.useRef)({ over: false });
|
|
453
|
-
(0, import_react6.useImperativeHandle)(ref, () => map, [map]);
|
|
454
|
-
(0, import_react6.useEffect)(() => {
|
|
455
|
-
if (!map || !id) return;
|
|
456
|
-
const r = registryRef.current;
|
|
457
|
-
if (!r) return;
|
|
458
|
-
r.register(id, map);
|
|
459
|
-
return () => {
|
|
460
|
-
registryRef.current?.unregister(id);
|
|
461
|
-
};
|
|
462
|
-
}, [map, id]);
|
|
463
|
-
(0, import_react6.useEffect)(() => {
|
|
464
|
-
if (!containerRef.current) return;
|
|
465
|
-
const mapOptions = { ...rest };
|
|
466
|
-
for (const key of Object.keys(HANDLER_NAMES)) {
|
|
467
|
-
delete mapOptions[key];
|
|
468
|
-
}
|
|
469
|
-
if (mapOptions.stage === void 0) {
|
|
470
|
-
delete mapOptions.stage;
|
|
471
|
-
}
|
|
472
|
-
const instance = new import_maps_core.GeoloniaMap({
|
|
473
|
-
center: DEFAULT_CENTER,
|
|
474
|
-
zoom: DEFAULT_ZOOM,
|
|
475
|
-
stage: import_maps_core.DEFAULT_STAGE,
|
|
476
|
-
...mapOptions,
|
|
477
|
-
container: containerRef.current
|
|
478
|
-
});
|
|
479
|
-
instance.on("load", () => {
|
|
480
|
-
onLoad?.(instance);
|
|
481
|
-
});
|
|
482
|
-
const queryFeatures = (point) => {
|
|
483
|
-
const layers = interactiveLayerIdsRef.current;
|
|
484
|
-
if (!layers?.length) return [];
|
|
485
|
-
const queryable = instance;
|
|
486
|
-
return queryable.queryRenderedFeatures?.(point, { layers }) ?? [];
|
|
487
|
-
};
|
|
488
|
-
const wrappers = [];
|
|
489
|
-
for (const [propName, eventName] of Object.entries(HANDLER_NAMES)) {
|
|
490
|
-
if (propName === "onMouseEnter" || propName === "onMouseLeave") {
|
|
491
|
-
const wrapper2 = (e) => {
|
|
492
|
-
if (interactiveLayerIdsRef.current?.length) return;
|
|
493
|
-
handlersRef.current[propName]?.(e);
|
|
494
|
-
};
|
|
495
|
-
instance.on(eventName, wrapper2);
|
|
496
|
-
wrappers.push([eventName, wrapper2]);
|
|
497
|
-
continue;
|
|
498
|
-
}
|
|
499
|
-
const wrapper = (e) => {
|
|
500
|
-
const handler = handlersRef.current[propName];
|
|
501
|
-
if (handler && POINTER_HANDLERS.has(propName) && interactiveLayerIdsRef.current?.length) {
|
|
502
|
-
e.features = queryFeatures(e.point);
|
|
503
|
-
}
|
|
504
|
-
handler?.(e);
|
|
505
|
-
};
|
|
506
|
-
instance.on(eventName, wrapper);
|
|
507
|
-
wrappers.push([eventName, wrapper]);
|
|
508
|
-
}
|
|
509
|
-
const hoverState = hoverStateRef.current;
|
|
510
|
-
const hoverMove = (e) => {
|
|
511
|
-
if (!interactiveLayerIdsRef.current?.length) return;
|
|
512
|
-
const features = e.features ?? queryFeatures(e.point);
|
|
513
|
-
const nowOver = features.length > 0;
|
|
514
|
-
if (nowOver && !hoverState.over) {
|
|
515
|
-
hoverState.over = true;
|
|
516
|
-
handlersRef.current.onMouseEnter?.({ ...e, features });
|
|
517
|
-
} else if (!nowOver && hoverState.over) {
|
|
518
|
-
hoverState.over = false;
|
|
519
|
-
handlersRef.current.onMouseLeave?.({ ...e, features });
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
instance.on("mousemove", hoverMove);
|
|
523
|
-
wrappers.push(["mousemove", hoverMove]);
|
|
524
|
-
const hoverCanvasLeave = (e) => {
|
|
525
|
-
if (!interactiveLayerIdsRef.current?.length) return;
|
|
526
|
-
if (hoverState.over) {
|
|
527
|
-
hoverState.over = false;
|
|
528
|
-
handlersRef.current.onMouseLeave?.({ ...e, features: [] });
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
instance.on("mouseleave", hoverCanvasLeave);
|
|
532
|
-
wrappers.push(["mouseleave", hoverCanvasLeave]);
|
|
533
|
-
setMap(instance);
|
|
534
|
-
return () => {
|
|
535
|
-
for (const [eventName, wrapper] of wrappers) {
|
|
536
|
-
instance.off(eventName, wrapper);
|
|
537
|
-
}
|
|
538
|
-
instance.remove();
|
|
539
|
-
setMap(null);
|
|
540
|
-
};
|
|
541
|
-
}, []);
|
|
542
|
-
(0, import_react6.useEffect)(() => {
|
|
543
|
-
if (!hoverStateRef.current.over) return;
|
|
544
|
-
hoverStateRef.current.over = false;
|
|
545
|
-
handlersRef.current.onMouseLeave?.({ features: [] });
|
|
546
|
-
}, [layerIdsKey]);
|
|
547
|
-
(0, import_react6.useEffect)(() => {
|
|
548
|
-
if (!map || cursor === void 0) return;
|
|
549
|
-
const canvas = map.getCanvas();
|
|
550
|
-
const prev = canvas.style.cursor;
|
|
551
|
-
canvas.style.cursor = cursor;
|
|
552
|
-
return () => {
|
|
553
|
-
canvas.style.cursor = prev;
|
|
554
|
-
};
|
|
555
|
-
}, [map, cursor]);
|
|
556
|
-
const centerTuple = toLngLatTuple(rest.center);
|
|
557
|
-
const lng = centerTuple?.[0];
|
|
558
|
-
const lat = centerTuple?.[1];
|
|
559
|
-
const zoom = rest.zoom;
|
|
560
|
-
const bearing = rest.bearing;
|
|
561
|
-
const pitch = rest.pitch;
|
|
562
|
-
const minZoom = rest.minZoom;
|
|
563
|
-
const maxZoom = rest.maxZoom;
|
|
564
|
-
const minPitch = rest.minPitch;
|
|
565
|
-
const maxPitch = rest.maxPitch;
|
|
566
|
-
const style = rest.style;
|
|
567
|
-
const prevStyleRef = (0, import_react6.useRef)(style);
|
|
568
|
-
(0, import_react6.useEffect)(() => {
|
|
569
|
-
if (!map) return;
|
|
570
|
-
const m = map;
|
|
571
|
-
const opts = {};
|
|
572
|
-
if (lng !== void 0 && lat !== void 0) {
|
|
573
|
-
const c = m.getCenter();
|
|
574
|
-
if (c.lng !== lng || c.lat !== lat) opts.center = [lng, lat];
|
|
575
|
-
}
|
|
576
|
-
if (zoom !== void 0 && m.getZoom() !== zoom) opts.zoom = zoom;
|
|
577
|
-
if (bearing !== void 0 && m.getBearing() !== bearing) {
|
|
578
|
-
opts.bearing = bearing;
|
|
579
|
-
}
|
|
580
|
-
if (pitch !== void 0 && m.getPitch() !== pitch) opts.pitch = pitch;
|
|
581
|
-
if (Object.keys(opts).length === 0) return;
|
|
582
|
-
if (transitionType === "jump") m.jumpTo(opts);
|
|
583
|
-
else m.flyTo(opts);
|
|
584
|
-
}, [map, lng, lat, zoom, bearing, pitch, transitionType]);
|
|
585
|
-
(0, import_react6.useEffect)(() => {
|
|
586
|
-
if (!map) return;
|
|
587
|
-
map.setMinZoom(
|
|
588
|
-
minZoom ?? null
|
|
589
|
-
);
|
|
590
|
-
}, [map, minZoom]);
|
|
591
|
-
(0, import_react6.useEffect)(() => {
|
|
592
|
-
if (!map) return;
|
|
593
|
-
map.setMaxZoom(
|
|
594
|
-
maxZoom ?? null
|
|
595
|
-
);
|
|
596
|
-
}, [map, maxZoom]);
|
|
597
|
-
(0, import_react6.useEffect)(() => {
|
|
598
|
-
if (!map) return;
|
|
599
|
-
map.setMinPitch(
|
|
600
|
-
minPitch ?? null
|
|
601
|
-
);
|
|
602
|
-
}, [map, minPitch]);
|
|
603
|
-
(0, import_react6.useEffect)(() => {
|
|
604
|
-
if (!map) return;
|
|
605
|
-
map.setMaxPitch(
|
|
606
|
-
maxPitch ?? null
|
|
607
|
-
);
|
|
608
|
-
}, [map, maxPitch]);
|
|
609
|
-
(0, import_react6.useEffect)(() => {
|
|
610
|
-
if (!map) return;
|
|
611
|
-
if (!style) return;
|
|
612
|
-
if (prevStyleRef.current === style) return;
|
|
613
|
-
prevStyleRef.current = style;
|
|
614
|
-
map.setStyle(style);
|
|
615
|
-
}, [map, style]);
|
|
616
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef, className, style: containerStyle, children: map && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapContext.Provider, { value: map, children }) });
|
|
617
|
-
});
|
|
618
|
-
Map.displayName = "Map";
|
|
619
|
-
|
|
620
|
-
// src/components/map-provider.tsx
|
|
621
|
-
var import_react7 = require("react");
|
|
622
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
623
|
-
function MapProvider({ children }) {
|
|
624
|
-
const [maps, setMaps] = (0, import_react7.useState)({});
|
|
625
|
-
const register = (0, import_react7.useCallback)((id, map) => {
|
|
626
|
-
setMaps((prev) => {
|
|
627
|
-
if (prev[id] === map) return prev;
|
|
628
|
-
return { ...prev, [id]: map };
|
|
629
|
-
});
|
|
630
|
-
}, []);
|
|
631
|
-
const unregister = (0, import_react7.useCallback)((id) => {
|
|
632
|
-
setMaps((prev) => {
|
|
633
|
-
if (!(id in prev)) return prev;
|
|
634
|
-
const next = { ...prev };
|
|
635
|
-
delete next[id];
|
|
636
|
-
return next;
|
|
637
|
-
});
|
|
638
|
-
}, []);
|
|
639
|
-
const value = (0, import_react7.useMemo)(
|
|
640
|
-
() => ({ maps, register, unregister }),
|
|
641
|
-
[maps, register, unregister]
|
|
642
|
-
);
|
|
643
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MapProviderContext.Provider, { value, children });
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// src/components/marker.tsx
|
|
647
|
-
var import_maps_core2 = require("@geolonia/maps-core");
|
|
648
|
-
var import_maplibre_gl2 = __toESM(require("maplibre-gl"), 1);
|
|
649
|
-
var import_react8 = require("react");
|
|
650
|
-
var import_react_dom2 = require("react-dom");
|
|
651
|
-
function Marker(props) {
|
|
652
|
-
const {
|
|
653
|
-
lat,
|
|
654
|
-
lng,
|
|
655
|
-
color,
|
|
656
|
-
openPopup,
|
|
657
|
-
draggable,
|
|
658
|
-
rotation,
|
|
659
|
-
offset,
|
|
660
|
-
anchor,
|
|
661
|
-
rotationAlignment,
|
|
662
|
-
pitchAlignment,
|
|
663
|
-
className,
|
|
664
|
-
children
|
|
665
|
-
} = props;
|
|
666
|
-
const map = useMap();
|
|
667
|
-
const markerRef = (0, import_react8.useRef)(null);
|
|
668
|
-
const popupEl = (0, import_react8.useRef)(document.createElement("div"));
|
|
669
|
-
const handlersRef = (0, import_react8.useRef)({});
|
|
670
|
-
handlersRef.current = {
|
|
671
|
-
onClick: props.onClick,
|
|
672
|
-
onDragStart: props.onDragStart,
|
|
673
|
-
onDrag: props.onDrag,
|
|
674
|
-
onDragEnd: props.onDragEnd
|
|
675
|
-
};
|
|
676
|
-
(0, import_react8.useEffect)(() => {
|
|
677
|
-
const marker = new import_maps_core2.GeoloniaMarker({
|
|
678
|
-
color,
|
|
679
|
-
draggable,
|
|
680
|
-
rotation,
|
|
681
|
-
offset,
|
|
682
|
-
anchor,
|
|
683
|
-
rotationAlignment,
|
|
684
|
-
pitchAlignment,
|
|
685
|
-
className
|
|
686
|
-
}).setLngLat([lng, lat]).addTo(map);
|
|
687
|
-
if (children) {
|
|
688
|
-
marker.setPopup(
|
|
689
|
-
new import_maplibre_gl2.default.Popup({ offset: [0, -30] }).setDOMContent(
|
|
690
|
-
popupEl.current
|
|
691
|
-
)
|
|
692
|
-
);
|
|
693
|
-
if (openPopup) marker.togglePopup();
|
|
694
|
-
}
|
|
695
|
-
const onClickWrapper = (e) => {
|
|
696
|
-
handlersRef.current.onClick?.(e);
|
|
697
|
-
};
|
|
698
|
-
const onDragStartWrapper = (e) => {
|
|
699
|
-
handlersRef.current.onDragStart?.(e);
|
|
700
|
-
};
|
|
701
|
-
const onDragWrapper = (e) => {
|
|
702
|
-
handlersRef.current.onDrag?.(e);
|
|
703
|
-
};
|
|
704
|
-
const onDragEndWrapper = (e) => {
|
|
705
|
-
handlersRef.current.onDragEnd?.(e);
|
|
706
|
-
};
|
|
707
|
-
const element = marker.getElement();
|
|
708
|
-
element.addEventListener("click", onClickWrapper);
|
|
709
|
-
marker.on("dragstart", onDragStartWrapper);
|
|
710
|
-
marker.on("drag", onDragWrapper);
|
|
711
|
-
marker.on("dragend", onDragEndWrapper);
|
|
712
|
-
markerRef.current = marker;
|
|
713
|
-
return () => {
|
|
714
|
-
element.removeEventListener("click", onClickWrapper);
|
|
715
|
-
marker.off("dragstart", onDragStartWrapper);
|
|
716
|
-
marker.off("drag", onDragWrapper);
|
|
717
|
-
marker.off("dragend", onDragEndWrapper);
|
|
718
|
-
marker.remove();
|
|
719
|
-
};
|
|
720
|
-
}, [map, color, anchor, className]);
|
|
721
|
-
(0, import_react8.useEffect)(() => {
|
|
722
|
-
markerRef.current?.setLngLat([lng, lat]);
|
|
723
|
-
}, [lat, lng]);
|
|
724
|
-
(0, import_react8.useEffect)(() => {
|
|
725
|
-
if (draggable === void 0) return;
|
|
726
|
-
markerRef.current?.setDraggable(draggable);
|
|
727
|
-
}, [draggable]);
|
|
728
|
-
(0, import_react8.useEffect)(() => {
|
|
729
|
-
if (rotation === void 0) return;
|
|
730
|
-
markerRef.current?.setRotation(rotation);
|
|
731
|
-
}, [rotation]);
|
|
732
|
-
(0, import_react8.useEffect)(() => {
|
|
733
|
-
if (offset === void 0) return;
|
|
734
|
-
markerRef.current?.setOffset(offset);
|
|
735
|
-
}, [offset]);
|
|
736
|
-
(0, import_react8.useEffect)(() => {
|
|
737
|
-
if (rotationAlignment === void 0) return;
|
|
738
|
-
markerRef.current?.setRotationAlignment(rotationAlignment);
|
|
739
|
-
}, [rotationAlignment]);
|
|
740
|
-
(0, import_react8.useEffect)(() => {
|
|
741
|
-
if (pitchAlignment === void 0) return;
|
|
742
|
-
markerRef.current?.setPitchAlignment(pitchAlignment);
|
|
743
|
-
}, [pitchAlignment]);
|
|
744
|
-
(0, import_react8.useEffect)(() => {
|
|
745
|
-
const marker = markerRef.current;
|
|
746
|
-
const popup = marker?.getPopup();
|
|
747
|
-
if (!popup) return;
|
|
748
|
-
const isOpen = popup.isOpen();
|
|
749
|
-
if (!!openPopup !== isOpen) marker?.togglePopup();
|
|
750
|
-
}, [openPopup]);
|
|
751
|
-
return children ? (0, import_react_dom2.createPortal)(children, popupEl.current) : null;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// src/components/popup.tsx
|
|
755
|
-
var import_maplibre_gl3 = __toESM(require("maplibre-gl"), 1);
|
|
756
|
-
var import_react9 = require("react");
|
|
757
|
-
var import_react_dom3 = require("react-dom");
|
|
758
|
-
function defined2(obj) {
|
|
759
|
-
const out = {};
|
|
760
|
-
for (const k of Object.keys(obj)) {
|
|
761
|
-
if (obj[k] !== void 0) out[k] = obj[k];
|
|
762
|
-
}
|
|
763
|
-
return out;
|
|
764
|
-
}
|
|
765
|
-
function Popup(props) {
|
|
766
|
-
const {
|
|
767
|
-
lat,
|
|
768
|
-
lng,
|
|
769
|
-
anchor,
|
|
770
|
-
offset,
|
|
771
|
-
closeButton,
|
|
772
|
-
closeOnClick,
|
|
773
|
-
closeOnMove,
|
|
774
|
-
maxWidth,
|
|
775
|
-
className,
|
|
776
|
-
children,
|
|
777
|
-
onClose
|
|
778
|
-
} = props;
|
|
779
|
-
const map = useMap();
|
|
780
|
-
const containerEl = (0, import_react9.useRef)(document.createElement("div"));
|
|
781
|
-
const popupRef = (0, import_react9.useRef)(null);
|
|
782
|
-
const onCloseRef = (0, import_react9.useRef)(onClose);
|
|
783
|
-
onCloseRef.current = onClose;
|
|
784
|
-
(0, import_react9.useEffect)(() => {
|
|
785
|
-
const popup = new import_maplibre_gl3.default.Popup(
|
|
786
|
-
defined2({
|
|
787
|
-
anchor,
|
|
788
|
-
offset,
|
|
789
|
-
closeButton,
|
|
790
|
-
closeOnClick,
|
|
791
|
-
closeOnMove,
|
|
792
|
-
maxWidth,
|
|
793
|
-
className
|
|
794
|
-
})
|
|
795
|
-
).setLngLat([lng, lat]).setDOMContent(containerEl.current).addTo(map);
|
|
796
|
-
popup.on("close", () => onCloseRef.current?.());
|
|
797
|
-
popupRef.current = popup;
|
|
798
|
-
return () => {
|
|
799
|
-
popup.remove();
|
|
800
|
-
};
|
|
801
|
-
}, [map, anchor, closeButton, closeOnClick, closeOnMove]);
|
|
802
|
-
(0, import_react9.useEffect)(() => {
|
|
803
|
-
popupRef.current?.setLngLat([lng, lat]);
|
|
804
|
-
}, [lat, lng]);
|
|
805
|
-
(0, import_react9.useEffect)(() => {
|
|
806
|
-
popupRef.current?.setOffset(offset);
|
|
807
|
-
}, [offset]);
|
|
808
|
-
(0, import_react9.useEffect)(() => {
|
|
809
|
-
popupRef.current?.setMaxWidth(maxWidth ?? "240px");
|
|
810
|
-
}, [maxWidth]);
|
|
811
|
-
const prevClassNameRef = (0, import_react9.useRef)(className);
|
|
812
|
-
(0, import_react9.useEffect)(() => {
|
|
813
|
-
const popup = popupRef.current;
|
|
814
|
-
if (!popup) return;
|
|
815
|
-
const prev = prevClassNameRef.current;
|
|
816
|
-
if (prev === className) return;
|
|
817
|
-
if (prev) popup.removeClassName(prev);
|
|
818
|
-
if (className) popup.addClassName(className);
|
|
819
|
-
prevClassNameRef.current = className;
|
|
820
|
-
}, [className]);
|
|
821
|
-
return (0, import_react_dom3.createPortal)(children, containerEl.current);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// src/components/source.tsx
|
|
825
|
-
var import_react10 = require("react");
|
|
826
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
827
|
-
var SUPPORTED_UPDATE_PROPS = {
|
|
828
|
-
geojson: ["data"],
|
|
829
|
-
image: ["url", "coordinates"],
|
|
830
|
-
// VideoSource exposes setCoordinates but no API to swap source urls at runtime
|
|
831
|
-
video: ["coordinates"],
|
|
832
|
-
canvas: ["coordinates"],
|
|
833
|
-
vector: ["url", "tiles"],
|
|
834
|
-
raster: ["url", "tiles"],
|
|
835
|
-
"raster-dem": ["url", "tiles"]
|
|
836
|
-
};
|
|
837
|
-
function Source({ id, children, ...spec }) {
|
|
838
|
-
const map = useMap();
|
|
839
|
-
const [ready, setReady] = (0, import_react10.useState)(false);
|
|
840
|
-
const prevSpecRef = (0, import_react10.useRef)(null);
|
|
841
|
-
(0, import_react10.useEffect)(() => {
|
|
842
|
-
let cancelled = false;
|
|
843
|
-
function add() {
|
|
844
|
-
if (cancelled || map.getSource(id)) return;
|
|
845
|
-
map.addSource(id, spec);
|
|
846
|
-
prevSpecRef.current = { ...spec };
|
|
847
|
-
if (!cancelled) setReady(true);
|
|
848
|
-
}
|
|
849
|
-
if (map.isStyleLoaded()) {
|
|
850
|
-
add();
|
|
851
|
-
} else {
|
|
852
|
-
map.once("styledata", add);
|
|
853
|
-
}
|
|
854
|
-
return () => {
|
|
855
|
-
cancelled = true;
|
|
856
|
-
map.off("styledata", add);
|
|
857
|
-
setReady(false);
|
|
858
|
-
try {
|
|
859
|
-
if (map.getSource(id)) {
|
|
860
|
-
map.getStyle()?.layers?.filter((l) => "source" in l && l.source === id).forEach((l) => {
|
|
861
|
-
map.removeLayer(l.id);
|
|
862
|
-
});
|
|
863
|
-
map.removeSource(id);
|
|
864
|
-
}
|
|
865
|
-
} catch {
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
}, [map, id]);
|
|
869
|
-
(0, import_react10.useEffect)(() => {
|
|
870
|
-
if (!ready) return;
|
|
871
|
-
const source = map.getSource(id);
|
|
872
|
-
if (!source) return;
|
|
873
|
-
const prev = prevSpecRef.current;
|
|
874
|
-
if (!prev) return;
|
|
875
|
-
const supported = SUPPORTED_UPDATE_PROPS[spec.type] ?? [];
|
|
876
|
-
const current = spec;
|
|
877
|
-
if (prev.type !== current.type) {
|
|
878
|
-
console.warn(
|
|
879
|
-
`[<Source id="${id}">] prop "type" changed from "${prev.type}" to "${current.type}" but is not updatable. Source must be re-mounted with a different id to apply.`
|
|
880
|
-
);
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
const allKeys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(current)]);
|
|
884
|
-
for (const key of allKeys) {
|
|
885
|
-
if (key === "id" || key === "type") continue;
|
|
886
|
-
if (prev[key] === current[key]) continue;
|
|
887
|
-
if (!supported.includes(key)) {
|
|
888
|
-
console.warn(
|
|
889
|
-
`[<Source id="${id}">] prop "${key}" is not updatable for type "${spec.type}". Source must be re-mounted to apply.`
|
|
890
|
-
);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
switch (spec.type) {
|
|
894
|
-
case "geojson": {
|
|
895
|
-
const data = current.data;
|
|
896
|
-
if (data !== void 0 && data !== prev.data) {
|
|
897
|
-
source.setData(data);
|
|
898
|
-
}
|
|
899
|
-
break;
|
|
900
|
-
}
|
|
901
|
-
case "image": {
|
|
902
|
-
const url = current.url;
|
|
903
|
-
const coordinates = current.coordinates;
|
|
904
|
-
if (url !== void 0 && url !== prev.url) {
|
|
905
|
-
source.updateImage?.({ url });
|
|
906
|
-
}
|
|
907
|
-
if (coordinates !== void 0 && coordinates !== prev.coordinates) {
|
|
908
|
-
source.setCoordinates?.(coordinates);
|
|
909
|
-
}
|
|
910
|
-
break;
|
|
911
|
-
}
|
|
912
|
-
case "video": {
|
|
913
|
-
const coordinates = current.coordinates;
|
|
914
|
-
if (coordinates !== void 0 && coordinates !== prev.coordinates) {
|
|
915
|
-
source.setCoordinates?.(coordinates);
|
|
916
|
-
}
|
|
917
|
-
break;
|
|
918
|
-
}
|
|
919
|
-
case "canvas": {
|
|
920
|
-
const coordinates = current.coordinates;
|
|
921
|
-
if (coordinates !== void 0 && coordinates !== prev.coordinates) {
|
|
922
|
-
source.setCoordinates(coordinates);
|
|
923
|
-
}
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
case "vector":
|
|
927
|
-
case "raster":
|
|
928
|
-
case "raster-dem": {
|
|
929
|
-
const url = current.url;
|
|
930
|
-
const tiles = current.tiles;
|
|
931
|
-
if (url !== void 0 && url !== prev.url) {
|
|
932
|
-
source.setUrl(url);
|
|
933
|
-
}
|
|
934
|
-
if (tiles !== void 0 && tiles !== prev.tiles) {
|
|
935
|
-
source.setTiles(tiles);
|
|
936
|
-
}
|
|
937
|
-
break;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
prevSpecRef.current = { ...current };
|
|
941
|
-
});
|
|
942
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SourceContext.Provider, { value: id, children: ready && children });
|
|
943
|
-
}
|
|
944
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
945
|
-
0 && (module.exports = {
|
|
946
|
-
AttributionControl,
|
|
947
|
-
Control,
|
|
948
|
-
FullscreenControl,
|
|
949
|
-
GeolocateControl,
|
|
950
|
-
Layer,
|
|
951
|
-
Map,
|
|
952
|
-
MapContext,
|
|
953
|
-
MapProvider,
|
|
954
|
-
MapProviderContext,
|
|
955
|
-
Marker,
|
|
956
|
-
NavigationControl,
|
|
957
|
-
Popup,
|
|
958
|
-
ScaleControl,
|
|
959
|
-
Source,
|
|
960
|
-
SourceContext,
|
|
961
|
-
useControl,
|
|
962
|
-
useMap,
|
|
963
|
-
useMaps,
|
|
964
|
-
useSourceId
|
|
965
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { Map as Map$1, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, NavigationControlOptions, ScaleControlOptions, IControl, LayerSpecification, PointLike, PositionAnchor, Alignment, SourceSpecification, CanvasSourceSpecification } from 'maplibre-gl';
|
|
4
|
-
import { GeoloniaMapOptions, GeoloniaMap } from '@geolonia/maps-core';
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
type ControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
8
|
-
type ControlProps = {
|
|
9
|
-
position?: ControlPosition;
|
|
10
|
-
onAdd?: (map: Map$1) => HTMLElement;
|
|
11
|
-
onRemove?: (map: Map$1) => void;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
};
|
|
14
|
-
declare function Control({ position, onAdd, onRemove, children, }: ControlProps): react.ReactPortal | null;
|
|
15
|
-
|
|
16
|
-
declare function useControl<T extends IControl>(factory: () => T, options?: {
|
|
17
|
-
position?: ControlPosition;
|
|
18
|
-
}): void;
|
|
19
|
-
type NavigationControlProps = NavigationControlOptions & {
|
|
20
|
-
position?: ControlPosition;
|
|
21
|
-
};
|
|
22
|
-
declare function NavigationControl({ position, showCompass, showZoom, visualizePitch, }?: NavigationControlProps): null;
|
|
23
|
-
type GeolocateControlProps = GeolocateControlOptions & {
|
|
24
|
-
position?: ControlPosition;
|
|
25
|
-
};
|
|
26
|
-
declare function GeolocateControl({ position, positionOptions, fitBoundsOptions, trackUserLocation, showAccuracyCircle, showUserLocation, }?: GeolocateControlProps): null;
|
|
27
|
-
type FullscreenControlProps = FullscreenControlOptions & {
|
|
28
|
-
position?: ControlPosition;
|
|
29
|
-
};
|
|
30
|
-
declare function FullscreenControl({ position, container, }?: FullscreenControlProps): null;
|
|
31
|
-
type ScaleControlProps = ScaleControlOptions & {
|
|
32
|
-
position?: ControlPosition;
|
|
33
|
-
};
|
|
34
|
-
declare function ScaleControl({ position, maxWidth, unit, }?: ScaleControlProps): null;
|
|
35
|
-
type AttributionControlProps = AttributionControlOptions & {
|
|
36
|
-
position?: ControlPosition;
|
|
37
|
-
};
|
|
38
|
-
declare function AttributionControl({ position, compact, customAttribution, }?: AttributionControlProps): null;
|
|
39
|
-
|
|
40
|
-
type LayerProps = LayerSpecification & {
|
|
41
|
-
beforeId?: string;
|
|
42
|
-
};
|
|
43
|
-
declare function Layer({ beforeId, ...layerSpec }: LayerProps): null;
|
|
44
|
-
|
|
45
|
-
declare const HANDLER_NAMES: {
|
|
46
|
-
readonly onClick: "click";
|
|
47
|
-
readonly onDblClick: "dblclick";
|
|
48
|
-
readonly onMouseDown: "mousedown";
|
|
49
|
-
readonly onMouseUp: "mouseup";
|
|
50
|
-
readonly onMouseMove: "mousemove";
|
|
51
|
-
readonly onMouseEnter: "mouseenter";
|
|
52
|
-
readonly onMouseLeave: "mouseleave";
|
|
53
|
-
readonly onMouseOver: "mouseover";
|
|
54
|
-
readonly onMouseOut: "mouseout";
|
|
55
|
-
readonly onContextMenu: "contextmenu";
|
|
56
|
-
readonly onWheel: "wheel";
|
|
57
|
-
readonly onTouchStart: "touchstart";
|
|
58
|
-
readonly onTouchEnd: "touchend";
|
|
59
|
-
readonly onTouchMove: "touchmove";
|
|
60
|
-
readonly onTouchCancel: "touchcancel";
|
|
61
|
-
readonly onMoveStart: "movestart";
|
|
62
|
-
readonly onMove: "move";
|
|
63
|
-
readonly onMoveEnd: "moveend";
|
|
64
|
-
readonly onZoomStart: "zoomstart";
|
|
65
|
-
readonly onZoom: "zoom";
|
|
66
|
-
readonly onZoomEnd: "zoomend";
|
|
67
|
-
readonly onRotateStart: "rotatestart";
|
|
68
|
-
readonly onRotate: "rotate";
|
|
69
|
-
readonly onRotateEnd: "rotateend";
|
|
70
|
-
readonly onPitchStart: "pitchstart";
|
|
71
|
-
readonly onPitch: "pitch";
|
|
72
|
-
readonly onPitchEnd: "pitchend";
|
|
73
|
-
readonly onDragStart: "dragstart";
|
|
74
|
-
readonly onDrag: "drag";
|
|
75
|
-
readonly onDragEnd: "dragend";
|
|
76
|
-
readonly onError: "error";
|
|
77
|
-
readonly onIdle: "idle";
|
|
78
|
-
readonly onRender: "render";
|
|
79
|
-
readonly onResize: "resize";
|
|
80
|
-
readonly onData: "data";
|
|
81
|
-
readonly onStyleData: "styledata";
|
|
82
|
-
readonly onSourceData: "sourcedata";
|
|
83
|
-
};
|
|
84
|
-
type HandlerKey = keyof typeof HANDLER_NAMES;
|
|
85
|
-
type MapEventHandler = (e: any) => void;
|
|
86
|
-
type MapEventProps = {
|
|
87
|
-
[K in HandlerKey]?: MapEventHandler;
|
|
88
|
-
};
|
|
89
|
-
type MapProps = Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
|
|
90
|
-
id?: string;
|
|
91
|
-
className?: string;
|
|
92
|
-
containerStyle?: CSSProperties;
|
|
93
|
-
interactiveLayerIds?: string[];
|
|
94
|
-
cursor?: string;
|
|
95
|
-
/** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
|
|
96
|
-
transitionType?: "fly" | "jump";
|
|
97
|
-
onLoad?: (map: GeoloniaMap) => void;
|
|
98
|
-
children?: ReactNode;
|
|
99
|
-
};
|
|
100
|
-
declare const Map: react.ForwardRefExoticComponent<Omit<GeoloniaMapOptions, "container"> & MapEventProps & {
|
|
101
|
-
id?: string;
|
|
102
|
-
className?: string;
|
|
103
|
-
containerStyle?: CSSProperties;
|
|
104
|
-
interactiveLayerIds?: string[];
|
|
105
|
-
cursor?: string;
|
|
106
|
-
/** Camera transition style for reactive center/zoom/bearing/pitch changes. Default `"fly"`. */
|
|
107
|
-
transitionType?: "fly" | "jump";
|
|
108
|
-
onLoad?: (map: GeoloniaMap) => void;
|
|
109
|
-
children?: ReactNode;
|
|
110
|
-
} & react.RefAttributes<GeoloniaMap | null>>;
|
|
111
|
-
|
|
112
|
-
type MapProviderProps = {
|
|
113
|
-
children?: ReactNode;
|
|
114
|
-
};
|
|
115
|
-
declare function MapProvider({ children }: MapProviderProps): react_jsx_runtime.JSX.Element;
|
|
116
|
-
|
|
117
|
-
type MarkerEventHandler = (e: any) => void;
|
|
118
|
-
type MarkerProps = {
|
|
119
|
-
lat: number;
|
|
120
|
-
lng: number;
|
|
121
|
-
color?: string;
|
|
122
|
-
openPopup?: boolean;
|
|
123
|
-
draggable?: boolean;
|
|
124
|
-
rotation?: number;
|
|
125
|
-
offset?: PointLike;
|
|
126
|
-
anchor?: PositionAnchor;
|
|
127
|
-
rotationAlignment?: Alignment;
|
|
128
|
-
pitchAlignment?: Alignment;
|
|
129
|
-
className?: string;
|
|
130
|
-
onClick?: (e: MouseEvent) => void;
|
|
131
|
-
onDragStart?: MarkerEventHandler;
|
|
132
|
-
onDrag?: MarkerEventHandler;
|
|
133
|
-
onDragEnd?: MarkerEventHandler;
|
|
134
|
-
children?: ReactNode;
|
|
135
|
-
};
|
|
136
|
-
declare function Marker(props: MarkerProps): react.ReactPortal | null;
|
|
137
|
-
|
|
138
|
-
type PopupProps = {
|
|
139
|
-
lat: number;
|
|
140
|
-
lng: number;
|
|
141
|
-
anchor?: PositionAnchor;
|
|
142
|
-
offset?: PointLike;
|
|
143
|
-
closeButton?: boolean;
|
|
144
|
-
closeOnClick?: boolean;
|
|
145
|
-
closeOnMove?: boolean;
|
|
146
|
-
maxWidth?: string;
|
|
147
|
-
className?: string;
|
|
148
|
-
children?: ReactNode;
|
|
149
|
-
onClose?: () => void;
|
|
150
|
-
};
|
|
151
|
-
declare function Popup(props: PopupProps): react.ReactPortal;
|
|
152
|
-
|
|
153
|
-
type SourceProps = (SourceSpecification | CanvasSourceSpecification) & {
|
|
154
|
-
id: string;
|
|
155
|
-
children?: ReactNode;
|
|
156
|
-
};
|
|
157
|
-
declare function Source({ id, children, ...spec }: SourceProps): react_jsx_runtime.JSX.Element;
|
|
158
|
-
|
|
159
|
-
declare const MapContext: react.Context<GeoloniaMap | null>;
|
|
160
|
-
type MapCollection = {
|
|
161
|
-
current?: GeoloniaMap;
|
|
162
|
-
maps: Record<string, GeoloniaMap>;
|
|
163
|
-
};
|
|
164
|
-
type MapRegistry = {
|
|
165
|
-
maps: Record<string, GeoloniaMap>;
|
|
166
|
-
register: (id: string, map: GeoloniaMap) => void;
|
|
167
|
-
unregister: (id: string) => void;
|
|
168
|
-
};
|
|
169
|
-
declare const MapProviderContext: react.Context<MapRegistry | null>;
|
|
170
|
-
declare function useMap(): GeoloniaMap;
|
|
171
|
-
declare function useMaps(): MapCollection;
|
|
172
|
-
|
|
173
|
-
declare const SourceContext: react.Context<string | null>;
|
|
174
|
-
declare function useSourceId(): string | null;
|
|
175
|
-
|
|
176
|
-
export { AttributionControl, type AttributionControlProps, Control, type ControlPosition, type ControlProps, FullscreenControl, type FullscreenControlProps, GeolocateControl, type GeolocateControlProps, Layer, type LayerProps, Map, type MapCollection, MapContext, type MapEventProps, type MapProps, MapProvider, MapProviderContext, type MapProviderProps, type MapRegistry, Marker, type MarkerProps, NavigationControl, type NavigationControlProps, Popup, type PopupProps, ScaleControl, type ScaleControlProps, Source, SourceContext, type SourceProps, useControl, useMap, useMaps, useSourceId };
|