@local-logic/maps 0.0.12 → 0.0.14
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/dist/index-58w3Qwxr.js +56 -0
- package/dist/index-BGoTpJjt.js +81 -0
- package/dist/index-Bp1bWq9c.js +690 -0
- package/dist/{index-DFdfOz0d.js → index-C36u5N_F.js} +1 -1
- package/dist/{index-B3NH4rqN.js → index-CBp9gCca.js} +8 -8
- package/dist/index-CCtDJ-mV.js +56 -0
- package/dist/index-CFomI3Il.js +98 -0
- package/dist/index-CUpaKIZP.js +105 -0
- package/dist/index-CXTsUiSS.js +57 -0
- package/dist/index-CXUQoF5Q.js +34 -0
- package/dist/{index-B9YXnLOH.js → index-DY5pY-zk.js} +11 -10
- package/dist/index-S5SfktvB.js +79 -0
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +75 -75
- package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts +1 -1
- package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts +1 -1
- package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts +1 -1
- package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/BaseMap/index.d.ts +1 -1
- package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/BaseMap/types.d.ts +10 -1
- package/dist/src/components/Map/Root/BaseMap/types.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Layers/types.d.ts +3 -2
- package/dist/src/components/Map/Root/Layers/types.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Markers/Google/index.d.ts +1 -1
- package/dist/src/components/Map/Root/Markers/Google/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts +1 -1
- package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts +1 -1
- package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Markers/index.d.ts +1 -1
- package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Markers/types.d.ts +0 -11
- package/dist/src/components/Map/Root/Markers/types.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Popup/Google/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/Popup/index.d.ts +1 -1
- package/dist/src/components/Map/Root/Popup/index.d.ts.map +1 -1
- package/dist/src/components/Map/Root/constants.d.ts +3 -0
- package/dist/src/components/Map/Root/constants.d.ts.map +1 -1
- package/dist/src/components/Map/Root/context.d.ts +2 -0
- package/dist/src/components/Map/Root/context.d.ts.map +1 -1
- package/dist/src/components/Map/Root/index.d.ts.map +1 -1
- package/dist/src/components/Map/index.d.ts +1 -1
- package/dist/src/components/Map/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index-BcpSqK0X.js +0 -74
- package/dist/index-Bd7meO8V.js +0 -783
- package/dist/index-BhldVNew.js +0 -35
- package/dist/index-Bu4XEiYU.js +0 -74
- package/dist/index-CzBPD5Sw.js +0 -73
- package/dist/index-DsrEcQq0.js +0 -71
- package/dist/index-LKvWHhi6.js +0 -53
- package/dist/index-aDlW4ps0.js +0 -50
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
2
|
+
import * as U from "react";
|
|
3
|
+
import it, { useContext as at, useState as v, useMemo as P, lazy as w, useRef as V, useEffect as ct } from "react";
|
|
4
|
+
const tt = it.createContext({}), R = () => at(tt), I = {
|
|
5
|
+
zoom: 14,
|
|
6
|
+
pitch: 0,
|
|
7
|
+
bearing: 0,
|
|
8
|
+
cooperativeGestures: !1
|
|
9
|
+
}, H = {
|
|
10
|
+
maptiler: "600d69cb-288d-445e-9839-3dfe4d76b31a",
|
|
11
|
+
mapbox: "locallogic/cmb9nz9kb011501ru8drq8fqf",
|
|
12
|
+
google: "a7ff20eb973126bb"
|
|
13
|
+
}, Y = 13, ut = 22, Ht = 12.5, ht = 30, pt = 60, lt = "w-full h-full relative overflow-hidden", ft = w(() => import("./index-S5SfktvB.js")), dt = w(() => import("./index-CUpaKIZP.js")), gt = w(() => import("./index-BGoTpJjt.js")), mt = w(() => import("./index-qqbvBkdn.js")), yt = ({ padding: r = 1e-3, children: t }) => {
|
|
14
|
+
const {
|
|
15
|
+
mapProvider: e,
|
|
16
|
+
center: n,
|
|
17
|
+
zoom: o = I.zoom,
|
|
18
|
+
pitch: i = I.pitch,
|
|
19
|
+
bearing: a = I.bearing,
|
|
20
|
+
cooperativeGestures: c = I.cooperativeGestures,
|
|
21
|
+
zoomPosition: s
|
|
22
|
+
} = R(), [h] = v(o), p = P(() => {
|
|
23
|
+
switch (e == null ? void 0 : e.name) {
|
|
24
|
+
case "maptiler":
|
|
25
|
+
return ft;
|
|
26
|
+
case "google":
|
|
27
|
+
return dt;
|
|
28
|
+
case "mapbox":
|
|
29
|
+
return gt;
|
|
30
|
+
default:
|
|
31
|
+
return mt;
|
|
32
|
+
}
|
|
33
|
+
}, [e]);
|
|
34
|
+
return /* @__PURE__ */ T(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: lt,
|
|
38
|
+
"data-testid": "base-map",
|
|
39
|
+
"data-map-provider-name": e == null ? void 0 : e.name,
|
|
40
|
+
"data-map-provider-theme": (e == null ? void 0 : e.theme) || H[e == null ? void 0 : e.name] || H.maptiler,
|
|
41
|
+
"data-initial-zoom": h,
|
|
42
|
+
"data-pitch": i,
|
|
43
|
+
"data-bearing": a,
|
|
44
|
+
"data-cooperative-gestures": c,
|
|
45
|
+
"data-zoom-position": s,
|
|
46
|
+
"data-center-latitude": n.latitude,
|
|
47
|
+
"data-center-longitude": n.longitude,
|
|
48
|
+
children: /* @__PURE__ */ T(p, { padding: r, children: t })
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}, wt = w(() => import("./index-Do_dW76Q.js")), Mt = w(() => import("./index-BCa658u4.js")), _t = w(() => import("./index-CNxLnZ8O.js"));
|
|
52
|
+
function At(r) {
|
|
53
|
+
const { mapProvider: t } = R(), e = P(() => {
|
|
54
|
+
switch (t == null ? void 0 : t.name) {
|
|
55
|
+
case "maptiler":
|
|
56
|
+
return wt;
|
|
57
|
+
case "google":
|
|
58
|
+
return Mt;
|
|
59
|
+
case "mapbox":
|
|
60
|
+
return _t;
|
|
61
|
+
default:
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}, [t]);
|
|
65
|
+
return e ? /* @__PURE__ */ T(e, { ...r }) : null;
|
|
66
|
+
}
|
|
67
|
+
function et(r, t, e = {}) {
|
|
68
|
+
const n = { type: "Feature" };
|
|
69
|
+
return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
|
|
70
|
+
}
|
|
71
|
+
function xt(r, t, e = {}) {
|
|
72
|
+
if (!r)
|
|
73
|
+
throw new Error("coordinates is required");
|
|
74
|
+
if (!Array.isArray(r))
|
|
75
|
+
throw new Error("coordinates must be an Array");
|
|
76
|
+
if (r.length < 2)
|
|
77
|
+
throw new Error("coordinates must be at least 2 numbers long");
|
|
78
|
+
if (!J(r[0]) || !J(r[1]))
|
|
79
|
+
throw new Error("coordinates must contain numbers");
|
|
80
|
+
return et({
|
|
81
|
+
type: "Point",
|
|
82
|
+
coordinates: r
|
|
83
|
+
}, t, e);
|
|
84
|
+
}
|
|
85
|
+
function Yt(r, t, e = {}) {
|
|
86
|
+
return et({
|
|
87
|
+
type: "MultiPoint",
|
|
88
|
+
coordinates: r
|
|
89
|
+
}, t, e);
|
|
90
|
+
}
|
|
91
|
+
function J(r) {
|
|
92
|
+
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
93
|
+
}
|
|
94
|
+
const K = [
|
|
95
|
+
Int8Array,
|
|
96
|
+
Uint8Array,
|
|
97
|
+
Uint8ClampedArray,
|
|
98
|
+
Int16Array,
|
|
99
|
+
Uint16Array,
|
|
100
|
+
Int32Array,
|
|
101
|
+
Uint32Array,
|
|
102
|
+
Float32Array,
|
|
103
|
+
Float64Array
|
|
104
|
+
], F = 1, S = 8;
|
|
105
|
+
class j {
|
|
106
|
+
/**
|
|
107
|
+
* Creates an index from raw `ArrayBuffer` data.
|
|
108
|
+
* @param {ArrayBuffer} data
|
|
109
|
+
*/
|
|
110
|
+
static from(t) {
|
|
111
|
+
if (!(t instanceof ArrayBuffer))
|
|
112
|
+
throw new Error("Data must be an instance of ArrayBuffer.");
|
|
113
|
+
const [e, n] = new Uint8Array(t, 0, 2);
|
|
114
|
+
if (e !== 219)
|
|
115
|
+
throw new Error("Data does not appear to be in a KDBush format.");
|
|
116
|
+
const o = n >> 4;
|
|
117
|
+
if (o !== F)
|
|
118
|
+
throw new Error(`Got v${o} data when expected v${F}.`);
|
|
119
|
+
const i = K[n & 15];
|
|
120
|
+
if (!i)
|
|
121
|
+
throw new Error("Unrecognized array type.");
|
|
122
|
+
const [a] = new Uint16Array(t, 2, 1), [c] = new Uint32Array(t, 4, 1);
|
|
123
|
+
return new j(c, a, i, t);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates an index that will hold a given number of items.
|
|
127
|
+
* @param {number} numItems
|
|
128
|
+
* @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
|
|
129
|
+
* @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
|
|
130
|
+
* @param {ArrayBuffer} [data] (For internal use only)
|
|
131
|
+
*/
|
|
132
|
+
constructor(t, e = 64, n = Float64Array, o) {
|
|
133
|
+
if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
|
|
134
|
+
this.numItems = +t, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.ArrayType = n, this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array;
|
|
135
|
+
const i = K.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, c = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - c % 8) % 8;
|
|
136
|
+
if (i < 0)
|
|
137
|
+
throw new Error(`Unexpected typed array class: ${n}.`);
|
|
138
|
+
o && o instanceof ArrayBuffer ? (this.data = o, this.ids = new this.IndexArrayType(this.data, S, t), this.coords = new this.ArrayType(this.data, S + c + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(S + a + c + s), this.ids = new this.IndexArrayType(this.data, S, t), this.coords = new this.ArrayType(this.data, S + c + s, t * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (F << 4) + i]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = t);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Add a point to the index.
|
|
142
|
+
* @param {number} x
|
|
143
|
+
* @param {number} y
|
|
144
|
+
* @returns {number} An incremental index associated with the added item (starting from `0`).
|
|
145
|
+
*/
|
|
146
|
+
add(t, e) {
|
|
147
|
+
const n = this._pos >> 1;
|
|
148
|
+
return this.ids[n] = n, this.coords[this._pos++] = t, this.coords[this._pos++] = e, n;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Perform indexing of the added points.
|
|
152
|
+
*/
|
|
153
|
+
finish() {
|
|
154
|
+
const t = this._pos >> 1;
|
|
155
|
+
if (t !== this.numItems)
|
|
156
|
+
throw new Error(`Added ${t} items when expected ${this.numItems}.`);
|
|
157
|
+
return N(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Search the index for items within a given bounding box.
|
|
161
|
+
* @param {number} minX
|
|
162
|
+
* @param {number} minY
|
|
163
|
+
* @param {number} maxX
|
|
164
|
+
* @param {number} maxY
|
|
165
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
166
|
+
*/
|
|
167
|
+
range(t, e, n, o) {
|
|
168
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
169
|
+
const { ids: i, coords: a, nodeSize: c } = this, s = [0, i.length - 1, 0], h = [];
|
|
170
|
+
for (; s.length; ) {
|
|
171
|
+
const p = s.pop() || 0, u = s.pop() || 0, f = s.pop() || 0;
|
|
172
|
+
if (u - f <= c) {
|
|
173
|
+
for (let d = f; d <= u; d++) {
|
|
174
|
+
const y = a[2 * d], M = a[2 * d + 1];
|
|
175
|
+
y >= t && y <= n && M >= e && M <= o && h.push(i[d]);
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const g = f + u >> 1, m = a[2 * g], l = a[2 * g + 1];
|
|
180
|
+
m >= t && m <= n && l >= e && l <= o && h.push(i[g]), (p === 0 ? t <= m : e <= l) && (s.push(f), s.push(g - 1), s.push(1 - p)), (p === 0 ? n >= m : o >= l) && (s.push(g + 1), s.push(u), s.push(1 - p));
|
|
181
|
+
}
|
|
182
|
+
return h;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Search the index for items within a given radius.
|
|
186
|
+
* @param {number} qx
|
|
187
|
+
* @param {number} qy
|
|
188
|
+
* @param {number} r Query radius.
|
|
189
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
190
|
+
*/
|
|
191
|
+
within(t, e, n) {
|
|
192
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
193
|
+
const { ids: o, coords: i, nodeSize: a } = this, c = [0, o.length - 1, 0], s = [], h = n * n;
|
|
194
|
+
for (; c.length; ) {
|
|
195
|
+
const p = c.pop() || 0, u = c.pop() || 0, f = c.pop() || 0;
|
|
196
|
+
if (u - f <= a) {
|
|
197
|
+
for (let d = f; d <= u; d++)
|
|
198
|
+
q(i[2 * d], i[2 * d + 1], t, e) <= h && s.push(o[d]);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const g = f + u >> 1, m = i[2 * g], l = i[2 * g + 1];
|
|
202
|
+
q(m, l, t, e) <= h && s.push(o[g]), (p === 0 ? t - n <= m : e - n <= l) && (c.push(f), c.push(g - 1), c.push(1 - p)), (p === 0 ? t + n >= m : e + n >= l) && (c.push(g + 1), c.push(u), c.push(1 - p));
|
|
203
|
+
}
|
|
204
|
+
return s;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function N(r, t, e, n, o, i) {
|
|
208
|
+
if (o - n <= e) return;
|
|
209
|
+
const a = n + o >> 1;
|
|
210
|
+
nt(r, t, a, n, o, i), N(r, t, e, n, a - 1, 1 - i), N(r, t, e, a + 1, o, 1 - i);
|
|
211
|
+
}
|
|
212
|
+
function nt(r, t, e, n, o, i) {
|
|
213
|
+
for (; o > n; ) {
|
|
214
|
+
if (o - n > 600) {
|
|
215
|
+
const h = o - n + 1, p = e - n + 1, u = Math.log(h), f = 0.5 * Math.exp(2 * u / 3), g = 0.5 * Math.sqrt(u * f * (h - f) / h) * (p - h / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - p * f / h + g)), l = Math.min(o, Math.floor(e + (h - p) * f / h + g));
|
|
216
|
+
nt(r, t, e, m, l, i);
|
|
217
|
+
}
|
|
218
|
+
const a = t[2 * e + i];
|
|
219
|
+
let c = n, s = o;
|
|
220
|
+
for (L(r, t, n, e), t[2 * o + i] > a && L(r, t, n, o); c < s; ) {
|
|
221
|
+
for (L(r, t, c, s), c++, s--; t[2 * c + i] < a; ) c++;
|
|
222
|
+
for (; t[2 * s + i] > a; ) s--;
|
|
223
|
+
}
|
|
224
|
+
t[2 * n + i] === a ? L(r, t, n, s) : (s++, L(r, t, s, o)), s <= e && (n = s + 1), e <= s && (o = s - 1);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function L(r, t, e, n) {
|
|
228
|
+
z(r, e, n), z(t, 2 * e, 2 * n), z(t, 2 * e + 1, 2 * n + 1);
|
|
229
|
+
}
|
|
230
|
+
function z(r, t, e) {
|
|
231
|
+
const n = r[t];
|
|
232
|
+
r[t] = r[e], r[e] = n;
|
|
233
|
+
}
|
|
234
|
+
function q(r, t, e, n) {
|
|
235
|
+
const o = r - e, i = t - n;
|
|
236
|
+
return o * o + i * i;
|
|
237
|
+
}
|
|
238
|
+
const Et = {
|
|
239
|
+
minZoom: 0,
|
|
240
|
+
// min zoom to generate clusters on
|
|
241
|
+
maxZoom: 16,
|
|
242
|
+
// max zoom level to cluster the points on
|
|
243
|
+
minPoints: 2,
|
|
244
|
+
// minimum points to form a cluster
|
|
245
|
+
radius: 40,
|
|
246
|
+
// cluster radius in pixels
|
|
247
|
+
extent: 512,
|
|
248
|
+
// tile extent (radius is calculated relative to it)
|
|
249
|
+
nodeSize: 64,
|
|
250
|
+
// size of the KD-tree leaf node, affects performance
|
|
251
|
+
log: !1,
|
|
252
|
+
// whether to log timing info
|
|
253
|
+
// whether to generate numeric ids for input features (in vector tiles)
|
|
254
|
+
generateId: !1,
|
|
255
|
+
// a reduce function for calculating custom cluster properties
|
|
256
|
+
reduce: null,
|
|
257
|
+
// (accumulated, props) => { accumulated.sum += props.sum; }
|
|
258
|
+
// properties to use for individual points when running the reducer
|
|
259
|
+
map: (r) => r
|
|
260
|
+
// props => ({sum: props.my_value})
|
|
261
|
+
}, Q = Math.fround || /* @__PURE__ */ ((r) => (t) => (r[0] = +t, r[0]))(new Float32Array(1)), O = 2, x = 3, D = 4, A = 5, rt = 6;
|
|
262
|
+
class Ot {
|
|
263
|
+
constructor(t) {
|
|
264
|
+
this.options = Object.assign(Object.create(Et), t), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
|
|
265
|
+
}
|
|
266
|
+
load(t) {
|
|
267
|
+
const { log: e, minZoom: n, maxZoom: o } = this.options;
|
|
268
|
+
e && console.time("total time");
|
|
269
|
+
const i = `prepare ${t.length} points`;
|
|
270
|
+
e && console.time(i), this.points = t;
|
|
271
|
+
const a = [];
|
|
272
|
+
for (let s = 0; s < t.length; s++) {
|
|
273
|
+
const h = t[s];
|
|
274
|
+
if (!h.geometry) continue;
|
|
275
|
+
const [p, u] = h.geometry.coordinates, f = Q(Z(p)), g = Q(C(u));
|
|
276
|
+
a.push(
|
|
277
|
+
f,
|
|
278
|
+
g,
|
|
279
|
+
// projected point coordinates
|
|
280
|
+
1 / 0,
|
|
281
|
+
// the last zoom the point was processed at
|
|
282
|
+
s,
|
|
283
|
+
// index of the source feature in the original input array
|
|
284
|
+
-1,
|
|
285
|
+
// parent cluster id
|
|
286
|
+
1
|
|
287
|
+
// number of points in a cluster
|
|
288
|
+
), this.options.reduce && a.push(0);
|
|
289
|
+
}
|
|
290
|
+
let c = this.trees[o + 1] = this._createTree(a);
|
|
291
|
+
e && console.timeEnd(i);
|
|
292
|
+
for (let s = o; s >= n; s--) {
|
|
293
|
+
const h = +Date.now();
|
|
294
|
+
c = this.trees[s] = this._createTree(this._cluster(c, s)), e && console.log("z%d: %d clusters in %dms", s, c.numItems, +Date.now() - h);
|
|
295
|
+
}
|
|
296
|
+
return e && console.timeEnd("total time"), this;
|
|
297
|
+
}
|
|
298
|
+
getClusters(t, e) {
|
|
299
|
+
let n = ((t[0] + 180) % 360 + 360) % 360 - 180;
|
|
300
|
+
const o = Math.max(-90, Math.min(90, t[1]));
|
|
301
|
+
let i = t[2] === 180 ? 180 : ((t[2] + 180) % 360 + 360) % 360 - 180;
|
|
302
|
+
const a = Math.max(-90, Math.min(90, t[3]));
|
|
303
|
+
if (t[2] - t[0] >= 360)
|
|
304
|
+
n = -180, i = 180;
|
|
305
|
+
else if (n > i) {
|
|
306
|
+
const u = this.getClusters([n, o, 180, a], e), f = this.getClusters([-180, o, i, a], e);
|
|
307
|
+
return u.concat(f);
|
|
308
|
+
}
|
|
309
|
+
const c = this.trees[this._limitZoom(e)], s = c.range(Z(n), C(a), Z(i), C(o)), h = c.data, p = [];
|
|
310
|
+
for (const u of s) {
|
|
311
|
+
const f = this.stride * u;
|
|
312
|
+
p.push(h[f + A] > 1 ? W(h, f, this.clusterProps) : this.points[h[f + x]]);
|
|
313
|
+
}
|
|
314
|
+
return p;
|
|
315
|
+
}
|
|
316
|
+
getChildren(t) {
|
|
317
|
+
const e = this._getOriginId(t), n = this._getOriginZoom(t), o = "No cluster with the specified id.", i = this.trees[n];
|
|
318
|
+
if (!i) throw new Error(o);
|
|
319
|
+
const a = i.data;
|
|
320
|
+
if (e * this.stride >= a.length) throw new Error(o);
|
|
321
|
+
const c = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), s = a[e * this.stride], h = a[e * this.stride + 1], p = i.within(s, h, c), u = [];
|
|
322
|
+
for (const f of p) {
|
|
323
|
+
const g = f * this.stride;
|
|
324
|
+
a[g + D] === t && u.push(a[g + A] > 1 ? W(a, g, this.clusterProps) : this.points[a[g + x]]);
|
|
325
|
+
}
|
|
326
|
+
if (u.length === 0) throw new Error(o);
|
|
327
|
+
return u;
|
|
328
|
+
}
|
|
329
|
+
getLeaves(t, e, n) {
|
|
330
|
+
e = e || 10, n = n || 0;
|
|
331
|
+
const o = [];
|
|
332
|
+
return this._appendLeaves(o, t, e, n, 0), o;
|
|
333
|
+
}
|
|
334
|
+
getTile(t, e, n) {
|
|
335
|
+
const o = this.trees[this._limitZoom(t)], i = Math.pow(2, t), { extent: a, radius: c } = this.options, s = c / a, h = (n - s) / i, p = (n + 1 + s) / i, u = {
|
|
336
|
+
features: []
|
|
337
|
+
};
|
|
338
|
+
return this._addTileFeatures(
|
|
339
|
+
o.range((e - s) / i, h, (e + 1 + s) / i, p),
|
|
340
|
+
o.data,
|
|
341
|
+
e,
|
|
342
|
+
n,
|
|
343
|
+
i,
|
|
344
|
+
u
|
|
345
|
+
), e === 0 && this._addTileFeatures(
|
|
346
|
+
o.range(1 - s / i, h, 1, p),
|
|
347
|
+
o.data,
|
|
348
|
+
i,
|
|
349
|
+
n,
|
|
350
|
+
i,
|
|
351
|
+
u
|
|
352
|
+
), e === i - 1 && this._addTileFeatures(
|
|
353
|
+
o.range(0, h, s / i, p),
|
|
354
|
+
o.data,
|
|
355
|
+
-1,
|
|
356
|
+
n,
|
|
357
|
+
i,
|
|
358
|
+
u
|
|
359
|
+
), u.features.length ? u : null;
|
|
360
|
+
}
|
|
361
|
+
getClusterExpansionZoom(t) {
|
|
362
|
+
let e = this._getOriginZoom(t) - 1;
|
|
363
|
+
for (; e <= this.options.maxZoom; ) {
|
|
364
|
+
const n = this.getChildren(t);
|
|
365
|
+
if (e++, n.length !== 1) break;
|
|
366
|
+
t = n[0].properties.cluster_id;
|
|
367
|
+
}
|
|
368
|
+
return e;
|
|
369
|
+
}
|
|
370
|
+
_appendLeaves(t, e, n, o, i) {
|
|
371
|
+
const a = this.getChildren(e);
|
|
372
|
+
for (const c of a) {
|
|
373
|
+
const s = c.properties;
|
|
374
|
+
if (s && s.cluster ? i + s.point_count <= o ? i += s.point_count : i = this._appendLeaves(t, s.cluster_id, n, o, i) : i < o ? i++ : t.push(c), t.length === n) break;
|
|
375
|
+
}
|
|
376
|
+
return i;
|
|
377
|
+
}
|
|
378
|
+
_createTree(t) {
|
|
379
|
+
const e = new j(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
|
|
380
|
+
for (let n = 0; n < t.length; n += this.stride) e.add(t[n], t[n + 1]);
|
|
381
|
+
return e.finish(), e.data = t, e;
|
|
382
|
+
}
|
|
383
|
+
_addTileFeatures(t, e, n, o, i, a) {
|
|
384
|
+
for (const c of t) {
|
|
385
|
+
const s = c * this.stride, h = e[s + A] > 1;
|
|
386
|
+
let p, u, f;
|
|
387
|
+
if (h)
|
|
388
|
+
p = st(e, s, this.clusterProps), u = e[s], f = e[s + 1];
|
|
389
|
+
else {
|
|
390
|
+
const l = this.points[e[s + x]];
|
|
391
|
+
p = l.properties;
|
|
392
|
+
const [d, y] = l.geometry.coordinates;
|
|
393
|
+
u = Z(d), f = C(y);
|
|
394
|
+
}
|
|
395
|
+
const g = {
|
|
396
|
+
type: 1,
|
|
397
|
+
geometry: [[
|
|
398
|
+
Math.round(this.options.extent * (u * i - n)),
|
|
399
|
+
Math.round(this.options.extent * (f * i - o))
|
|
400
|
+
]],
|
|
401
|
+
tags: p
|
|
402
|
+
};
|
|
403
|
+
let m;
|
|
404
|
+
h || this.options.generateId ? m = e[s + x] : m = this.points[e[s + x]].id, m !== void 0 && (g.id = m), a.features.push(g);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
_limitZoom(t) {
|
|
408
|
+
return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
|
|
409
|
+
}
|
|
410
|
+
_cluster(t, e) {
|
|
411
|
+
const { radius: n, extent: o, reduce: i, minPoints: a } = this.options, c = n / (o * Math.pow(2, e)), s = t.data, h = [], p = this.stride;
|
|
412
|
+
for (let u = 0; u < s.length; u += p) {
|
|
413
|
+
if (s[u + O] <= e) continue;
|
|
414
|
+
s[u + O] = e;
|
|
415
|
+
const f = s[u], g = s[u + 1], m = t.within(s[u], s[u + 1], c), l = s[u + A];
|
|
416
|
+
let d = l;
|
|
417
|
+
for (const y of m) {
|
|
418
|
+
const M = y * p;
|
|
419
|
+
s[M + O] > e && (d += s[M + A]);
|
|
420
|
+
}
|
|
421
|
+
if (d > l && d >= a) {
|
|
422
|
+
let y = f * l, M = g * l, _, G = -1;
|
|
423
|
+
const B = ((u / p | 0) << 5) + (e + 1) + this.points.length;
|
|
424
|
+
for (const ot of m) {
|
|
425
|
+
const E = ot * p;
|
|
426
|
+
if (s[E + O] <= e) continue;
|
|
427
|
+
s[E + O] = e;
|
|
428
|
+
const $ = s[E + A];
|
|
429
|
+
y += s[E] * $, M += s[E + 1] * $, s[E + D] = B, i && (_ || (_ = this._map(s, u, !0), G = this.clusterProps.length, this.clusterProps.push(_)), i(_, this._map(s, E)));
|
|
430
|
+
}
|
|
431
|
+
s[u + D] = B, h.push(y / d, M / d, 1 / 0, B, -1, d), i && h.push(G);
|
|
432
|
+
} else {
|
|
433
|
+
for (let y = 0; y < p; y++) h.push(s[u + y]);
|
|
434
|
+
if (d > 1)
|
|
435
|
+
for (const y of m) {
|
|
436
|
+
const M = y * p;
|
|
437
|
+
if (!(s[M + O] <= e)) {
|
|
438
|
+
s[M + O] = e;
|
|
439
|
+
for (let _ = 0; _ < p; _++) h.push(s[M + _]);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return h;
|
|
445
|
+
}
|
|
446
|
+
// get index of the point from which the cluster originated
|
|
447
|
+
_getOriginId(t) {
|
|
448
|
+
return t - this.points.length >> 5;
|
|
449
|
+
}
|
|
450
|
+
// get zoom of the point from which the cluster originated
|
|
451
|
+
_getOriginZoom(t) {
|
|
452
|
+
return (t - this.points.length) % 32;
|
|
453
|
+
}
|
|
454
|
+
_map(t, e, n) {
|
|
455
|
+
if (t[e + A] > 1) {
|
|
456
|
+
const a = this.clusterProps[t[e + rt]];
|
|
457
|
+
return n ? Object.assign({}, a) : a;
|
|
458
|
+
}
|
|
459
|
+
const o = this.points[t[e + x]].properties, i = this.options.map(o);
|
|
460
|
+
return n && i === o ? Object.assign({}, i) : i;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function W(r, t, e) {
|
|
464
|
+
return {
|
|
465
|
+
type: "Feature",
|
|
466
|
+
id: r[t + x],
|
|
467
|
+
properties: st(r, t, e),
|
|
468
|
+
geometry: {
|
|
469
|
+
type: "Point",
|
|
470
|
+
coordinates: [bt(r[t]), Tt(r[t + 1])]
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function st(r, t, e) {
|
|
475
|
+
const n = r[t + A], o = n >= 1e4 ? `${Math.round(n / 1e3)}k` : n >= 1e3 ? `${Math.round(n / 100) / 10}k` : n, i = r[t + rt], a = i === -1 ? {} : Object.assign({}, e[i]);
|
|
476
|
+
return Object.assign(a, {
|
|
477
|
+
cluster: !0,
|
|
478
|
+
cluster_id: r[t + x],
|
|
479
|
+
point_count: n,
|
|
480
|
+
point_count_abbreviated: o
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function Z(r) {
|
|
484
|
+
return r / 360 + 0.5;
|
|
485
|
+
}
|
|
486
|
+
function C(r) {
|
|
487
|
+
const t = Math.sin(r * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
|
|
488
|
+
return e < 0 ? 0 : e > 1 ? 1 : e;
|
|
489
|
+
}
|
|
490
|
+
function bt(r) {
|
|
491
|
+
return (r - 0.5) * 360;
|
|
492
|
+
}
|
|
493
|
+
function Tt(r) {
|
|
494
|
+
const t = (180 - r * 360) * Math.PI / 180;
|
|
495
|
+
return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
|
|
496
|
+
}
|
|
497
|
+
var k = Object.prototype.hasOwnProperty;
|
|
498
|
+
function X(r, t, e) {
|
|
499
|
+
for (e of r.keys())
|
|
500
|
+
if (b(e, t)) return e;
|
|
501
|
+
}
|
|
502
|
+
function b(r, t) {
|
|
503
|
+
var e, n, o;
|
|
504
|
+
if (r === t) return !0;
|
|
505
|
+
if (r && t && (e = r.constructor) === t.constructor) {
|
|
506
|
+
if (e === Date) return r.getTime() === t.getTime();
|
|
507
|
+
if (e === RegExp) return r.toString() === t.toString();
|
|
508
|
+
if (e === Array) {
|
|
509
|
+
if ((n = r.length) === t.length)
|
|
510
|
+
for (; n-- && b(r[n], t[n]); ) ;
|
|
511
|
+
return n === -1;
|
|
512
|
+
}
|
|
513
|
+
if (e === Set) {
|
|
514
|
+
if (r.size !== t.size)
|
|
515
|
+
return !1;
|
|
516
|
+
for (n of r)
|
|
517
|
+
if (o = n, o && typeof o == "object" && (o = X(t, o), !o) || !t.has(o)) return !1;
|
|
518
|
+
return !0;
|
|
519
|
+
}
|
|
520
|
+
if (e === Map) {
|
|
521
|
+
if (r.size !== t.size)
|
|
522
|
+
return !1;
|
|
523
|
+
for (n of r)
|
|
524
|
+
if (o = n[0], o && typeof o == "object" && (o = X(t, o), !o) || !b(n[1], t.get(o)))
|
|
525
|
+
return !1;
|
|
526
|
+
return !0;
|
|
527
|
+
}
|
|
528
|
+
if (e === ArrayBuffer)
|
|
529
|
+
r = new Uint8Array(r), t = new Uint8Array(t);
|
|
530
|
+
else if (e === DataView) {
|
|
531
|
+
if ((n = r.byteLength) === t.byteLength)
|
|
532
|
+
for (; n-- && r.getInt8(n) === t.getInt8(n); ) ;
|
|
533
|
+
return n === -1;
|
|
534
|
+
}
|
|
535
|
+
if (ArrayBuffer.isView(r)) {
|
|
536
|
+
if ((n = r.byteLength) === t.byteLength)
|
|
537
|
+
for (; n-- && r[n] === t[n]; ) ;
|
|
538
|
+
return n === -1;
|
|
539
|
+
}
|
|
540
|
+
if (!e || typeof r == "object") {
|
|
541
|
+
n = 0;
|
|
542
|
+
for (e in r)
|
|
543
|
+
if (k.call(r, e) && ++n && !k.call(t, e) || !(e in t) || !b(r[e], t[e])) return !1;
|
|
544
|
+
return Object.keys(t).length === n;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return r !== r && t !== t;
|
|
548
|
+
}
|
|
549
|
+
function Pt(r) {
|
|
550
|
+
var t = U.useRef(r), e = U.useRef(0);
|
|
551
|
+
return b(r, t.current) || (t.current = r, e.current += 1), U.useMemo(function() {
|
|
552
|
+
return t.current;
|
|
553
|
+
}, [e.current]);
|
|
554
|
+
}
|
|
555
|
+
function St(r, t) {
|
|
556
|
+
return U.useEffect(r, Pt(t));
|
|
557
|
+
}
|
|
558
|
+
var Lt = function(t) {
|
|
559
|
+
var e = t.points, n = t.bounds, o = t.zoom, i = t.options, a = t.disableRefresh, c = V(), s = V(), h = v([]), p = h[0], u = h[1], f = Math.round(o);
|
|
560
|
+
return St(function() {
|
|
561
|
+
a !== !0 && ((!c.current || !b(s.current, e) || !b(c.current.options, i)) && (c.current = new Ot(i), c.current.load(e)), n && u(c.current.getClusters(n, f)), s.current = e);
|
|
562
|
+
}, [e, n, f, i, a]), {
|
|
563
|
+
clusters: p,
|
|
564
|
+
supercluster: c.current
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
const It = w(() => import("./index-CCtDJ-mV.js")), vt = w(() => import("./index-CXTsUiSS.js")), Rt = w(() => import("./index-58w3Qwxr.js"));
|
|
568
|
+
function Zt({ markers: r, onClick: t, ...e }) {
|
|
569
|
+
const { mapProvider: n, activeMarker: o, center: i, bounds: a, zoom: c, setMarkerPoints: s } = R();
|
|
570
|
+
ct(() => {
|
|
571
|
+
let l = [[i.latitude, i.longitude]];
|
|
572
|
+
r.length > 0 && (l = l.concat(
|
|
573
|
+
r.map((d) => [d.latitude, d.longitude])
|
|
574
|
+
)), s(l);
|
|
575
|
+
}, [r, i]);
|
|
576
|
+
const h = P(
|
|
577
|
+
() => ({
|
|
578
|
+
points: r.map((l) => xt([l.longitude, l.latitude], l)),
|
|
579
|
+
bounds: a,
|
|
580
|
+
zoom: c,
|
|
581
|
+
options: {
|
|
582
|
+
radius: n.name === "google" && c > Y ? pt : ht,
|
|
583
|
+
minZoom: Y,
|
|
584
|
+
maxZoom: ut
|
|
585
|
+
}
|
|
586
|
+
}),
|
|
587
|
+
[r, n, a, c]
|
|
588
|
+
), { clusters: p, supercluster: u } = Lt(h), f = (l) => {
|
|
589
|
+
var d, y, M;
|
|
590
|
+
if (!("properties" in l))
|
|
591
|
+
throw new Error("Cluster does not have properties");
|
|
592
|
+
if ((d = l.properties) != null && d.cluster && typeof ((y = l.properties) == null ? void 0 : y.cluster_id) == "number") {
|
|
593
|
+
t == null || t({
|
|
594
|
+
id: `${l.properties.cluster_id}`,
|
|
595
|
+
latitude: l.geometry.coordinates[1],
|
|
596
|
+
longitude: l.geometry.coordinates[0],
|
|
597
|
+
markers: ((M = u == null ? void 0 : u.getLeaves(l.properties.cluster_id)) == null ? void 0 : M.map((_) => _.properties)) ?? []
|
|
598
|
+
});
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
t == null || t({
|
|
602
|
+
id: l.properties.id,
|
|
603
|
+
latitude: l.properties.latitude,
|
|
604
|
+
longitude: l.properties.longitude,
|
|
605
|
+
markers: [l.properties]
|
|
606
|
+
});
|
|
607
|
+
}, g = (l) => {
|
|
608
|
+
var d;
|
|
609
|
+
return !u || !o ? !1 : o.id === `${l}` ? !0 : ((d = u.getLeaves(l)) == null ? void 0 : d.find((y) => y.properties.id === o.id)) !== void 0;
|
|
610
|
+
}, m = P(() => {
|
|
611
|
+
switch (n == null ? void 0 : n.name) {
|
|
612
|
+
case "maptiler":
|
|
613
|
+
return It;
|
|
614
|
+
case "google":
|
|
615
|
+
return vt;
|
|
616
|
+
case "mapbox":
|
|
617
|
+
return Rt;
|
|
618
|
+
default:
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
}, [n]);
|
|
622
|
+
return m ? /* @__PURE__ */ T(
|
|
623
|
+
m,
|
|
624
|
+
{
|
|
625
|
+
clusters: p,
|
|
626
|
+
onClick: f,
|
|
627
|
+
doesSuperclusterContainActiveMarker: g,
|
|
628
|
+
...e
|
|
629
|
+
}
|
|
630
|
+
) : null;
|
|
631
|
+
}
|
|
632
|
+
const Ct = w(() => import("./index-CXUQoF5Q.js")), Ut = w(() => import("./index-DY5pY-zk.js")), Bt = w(() => import("./index-C36u5N_F.js"));
|
|
633
|
+
function Ft({ children: r, anchor: t = "bottom", ...e }) {
|
|
634
|
+
const { mapProvider: n } = R(), o = P(() => {
|
|
635
|
+
switch (n == null ? void 0 : n.name) {
|
|
636
|
+
case "maptiler":
|
|
637
|
+
return Ct;
|
|
638
|
+
case "google":
|
|
639
|
+
return Ut;
|
|
640
|
+
case "mapbox":
|
|
641
|
+
return Bt;
|
|
642
|
+
default:
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
}, [n]);
|
|
646
|
+
return o ? /* @__PURE__ */ T(o, { ...e, anchor: t, children: r }) : null;
|
|
647
|
+
}
|
|
648
|
+
const zt = w(() => import("./index-CTk5bvm9.js")), Dt = w(() => import("./index-UEadmVww.js")), Nt = w(() => import("./index-DVitM43i.js"));
|
|
649
|
+
function jt(r) {
|
|
650
|
+
const { mapProvider: t } = R(), e = P(() => {
|
|
651
|
+
switch (t == null ? void 0 : t.name) {
|
|
652
|
+
case "maptiler":
|
|
653
|
+
return zt;
|
|
654
|
+
case "google":
|
|
655
|
+
return Dt;
|
|
656
|
+
case "mapbox":
|
|
657
|
+
return Nt;
|
|
658
|
+
default:
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
}, [t]);
|
|
662
|
+
return e ? /* @__PURE__ */ T(e, { ...r }) : null;
|
|
663
|
+
}
|
|
664
|
+
function Gt(r) {
|
|
665
|
+
const [t, e] = v([]), [n, o] = v(r.zoom || I.zoom), [i, a] = v();
|
|
666
|
+
return /* @__PURE__ */ T(
|
|
667
|
+
tt.Provider,
|
|
668
|
+
{
|
|
669
|
+
value: { ...r, markerPoints: t, setMarkerPoints: e, bounds: i, setBounds: a, zoom: n, setZoom: o },
|
|
670
|
+
children: r.children
|
|
671
|
+
}
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
const Jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
675
|
+
__proto__: null,
|
|
676
|
+
BaseMap: yt,
|
|
677
|
+
CenterPin: At,
|
|
678
|
+
Layers: jt,
|
|
679
|
+
Markers: Zt,
|
|
680
|
+
Popup: Ft,
|
|
681
|
+
Root: Gt
|
|
682
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
683
|
+
export {
|
|
684
|
+
Ht as M,
|
|
685
|
+
H as a,
|
|
686
|
+
I as d,
|
|
687
|
+
Jt as i,
|
|
688
|
+
Yt as m,
|
|
689
|
+
R as u
|
|
690
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect as a } from "react";
|
|
3
3
|
import { P as c } from "./scale-control-CyJd4u6j.js";
|
|
4
|
-
import { u as i } from "./index-
|
|
4
|
+
import { u as i } from "./index-Bp1bWq9c.js";
|
|
5
5
|
import { c as n } from "./styles-ChFj97uV.js";
|
|
6
6
|
function l({
|
|
7
7
|
latitude: p,
|