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