@xyo-network/react-map 7.4.1 → 7.5.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/dist/browser/index.mjs
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/Components/AnimatedHeatMap.tsx
|
|
2
5
|
import { useTheme } from "@mui/material";
|
|
3
6
|
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
4
7
|
import { darkenCss } from "@xylabs/react-theme";
|
|
5
|
-
import { useState as useState5 } from "react";
|
|
8
|
+
import React8, { useState as useState5 } from "react";
|
|
6
9
|
|
|
7
10
|
// src/Contexts/HeatMapInitializer/Provider.tsx
|
|
8
11
|
import { forget as forget2 } from "@xylabs/forget";
|
|
9
|
-
import { useEffect as useEffect4, useMemo as useMemo6 } from "react";
|
|
12
|
+
import React3, { useEffect as useEffect4, useMemo as useMemo6 } from "react";
|
|
10
13
|
|
|
11
14
|
// src/hooks/useDynamicMapResize.tsx
|
|
12
15
|
import { useEffect, useMemo } from "react";
|
|
13
|
-
var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
|
|
14
|
-
const resizer = useMemo(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
var useDynamicMapResize = /* @__PURE__ */ __name((mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
|
|
17
|
+
const resizer = useMemo(() => new ResizeObserver(() => {
|
|
18
|
+
const width = mapContainerRef.current?.getBoundingClientRect().width;
|
|
19
|
+
if (width && mapCanvasRef.current) {
|
|
20
|
+
mapCanvasRef.current.style.width = `${width}px`;
|
|
21
|
+
setTimeout(() => mapInstance?.resize());
|
|
22
|
+
}
|
|
23
|
+
}), [
|
|
24
|
+
mapCanvasRef,
|
|
25
|
+
mapContainerRef,
|
|
26
|
+
mapInstance
|
|
27
|
+
]);
|
|
24
28
|
const dependenciesReady = useMemo(() => {
|
|
25
29
|
return !!(active && mapInstance && mapContainerRef?.current && mapCanvasRef.current);
|
|
26
|
-
}, [
|
|
30
|
+
}, [
|
|
31
|
+
active,
|
|
32
|
+
mapCanvasRef,
|
|
33
|
+
mapContainerRef,
|
|
34
|
+
mapInstance
|
|
35
|
+
]);
|
|
27
36
|
useEffect(() => {
|
|
28
37
|
if (dependenciesReady) {
|
|
29
38
|
if (mapContainerRef.current) {
|
|
@@ -33,17 +42,33 @@ var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active =
|
|
|
33
42
|
resizer.disconnect();
|
|
34
43
|
};
|
|
35
44
|
}
|
|
36
|
-
}, [
|
|
37
|
-
|
|
45
|
+
}, [
|
|
46
|
+
active,
|
|
47
|
+
dependenciesReady,
|
|
48
|
+
mapCanvasRef,
|
|
49
|
+
mapContainerRef,
|
|
50
|
+
mapInstance,
|
|
51
|
+
resizer
|
|
52
|
+
]);
|
|
53
|
+
}, "useDynamicMapResize");
|
|
38
54
|
|
|
39
55
|
// src/hooks/useDynamicPositioning.tsx
|
|
40
56
|
import { useWindowSize } from "@xylabs/react-shared";
|
|
41
57
|
import { useMemo as useMemo2 } from "react";
|
|
42
58
|
var defaultZoom = 1.6;
|
|
43
|
-
var defaultAspectRatioRange = [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
var defaultAspectRatioRange = [
|
|
60
|
+
0.5,
|
|
61
|
+
2
|
|
62
|
+
];
|
|
63
|
+
var latRange = [
|
|
64
|
+
0.9121644205263664,
|
|
65
|
+
1.71785031559439
|
|
66
|
+
];
|
|
67
|
+
var lngRange = [
|
|
68
|
+
-81.4742014851959,
|
|
69
|
+
12.788958675506933
|
|
70
|
+
];
|
|
71
|
+
var linearInterpolate = /* @__PURE__ */ __name((aspectRatio, degreeRange, aspectRatioRange) => {
|
|
47
72
|
const [degreeMin, degreeMax] = degreeRange;
|
|
48
73
|
const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange;
|
|
49
74
|
const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin;
|
|
@@ -51,41 +76,51 @@ var linearInterpolate = (aspectRatio, degreeRange, aspectRatioRange) => {
|
|
|
51
76
|
const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan;
|
|
52
77
|
const scaledDegree = percent * degreeRangeSpan + degreeMin;
|
|
53
78
|
return scaledDegree;
|
|
54
|
-
};
|
|
55
|
-
var useDynamicPositioning = () => {
|
|
79
|
+
}, "linearInterpolate");
|
|
80
|
+
var useDynamicPositioning = /* @__PURE__ */ __name(() => {
|
|
56
81
|
const { width, height } = useWindowSize();
|
|
57
82
|
const options = useMemo2(() => {
|
|
58
83
|
if (width && height) {
|
|
59
84
|
const aspectRatio = width / height;
|
|
60
85
|
return {
|
|
61
|
-
center: [
|
|
86
|
+
center: [
|
|
87
|
+
linearInterpolate(aspectRatio, lngRange),
|
|
88
|
+
linearInterpolate(aspectRatio, latRange)
|
|
89
|
+
],
|
|
62
90
|
zoom: defaultZoom
|
|
63
91
|
};
|
|
64
92
|
}
|
|
65
|
-
}, [
|
|
66
|
-
|
|
67
|
-
|
|
93
|
+
}, [
|
|
94
|
+
height,
|
|
95
|
+
width
|
|
96
|
+
]);
|
|
97
|
+
return {
|
|
98
|
+
options
|
|
99
|
+
};
|
|
100
|
+
}, "useDynamicPositioning");
|
|
68
101
|
|
|
69
102
|
// src/hooks/useQuadKeyPayloadsToFeatures.tsx
|
|
70
103
|
import { exists } from "@xylabs/exists";
|
|
71
104
|
import { GeoJson } from "@xyo-network/sdk-geo";
|
|
72
105
|
import { useMemo as useMemo3, useState } from "react";
|
|
73
|
-
var quadKeyToFeature = ({ density, quadkey }) => {
|
|
106
|
+
var quadKeyToFeature = /* @__PURE__ */ __name(({ density, quadkey }) => {
|
|
74
107
|
const polygonFeature = new GeoJson(quadkey).polygonFeature();
|
|
75
108
|
polygonFeature.properties = {
|
|
76
109
|
count: density,
|
|
77
110
|
density
|
|
78
111
|
};
|
|
79
112
|
return polygonFeature;
|
|
80
|
-
};
|
|
81
|
-
var setDensity = (feature) => {
|
|
113
|
+
}, "quadKeyToFeature");
|
|
114
|
+
var setDensity = /* @__PURE__ */ __name((feature) => {
|
|
82
115
|
if (feature.properties) {
|
|
83
116
|
feature.properties.value = feature.properties.density / 5;
|
|
84
117
|
}
|
|
85
118
|
return feature;
|
|
86
|
-
};
|
|
87
|
-
var useQuadKeyPayloadsToFeatures = (payloads) => {
|
|
88
|
-
const [multipleFeatureSets, setMultipleFeatureSets] = useState([
|
|
119
|
+
}, "setDensity");
|
|
120
|
+
var useQuadKeyPayloadsToFeatures = /* @__PURE__ */ __name((payloads) => {
|
|
121
|
+
const [multipleFeatureSets, setMultipleFeatureSets] = useState([
|
|
122
|
+
[]
|
|
123
|
+
]);
|
|
89
124
|
const [features, setFeatures] = useState([]);
|
|
90
125
|
const [error, setError] = useState();
|
|
91
126
|
useMemo3(() => {
|
|
@@ -102,18 +137,23 @@ var useQuadKeyPayloadsToFeatures = (payloads) => {
|
|
|
102
137
|
const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
|
|
103
138
|
setFeatures(mappedFeatures.map(setDensity));
|
|
104
139
|
}
|
|
105
|
-
}, [
|
|
140
|
+
}, [
|
|
141
|
+
payloads
|
|
142
|
+
]);
|
|
106
143
|
return {
|
|
107
144
|
error,
|
|
108
145
|
features,
|
|
109
146
|
multipleFeatureSets
|
|
110
147
|
};
|
|
111
|
-
};
|
|
148
|
+
}, "useQuadKeyPayloadsToFeatures");
|
|
112
149
|
|
|
113
150
|
// src/MapBoxClasses/MapBase.ts
|
|
114
151
|
import { assertEx } from "@xylabs/assert";
|
|
115
152
|
import { GeoJson as GeoJson2 } from "@xyo-network/sdk-geo";
|
|
116
153
|
var MapBase = class {
|
|
154
|
+
static {
|
|
155
|
+
__name(this, "MapBase");
|
|
156
|
+
}
|
|
117
157
|
_config;
|
|
118
158
|
constructor(config) {
|
|
119
159
|
this._config = {
|
|
@@ -126,10 +166,10 @@ var MapBase = class {
|
|
|
126
166
|
return !!this._config.map;
|
|
127
167
|
}
|
|
128
168
|
initializeMapSource(layer) {
|
|
129
|
-
const getSource = () => {
|
|
169
|
+
const getSource = /* @__PURE__ */ __name(() => {
|
|
130
170
|
const featuresCollection = GeoJson2.featureCollection(this._config.features);
|
|
131
171
|
return GeoJson2.featuresSource(featuresCollection);
|
|
132
|
-
};
|
|
172
|
+
}, "getSource");
|
|
133
173
|
const existingSource = this._config.map.getSource(layer.source);
|
|
134
174
|
const source = getSource();
|
|
135
175
|
if (existingSource) {
|
|
@@ -149,6 +189,9 @@ import { forget } from "@xylabs/forget";
|
|
|
149
189
|
import { GeoJson as GeoJson3 } from "@xyo-network/sdk-geo";
|
|
150
190
|
import { LngLatBounds } from "mapbox-gl";
|
|
151
191
|
var MapHeat = class extends MapBase {
|
|
192
|
+
static {
|
|
193
|
+
__name(this, "MapHeat");
|
|
194
|
+
}
|
|
152
195
|
// eslint-disable-next-line sonarjs/public-static-readonly
|
|
153
196
|
static animationStarted = false;
|
|
154
197
|
config;
|
|
@@ -197,7 +240,7 @@ var MapHeat = class extends MapBase {
|
|
|
197
240
|
const stepLength = frameLength / steps;
|
|
198
241
|
const lowUsageColor = startColor ?? "#FFB3B3";
|
|
199
242
|
const highUsageColor = endColor ?? "#FF0000";
|
|
200
|
-
const dynamicFillColor = (factor2, initialPad2, i) => {
|
|
243
|
+
const dynamicFillColor = /* @__PURE__ */ __name((factor2, initialPad2, i) => {
|
|
201
244
|
const sinFade = Math.sin(i / steps * Math.PI / 2);
|
|
202
245
|
const cosFade = Math.cos(i / steps * Math.PI / 2);
|
|
203
246
|
const divisor = factor2 + factor2 * sinFade;
|
|
@@ -205,27 +248,54 @@ var MapHeat = class extends MapBase {
|
|
|
205
248
|
return [
|
|
206
249
|
"let",
|
|
207
250
|
"density",
|
|
208
|
-
[
|
|
209
|
-
|
|
251
|
+
[
|
|
252
|
+
"+",
|
|
253
|
+
[
|
|
254
|
+
"/",
|
|
255
|
+
[
|
|
256
|
+
"number",
|
|
257
|
+
[
|
|
258
|
+
"get",
|
|
259
|
+
"value"
|
|
260
|
+
]
|
|
261
|
+
],
|
|
262
|
+
divisor
|
|
263
|
+
],
|
|
264
|
+
offset
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
"interpolate",
|
|
268
|
+
[
|
|
269
|
+
"linear"
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
"var",
|
|
273
|
+
"density"
|
|
274
|
+
],
|
|
275
|
+
0,
|
|
276
|
+
lowUsageColor,
|
|
277
|
+
0.5,
|
|
278
|
+
highUsageColor
|
|
279
|
+
]
|
|
210
280
|
];
|
|
211
|
-
};
|
|
281
|
+
}, "dynamicFillColor");
|
|
212
282
|
const fadedIn = layers.map((_) => false);
|
|
213
|
-
const fadeIn = async (id, index) => {
|
|
283
|
+
const fadeIn = /* @__PURE__ */ __name(async (id, index) => {
|
|
214
284
|
for (let i = steps; i >= 1; i--) {
|
|
215
285
|
map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
|
|
216
286
|
await delay(stepLength);
|
|
217
287
|
}
|
|
218
288
|
fadedIn[index] = true;
|
|
219
|
-
};
|
|
220
|
-
const fadeOut = async (id, index) => {
|
|
289
|
+
}, "fadeIn");
|
|
290
|
+
const fadeOut = /* @__PURE__ */ __name(async (id, index) => {
|
|
221
291
|
for (let i = 1; i <= steps; i++) {
|
|
222
292
|
map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
|
|
223
293
|
await delay(stepLength);
|
|
224
294
|
}
|
|
225
295
|
fadedIn[index] = false;
|
|
226
|
-
};
|
|
296
|
+
}, "fadeOut");
|
|
227
297
|
let started = false;
|
|
228
|
-
const startAnimation = async () => {
|
|
298
|
+
const startAnimation = /* @__PURE__ */ __name(async () => {
|
|
229
299
|
assertEx2(!started, () => "Animation Already Started");
|
|
230
300
|
started = true;
|
|
231
301
|
while (this.animationStarted) {
|
|
@@ -247,7 +317,7 @@ var MapHeat = class extends MapBase {
|
|
|
247
317
|
layerTick++;
|
|
248
318
|
sourceTick++;
|
|
249
319
|
}
|
|
250
|
-
};
|
|
320
|
+
}, "startAnimation");
|
|
251
321
|
await startAnimation();
|
|
252
322
|
}
|
|
253
323
|
static updateLayer(map, layer, source) {
|
|
@@ -261,10 +331,10 @@ var MapHeat = class extends MapBase {
|
|
|
261
331
|
}
|
|
262
332
|
// Build layers each with the same features
|
|
263
333
|
initializeHeatMapSource(layers) {
|
|
264
|
-
const getSource = (_) => {
|
|
334
|
+
const getSource = /* @__PURE__ */ __name((_) => {
|
|
265
335
|
const featuresCollection = GeoJson3.featureCollection(this.config.features);
|
|
266
336
|
return GeoJson3.featuresSource(featuresCollection);
|
|
267
|
-
};
|
|
337
|
+
}, "getSource");
|
|
268
338
|
for (const [index, layer] of layers.entries()) {
|
|
269
339
|
const existingSource = this.config.map.getSource(layer.source);
|
|
270
340
|
const source = getSource(index);
|
|
@@ -282,6 +352,9 @@ var MapHeat = class extends MapBase {
|
|
|
282
352
|
// src/MapBoxClasses/MapPoints.ts
|
|
283
353
|
import { LngLatBounds as LngLatBounds2 } from "mapbox-gl";
|
|
284
354
|
var MapPoints = class extends MapBase {
|
|
355
|
+
static {
|
|
356
|
+
__name(this, "MapPoints");
|
|
357
|
+
}
|
|
285
358
|
config;
|
|
286
359
|
constructor(config) {
|
|
287
360
|
super(config);
|
|
@@ -306,17 +379,20 @@ var MapPoints = class extends MapBase {
|
|
|
306
379
|
// src/MapBoxClasses/MapSettings.ts
|
|
307
380
|
import { GeolocateControl, NavigationControl } from "mapbox-gl";
|
|
308
381
|
var MapSettings = class _MapSettings {
|
|
382
|
+
static {
|
|
383
|
+
__name(this, "MapSettings");
|
|
384
|
+
}
|
|
309
385
|
// eslint-disable-next-line sonarjs/public-static-readonly
|
|
310
386
|
static geoLocateControl;
|
|
311
387
|
// eslint-disable-next-line sonarjs/public-static-readonly
|
|
312
388
|
static mapListeners = {
|
|
313
|
-
logData: (ev, map) => {
|
|
389
|
+
logData: /* @__PURE__ */ __name((ev, map) => {
|
|
314
390
|
const target = map || ev?.target;
|
|
315
391
|
if (target) {
|
|
316
392
|
console.log("zoom", target.getZoom());
|
|
317
393
|
console.log("center", target.getCenter());
|
|
318
394
|
}
|
|
319
|
-
}
|
|
395
|
+
}, "logData")
|
|
320
396
|
};
|
|
321
397
|
// eslint-disable-next-line sonarjs/public-static-readonly
|
|
322
398
|
static navControl;
|
|
@@ -342,7 +418,11 @@ var MapSettings = class _MapSettings {
|
|
|
342
418
|
return this;
|
|
343
419
|
}
|
|
344
420
|
static toggleDebugLogging(value, map) {
|
|
345
|
-
const debugEvents = [
|
|
421
|
+
const debugEvents = [
|
|
422
|
+
"resize",
|
|
423
|
+
"zoomend",
|
|
424
|
+
"dragend"
|
|
425
|
+
];
|
|
346
426
|
if (value) {
|
|
347
427
|
this.mapListeners.logData(void 0, map);
|
|
348
428
|
for (const event of debugEvents) map.on(event, this.mapListeners.logData);
|
|
@@ -359,29 +439,24 @@ var MapSettings = class _MapSettings {
|
|
|
359
439
|
return this;
|
|
360
440
|
}
|
|
361
441
|
static updateSettings(config) {
|
|
362
|
-
const {
|
|
363
|
-
|
|
364
|
-
map,
|
|
365
|
-
zoom,
|
|
366
|
-
requestLocation,
|
|
367
|
-
debugLayerName = ""
|
|
368
|
-
} = config;
|
|
369
|
-
const {
|
|
370
|
-
scrollToZoom: scrollToZoom2,
|
|
371
|
-
enableControls,
|
|
372
|
-
debugLayer: debugLayer2,
|
|
373
|
-
debugLogging
|
|
374
|
-
} = settings;
|
|
442
|
+
const { settings, map, zoom, requestLocation, debugLayerName = "" } = config;
|
|
443
|
+
const { scrollToZoom: scrollToZoom2, enableControls, debugLayer: debugLayer2, debugLogging } = settings;
|
|
375
444
|
_MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation).toggleScrollToZoom(scrollToZoom2?.value, map).toggleDebugLayer(debugLayer2?.value, map, debugLayerName).toggleDebugLogging(debugLogging.value, map);
|
|
376
445
|
}
|
|
377
446
|
// Needs to be static so we ensure controls are only instantiated once
|
|
378
447
|
static addControls(map, zoom, requestLocation) {
|
|
379
448
|
const geolocateControl = new GeolocateControl({
|
|
380
|
-
fitBoundsOptions: {
|
|
381
|
-
|
|
449
|
+
fitBoundsOptions: {
|
|
450
|
+
zoom: zoom || 2
|
|
451
|
+
},
|
|
452
|
+
positionOptions: {
|
|
453
|
+
enableHighAccuracy: true
|
|
454
|
+
},
|
|
382
455
|
trackUserLocation: true
|
|
383
456
|
});
|
|
384
|
-
const navControl = new NavigationControl({
|
|
457
|
+
const navControl = new NavigationControl({
|
|
458
|
+
showCompass: false
|
|
459
|
+
});
|
|
385
460
|
this.geoLocateControl = this.geoLocateControl || geolocateControl;
|
|
386
461
|
this.navControl = this.navControl || navControl;
|
|
387
462
|
if (!map.hasControl(this.geoLocateControl) && requestLocation) {
|
|
@@ -404,71 +479,68 @@ var MapSettings = class _MapSettings {
|
|
|
404
479
|
};
|
|
405
480
|
|
|
406
481
|
// src/Contexts/MapBoxInstance/Provider.tsx
|
|
407
|
-
import {
|
|
408
|
-
useEffect as useEffect2,
|
|
409
|
-
useMemo as useMemo4,
|
|
410
|
-
useState as useState2
|
|
411
|
-
} from "react";
|
|
482
|
+
import React, { useEffect as useEffect2, useMemo as useMemo4, useState as useState2 } from "react";
|
|
412
483
|
|
|
413
484
|
// src/Contexts/MapBoxInstance/Context.ts
|
|
414
485
|
import { createContext } from "react";
|
|
415
486
|
var MapBoxInstanceContext = createContext({});
|
|
416
487
|
|
|
417
488
|
// src/Contexts/MapBoxInstance/Provider.tsx
|
|
418
|
-
|
|
419
|
-
var MapBoxInstanceProvider = ({ children }) => {
|
|
489
|
+
var MapBoxInstanceProvider = /* @__PURE__ */ __name(({ children }) => {
|
|
420
490
|
const [map, setMapBoxInstance] = useState2();
|
|
421
491
|
const [mapInitialized, setMapInitialized] = useState2(false);
|
|
422
492
|
const value = useMemo4(() => ({
|
|
423
493
|
map,
|
|
424
494
|
mapInitialized,
|
|
425
495
|
setMapBoxInstance
|
|
426
|
-
}), [
|
|
496
|
+
}), [
|
|
497
|
+
map,
|
|
498
|
+
mapInitialized,
|
|
499
|
+
setMapBoxInstance
|
|
500
|
+
]);
|
|
427
501
|
useEffect2(() => {
|
|
428
502
|
if (!mapInitialized && map) {
|
|
429
503
|
map?.on("load", () => {
|
|
430
504
|
setMapInitialized(true);
|
|
431
505
|
});
|
|
432
506
|
}
|
|
433
|
-
}, [
|
|
434
|
-
|
|
435
|
-
|
|
507
|
+
}, [
|
|
508
|
+
map,
|
|
509
|
+
mapInitialized,
|
|
510
|
+
setMapInitialized
|
|
511
|
+
]);
|
|
512
|
+
return /* @__PURE__ */ React.createElement(MapBoxInstanceContext, {
|
|
513
|
+
value
|
|
514
|
+
}, children);
|
|
515
|
+
}, "MapBoxInstanceProvider");
|
|
436
516
|
|
|
437
517
|
// src/Contexts/MapBoxInstance/useMapBoxInstance.tsx
|
|
438
518
|
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
439
519
|
import { use } from "react";
|
|
440
|
-
var useMapBoxInstance = () => {
|
|
520
|
+
var useMapBoxInstance = /* @__PURE__ */ __name(() => {
|
|
441
521
|
const context = use(MapBoxInstanceContext);
|
|
442
522
|
assertEx3("map" in context, () => "useMapBoxInstance must be used within a MapBoxInstanceContext");
|
|
443
523
|
return context;
|
|
444
|
-
};
|
|
524
|
+
}, "useMapBoxInstance");
|
|
445
525
|
|
|
446
526
|
// src/Contexts/MapSettings/Provider.tsx
|
|
447
|
-
import {
|
|
448
|
-
useEffect as useEffect3,
|
|
449
|
-
useMemo as useMemo5,
|
|
450
|
-
useState as useState3
|
|
451
|
-
} from "react";
|
|
527
|
+
import React2, { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
452
528
|
|
|
453
529
|
// src/Contexts/MapSettings/Context.ts
|
|
454
530
|
import { createContext as createContext2 } from "react";
|
|
455
531
|
var MapSettingsContext = createContext2({});
|
|
456
532
|
|
|
457
533
|
// src/Contexts/MapSettings/Provider.tsx
|
|
458
|
-
|
|
459
|
-
var MapSettingsProvider = ({
|
|
460
|
-
children,
|
|
461
|
-
debugLayerName,
|
|
462
|
-
defaultMapSettings,
|
|
463
|
-
requestLocation,
|
|
464
|
-
zoom = 1
|
|
465
|
-
}) => {
|
|
534
|
+
var MapSettingsProvider = /* @__PURE__ */ __name(({ children, debugLayerName, defaultMapSettings, requestLocation, zoom = 1 }) => {
|
|
466
535
|
const [mapSettings, setMapSettings] = useState3(defaultMapSettings || {});
|
|
467
536
|
const { map, mapInitialized } = useMapBoxInstance();
|
|
468
537
|
const value = useMemo5(() => ({
|
|
469
538
|
mapSettings,
|
|
470
539
|
setMapSettings
|
|
471
|
-
}), [
|
|
540
|
+
}), [
|
|
541
|
+
mapSettings,
|
|
542
|
+
setMapSettings
|
|
543
|
+
]);
|
|
472
544
|
useEffect3(() => {
|
|
473
545
|
if (mapSettings && map && mapInitialized) {
|
|
474
546
|
MapSettings.updateSettings({
|
|
@@ -479,33 +551,32 @@ var MapSettingsProvider = ({
|
|
|
479
551
|
zoom
|
|
480
552
|
});
|
|
481
553
|
}
|
|
482
|
-
}, [
|
|
483
|
-
|
|
484
|
-
|
|
554
|
+
}, [
|
|
555
|
+
debugLayerName,
|
|
556
|
+
map,
|
|
557
|
+
mapInitialized,
|
|
558
|
+
mapSettings,
|
|
559
|
+
requestLocation,
|
|
560
|
+
zoom
|
|
561
|
+
]);
|
|
562
|
+
return /* @__PURE__ */ React2.createElement(MapSettingsContext, {
|
|
563
|
+
value
|
|
564
|
+
}, children);
|
|
565
|
+
}, "MapSettingsProvider");
|
|
485
566
|
|
|
486
567
|
// src/Contexts/MapSettings/useMapSettings.tsx
|
|
487
568
|
import { use as use2 } from "react";
|
|
488
|
-
var useMapSettings = () => {
|
|
569
|
+
var useMapSettings = /* @__PURE__ */ __name(() => {
|
|
489
570
|
const context = use2(MapSettingsContext);
|
|
490
571
|
return context;
|
|
491
|
-
};
|
|
572
|
+
}, "useMapSettings");
|
|
492
573
|
|
|
493
574
|
// src/Contexts/HeatMapInitializer/Context.ts
|
|
494
575
|
import { createContext as createContext3 } from "react";
|
|
495
576
|
var HeatMapInitializerContext = createContext3({});
|
|
496
577
|
|
|
497
578
|
// src/Contexts/HeatMapInitializer/Provider.tsx
|
|
498
|
-
|
|
499
|
-
var HeatMapInitializerProvider = ({
|
|
500
|
-
children,
|
|
501
|
-
featureSets,
|
|
502
|
-
featureSetsLayers,
|
|
503
|
-
features,
|
|
504
|
-
fitToPadding,
|
|
505
|
-
heatMapColorProps,
|
|
506
|
-
layers,
|
|
507
|
-
zoom
|
|
508
|
-
}) => {
|
|
579
|
+
var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets, featureSetsLayers, features, fitToPadding, heatMapColorProps, layers, zoom }) => {
|
|
509
580
|
const { options } = useDynamicPositioning();
|
|
510
581
|
const { mapSettings } = useMapSettings();
|
|
511
582
|
const { map, mapInitialized } = useMapBoxInstance();
|
|
@@ -515,11 +586,18 @@ var HeatMapInitializerProvider = ({
|
|
|
515
586
|
map,
|
|
516
587
|
zoom
|
|
517
588
|
}) : void 0;
|
|
518
|
-
}, [
|
|
589
|
+
}, [
|
|
590
|
+
map,
|
|
591
|
+
features,
|
|
592
|
+
zoom
|
|
593
|
+
]);
|
|
519
594
|
const value = useMemo6(() => ({
|
|
520
595
|
MapHeat: mapHeat,
|
|
521
596
|
heatMapColorProps
|
|
522
|
-
}), [
|
|
597
|
+
}), [
|
|
598
|
+
mapHeat,
|
|
599
|
+
heatMapColorProps
|
|
600
|
+
]);
|
|
523
601
|
useEffect4(() => {
|
|
524
602
|
if (mapInitialized && featureSets?.length && featureSets[0].length > 0 && map && featureSetsLayers?.length) {
|
|
525
603
|
const { lowUsageColor, highUsageColor } = heatMapColorProps;
|
|
@@ -528,94 +606,187 @@ var HeatMapInitializerProvider = ({
|
|
|
528
606
|
return () => {
|
|
529
607
|
MapHeat.animationStarted = false;
|
|
530
608
|
};
|
|
531
|
-
}, [
|
|
609
|
+
}, [
|
|
610
|
+
featureSets,
|
|
611
|
+
featureSetsLayers,
|
|
612
|
+
mapInitialized,
|
|
613
|
+
map,
|
|
614
|
+
heatMapColorProps
|
|
615
|
+
]);
|
|
532
616
|
useEffect4(() => {
|
|
533
617
|
if (mapHeat && mapInitialized && features?.length && layers?.length) {
|
|
534
618
|
mapHeat.initializeHeatMapSource(layers);
|
|
535
619
|
}
|
|
536
|
-
}, [
|
|
620
|
+
}, [
|
|
621
|
+
mapHeat,
|
|
622
|
+
features?.length,
|
|
623
|
+
layers,
|
|
624
|
+
mapInitialized
|
|
625
|
+
]);
|
|
537
626
|
useEffect4(() => {
|
|
538
627
|
if (mapInitialized) {
|
|
539
628
|
const { fitToPoints: fitToPoints2 } = mapSettings || {};
|
|
540
629
|
if (map) {
|
|
541
630
|
if (fitToPoints2?.value === true) {
|
|
542
|
-
MapHeat.initialMapPositioning(
|
|
543
|
-
{
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
},
|
|
551
|
-
map,
|
|
552
|
-
features
|
|
553
|
-
);
|
|
631
|
+
MapHeat.initialMapPositioning({
|
|
632
|
+
padding: {
|
|
633
|
+
bottom: fitToPadding,
|
|
634
|
+
left: fitToPadding,
|
|
635
|
+
right: fitToPadding,
|
|
636
|
+
top: fitToPadding
|
|
637
|
+
}
|
|
638
|
+
}, map, features);
|
|
554
639
|
} else if (options?.zoom && options.center) {
|
|
555
640
|
map.setZoom(options.zoom);
|
|
556
641
|
map.setCenter(options.center);
|
|
557
642
|
}
|
|
558
643
|
}
|
|
559
644
|
}
|
|
560
|
-
}, [
|
|
561
|
-
|
|
562
|
-
|
|
645
|
+
}, [
|
|
646
|
+
mapHeat,
|
|
647
|
+
map,
|
|
648
|
+
mapSettings,
|
|
649
|
+
fitToPadding,
|
|
650
|
+
options,
|
|
651
|
+
mapInitialized,
|
|
652
|
+
features
|
|
653
|
+
]);
|
|
654
|
+
return /* @__PURE__ */ React3.createElement(HeatMapInitializerContext, {
|
|
655
|
+
value
|
|
656
|
+
}, children);
|
|
657
|
+
}, "HeatMapInitializerProvider");
|
|
563
658
|
|
|
564
659
|
// src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx
|
|
565
660
|
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
566
661
|
import { use as use3 } from "react";
|
|
567
|
-
var useHeatMapInitializer = () => {
|
|
662
|
+
var useHeatMapInitializer = /* @__PURE__ */ __name(() => {
|
|
568
663
|
const context = use3(HeatMapInitializerContext);
|
|
569
664
|
assertEx4("heatMapInitialized" in context, () => "useHeatMapInitializer must be used within a HeatMapInitializerContext");
|
|
570
665
|
return context;
|
|
571
|
-
};
|
|
666
|
+
}, "useHeatMapInitializer");
|
|
572
667
|
|
|
573
668
|
// src/Layers/Configs/HeatMapFillLayerConfig.ts
|
|
574
|
-
var HeatMapFillLayerConfig = (color) => ({
|
|
669
|
+
var HeatMapFillLayerConfig = /* @__PURE__ */ __name((color) => ({
|
|
575
670
|
paint: {
|
|
576
671
|
"fill-color": color,
|
|
577
672
|
"fill-opacity": [
|
|
578
673
|
"let",
|
|
579
674
|
"density",
|
|
580
|
-
[
|
|
581
|
-
|
|
675
|
+
[
|
|
676
|
+
"+",
|
|
677
|
+
[
|
|
678
|
+
"/",
|
|
679
|
+
[
|
|
680
|
+
"number",
|
|
681
|
+
[
|
|
682
|
+
"get",
|
|
683
|
+
"value"
|
|
684
|
+
]
|
|
685
|
+
],
|
|
686
|
+
4
|
|
687
|
+
],
|
|
688
|
+
0.125
|
|
689
|
+
],
|
|
690
|
+
[
|
|
691
|
+
"interpolate",
|
|
692
|
+
[
|
|
693
|
+
"linear"
|
|
694
|
+
],
|
|
695
|
+
[
|
|
696
|
+
"var",
|
|
697
|
+
"density"
|
|
698
|
+
],
|
|
699
|
+
0.8,
|
|
700
|
+
[
|
|
701
|
+
"var",
|
|
702
|
+
"density"
|
|
703
|
+
],
|
|
704
|
+
1,
|
|
705
|
+
0.85
|
|
706
|
+
]
|
|
582
707
|
]
|
|
583
708
|
}
|
|
584
|
-
});
|
|
709
|
+
}), "HeatMapFillLayerConfig");
|
|
585
710
|
|
|
586
711
|
// src/Layers/Configs/HeatMapLineLayerConfig.ts
|
|
587
|
-
var HeatMapLineLayerConfig = (color) => ({
|
|
712
|
+
var HeatMapLineLayerConfig = /* @__PURE__ */ __name((color) => ({
|
|
588
713
|
layout: {
|
|
589
714
|
// Enable for debugging
|
|
590
715
|
visibility: "none"
|
|
591
716
|
},
|
|
592
717
|
paint: {
|
|
593
718
|
"line-color": color,
|
|
594
|
-
"line-opacity": [
|
|
719
|
+
"line-opacity": [
|
|
720
|
+
"let",
|
|
721
|
+
"density",
|
|
722
|
+
0,
|
|
723
|
+
[
|
|
724
|
+
"interpolate",
|
|
725
|
+
[
|
|
726
|
+
"linear"
|
|
727
|
+
],
|
|
728
|
+
[
|
|
729
|
+
"var",
|
|
730
|
+
"density"
|
|
731
|
+
],
|
|
732
|
+
0.8,
|
|
733
|
+
[
|
|
734
|
+
"var",
|
|
735
|
+
"density"
|
|
736
|
+
],
|
|
737
|
+
1,
|
|
738
|
+
0.85
|
|
739
|
+
]
|
|
740
|
+
],
|
|
595
741
|
"line-width": 0.5
|
|
596
742
|
}
|
|
597
|
-
});
|
|
743
|
+
}), "HeatMapLineLayerConfig");
|
|
598
744
|
|
|
599
745
|
// src/Layers/Configs/HeatMapSymbolLayerConfig.ts
|
|
600
|
-
var HeatMapSymbolLayerConfig = (color) => ({
|
|
746
|
+
var HeatMapSymbolLayerConfig = /* @__PURE__ */ __name((color) => ({
|
|
601
747
|
layout: {
|
|
602
748
|
"text-anchor": "center",
|
|
603
749
|
"text-field": [
|
|
604
750
|
"concat",
|
|
605
751
|
"value: ",
|
|
606
|
-
[
|
|
752
|
+
[
|
|
753
|
+
"to-string",
|
|
754
|
+
[
|
|
755
|
+
"+",
|
|
756
|
+
[
|
|
757
|
+
"/",
|
|
758
|
+
[
|
|
759
|
+
"number",
|
|
760
|
+
[
|
|
761
|
+
"get",
|
|
762
|
+
"value"
|
|
763
|
+
]
|
|
764
|
+
],
|
|
765
|
+
2
|
|
766
|
+
],
|
|
767
|
+
0.25
|
|
768
|
+
]
|
|
769
|
+
],
|
|
607
770
|
"\n",
|
|
608
771
|
"count: ",
|
|
609
|
-
[
|
|
772
|
+
[
|
|
773
|
+
"to-string",
|
|
774
|
+
[
|
|
775
|
+
"get",
|
|
776
|
+
"count"
|
|
777
|
+
]
|
|
778
|
+
]
|
|
610
779
|
],
|
|
611
780
|
"text-size": 10,
|
|
612
781
|
"visibility": "none"
|
|
613
782
|
},
|
|
614
|
-
paint: {
|
|
615
|
-
|
|
783
|
+
paint: {
|
|
784
|
+
"text-color": color
|
|
785
|
+
}
|
|
786
|
+
}), "HeatMapSymbolLayerConfig");
|
|
616
787
|
|
|
617
788
|
// src/Layers/Configs/LocationPointLayerConfig.ts
|
|
618
|
-
var LocationPointLayerConfig = (color, circleRadius, circleOpacity) => {
|
|
789
|
+
var LocationPointLayerConfig = /* @__PURE__ */ __name((color, circleRadius, circleOpacity) => {
|
|
619
790
|
return {
|
|
620
791
|
paint: {
|
|
621
792
|
"circle-color": color,
|
|
@@ -623,17 +794,23 @@ var LocationPointLayerConfig = (color, circleRadius, circleOpacity) => {
|
|
|
623
794
|
"circle-radius": circleRadius
|
|
624
795
|
}
|
|
625
796
|
};
|
|
626
|
-
};
|
|
797
|
+
}, "LocationPointLayerConfig");
|
|
627
798
|
|
|
628
799
|
// src/Layers/FillLayer.ts
|
|
629
800
|
import { LayerBase } from "@xyo-network/sdk-geo";
|
|
630
801
|
var FillLayerBuilder = class extends LayerBase {
|
|
802
|
+
static {
|
|
803
|
+
__name(this, "FillLayerBuilder");
|
|
804
|
+
}
|
|
631
805
|
FillLayerOptions;
|
|
632
806
|
// ensures this class passes for `AnyLayer` type in MapBox
|
|
633
807
|
type = "fill";
|
|
634
808
|
constructor(id, source, FillLayerOptions) {
|
|
635
809
|
super(id, source);
|
|
636
|
-
this.FillLayerOptions = FillLayerOptions || {
|
|
810
|
+
this.FillLayerOptions = FillLayerOptions || {
|
|
811
|
+
id: this.id,
|
|
812
|
+
source: this.source
|
|
813
|
+
};
|
|
637
814
|
}
|
|
638
815
|
buildLayer() {
|
|
639
816
|
return {
|
|
@@ -648,12 +825,18 @@ var FillLayerBuilder = class extends LayerBase {
|
|
|
648
825
|
// src/Layers/LineLayer.ts
|
|
649
826
|
import { LayerBase as LayerBase2 } from "@xyo-network/sdk-geo";
|
|
650
827
|
var LineLayerBuilder = class extends LayerBase2 {
|
|
828
|
+
static {
|
|
829
|
+
__name(this, "LineLayerBuilder");
|
|
830
|
+
}
|
|
651
831
|
LineLayerOptions;
|
|
652
832
|
// ensures this class passes for `AnyLayer` type in MapBox
|
|
653
833
|
type = "line";
|
|
654
834
|
constructor(id, source, LineLayerOptions) {
|
|
655
835
|
super(id, source);
|
|
656
|
-
this.LineLayerOptions = LineLayerOptions || {
|
|
836
|
+
this.LineLayerOptions = LineLayerOptions || {
|
|
837
|
+
id: this.id,
|
|
838
|
+
source: this.source
|
|
839
|
+
};
|
|
657
840
|
}
|
|
658
841
|
buildLayer() {
|
|
659
842
|
return {
|
|
@@ -669,12 +852,18 @@ var LineLayerBuilder = class extends LayerBase2 {
|
|
|
669
852
|
// src/Layers/SymbolLayer.ts
|
|
670
853
|
import { LayerBase as LayerBase3 } from "@xyo-network/sdk-geo";
|
|
671
854
|
var SymbolLayerBuilder = class extends LayerBase3 {
|
|
855
|
+
static {
|
|
856
|
+
__name(this, "SymbolLayerBuilder");
|
|
857
|
+
}
|
|
672
858
|
SymbolLayerOptions;
|
|
673
859
|
// ensures this class passes for `AnyLayer` type in MapBox
|
|
674
860
|
type = "symbol";
|
|
675
861
|
constructor(id, source, SymbolLayerOptions) {
|
|
676
862
|
super(id, source);
|
|
677
|
-
this.SymbolLayerOptions = SymbolLayerOptions || {
|
|
863
|
+
this.SymbolLayerOptions = SymbolLayerOptions || {
|
|
864
|
+
id: this.id,
|
|
865
|
+
source: this.source
|
|
866
|
+
};
|
|
678
867
|
}
|
|
679
868
|
buildLayer() {
|
|
680
869
|
return {
|
|
@@ -695,43 +884,43 @@ var MapHeatConstants = {
|
|
|
695
884
|
LocationLineLayerId: "location-line-id",
|
|
696
885
|
LocationLineLayerSource: "location-line-source"
|
|
697
886
|
};
|
|
698
|
-
var LocationHeatMapLayerBuilder = (color, alternateColor = "#000") => {
|
|
699
|
-
const {
|
|
700
|
-
LocationFillLayerId,
|
|
701
|
-
LocationFillLayerSource,
|
|
702
|
-
LocationLineLayerId,
|
|
703
|
-
LocationLineLayerSource,
|
|
704
|
-
LocationDebugLayerId,
|
|
705
|
-
LocationDebugLayerSource
|
|
706
|
-
} = MapHeatConstants;
|
|
887
|
+
var LocationHeatMapLayerBuilder = /* @__PURE__ */ __name((color, alternateColor = "#000") => {
|
|
888
|
+
const { LocationFillLayerId, LocationFillLayerSource, LocationLineLayerId, LocationLineLayerSource, LocationDebugLayerId, LocationDebugLayerSource } = MapHeatConstants;
|
|
707
889
|
const fillLayerConfig = HeatMapFillLayerConfig(color);
|
|
708
890
|
const lineLayerConfig = HeatMapLineLayerConfig(color);
|
|
709
891
|
const debugLayerConfig = HeatMapSymbolLayerConfig(alternateColor);
|
|
710
892
|
const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
|
|
711
893
|
const lineLayer = new LineLayerBuilder(LocationLineLayerId, LocationLineLayerSource, lineLayerConfig);
|
|
712
894
|
const debugLayer2 = new SymbolLayerBuilder(LocationDebugLayerId, LocationDebugLayerSource, debugLayerConfig);
|
|
713
|
-
return [
|
|
714
|
-
|
|
895
|
+
return [
|
|
896
|
+
fillLayer,
|
|
897
|
+
lineLayer,
|
|
898
|
+
debugLayer2
|
|
899
|
+
];
|
|
900
|
+
}, "LocationHeatMapLayerBuilder");
|
|
715
901
|
|
|
716
902
|
// src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts
|
|
717
|
-
var MapHeatConstants2 = (index, type) => ({
|
|
903
|
+
var MapHeatConstants2 = /* @__PURE__ */ __name((index, type) => ({
|
|
718
904
|
LocationDebugLayerId: `location-${type}-debug-id-${index}`,
|
|
719
905
|
LocationDebugLayerSource: `location-${type}-debug-source-${index}`,
|
|
720
906
|
LocationFillLayerId: `location-${type}-fill-id-${index}`,
|
|
721
907
|
LocationFillLayerSource: `location-${type}-fill-source-${index}`,
|
|
722
908
|
LocationLineLayerId: `location-${type}-line-id-${index}`,
|
|
723
909
|
LocationLineLayerSource: `location-${type}-line-source-${index}`
|
|
724
|
-
});
|
|
725
|
-
var LocationHeatMapLayerBuilderAnimated = (color, index, type = "") => {
|
|
910
|
+
}), "MapHeatConstants");
|
|
911
|
+
var LocationHeatMapLayerBuilderAnimated = /* @__PURE__ */ __name((color, index, type = "") => {
|
|
726
912
|
const { LocationFillLayerId, LocationFillLayerSource } = MapHeatConstants2(index, type);
|
|
727
913
|
const fillLayerConfig = HeatMapFillLayerConfig(color);
|
|
728
914
|
const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
|
|
729
915
|
return fillLayer;
|
|
730
|
-
};
|
|
916
|
+
}, "LocationHeatMapLayerBuilderAnimated");
|
|
731
917
|
|
|
732
918
|
// src/Layers/CircleLayer.ts
|
|
733
919
|
import { LayerBase as LayerBase4 } from "@xyo-network/sdk-geo";
|
|
734
920
|
var CircleLayerBuilder = class extends LayerBase4 {
|
|
921
|
+
static {
|
|
922
|
+
__name(this, "CircleLayerBuilder");
|
|
923
|
+
}
|
|
735
924
|
CircleLayerOptions;
|
|
736
925
|
// ensures this class passes for `AnyLayer` type in MapBox
|
|
737
926
|
type = "circle";
|
|
@@ -745,7 +934,11 @@ var CircleLayerBuilder = class extends LayerBase4 {
|
|
|
745
934
|
}
|
|
746
935
|
buildLayer() {
|
|
747
936
|
return {
|
|
748
|
-
filter: [
|
|
937
|
+
filter: [
|
|
938
|
+
"==",
|
|
939
|
+
"$type",
|
|
940
|
+
"Point"
|
|
941
|
+
],
|
|
749
942
|
layout: {},
|
|
750
943
|
paint: {
|
|
751
944
|
"circle-color": "#ff0000",
|
|
@@ -764,33 +957,25 @@ var MapPointsConstants = {
|
|
|
764
957
|
LocationDotsLayerId: "location-dots",
|
|
765
958
|
LocationDotsLayerSource: "location-dots-source"
|
|
766
959
|
};
|
|
767
|
-
var LocationPointsMapLayerBuilder = (color, circleRadius = 6, circleOpacity = 0.8) => {
|
|
960
|
+
var LocationPointsMapLayerBuilder = /* @__PURE__ */ __name((color, circleRadius = 6, circleOpacity = 0.8) => {
|
|
768
961
|
const { LocationDotsLayerId, LocationDotsLayerSource } = MapPointsConstants;
|
|
769
962
|
const dotLayerConfig = LocationPointLayerConfig(color, circleRadius, circleOpacity);
|
|
770
963
|
const dotLayer = new CircleLayerBuilder(LocationDotsLayerId, LocationDotsLayerSource, dotLayerConfig);
|
|
771
|
-
return [
|
|
772
|
-
|
|
964
|
+
return [
|
|
965
|
+
dotLayer
|
|
966
|
+
];
|
|
967
|
+
}, "LocationPointsMapLayerBuilder");
|
|
773
968
|
|
|
774
969
|
// src/Components/MapBoxHeat.tsx
|
|
775
970
|
import { FlexCol } from "@xylabs/react-flexbox";
|
|
971
|
+
import React7 from "react";
|
|
776
972
|
|
|
777
973
|
// src/Components/MapBox.tsx
|
|
778
974
|
import "mapbox-gl/dist/mapbox-gl.css";
|
|
779
975
|
import { MapStyle } from "@xyo-network/react-map-model";
|
|
780
976
|
import { Map } from "mapbox-gl";
|
|
781
|
-
import {
|
|
782
|
-
|
|
783
|
-
useRef,
|
|
784
|
-
useState as useState4
|
|
785
|
-
} from "react";
|
|
786
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
787
|
-
var MapBox = ({
|
|
788
|
-
accessToken,
|
|
789
|
-
darkMode = false,
|
|
790
|
-
options,
|
|
791
|
-
zoom = 2,
|
|
792
|
-
...props
|
|
793
|
-
}) => {
|
|
977
|
+
import React4, { useEffect as useEffect5, useRef, useState as useState4 } from "react";
|
|
978
|
+
var MapBox = /* @__PURE__ */ __name(({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
|
|
794
979
|
const [map, setMap] = useState4();
|
|
795
980
|
const mapContainerRef = useRef(null);
|
|
796
981
|
const mapCanvasRef = useRef(null);
|
|
@@ -804,11 +989,18 @@ var MapBox = ({
|
|
|
804
989
|
} else {
|
|
805
990
|
map?.setStyle(`mapbox://styles/${darkMode ? MapStyle.Dark : MapStyle.Light}`);
|
|
806
991
|
}
|
|
807
|
-
}, [
|
|
992
|
+
}, [
|
|
993
|
+
map,
|
|
994
|
+
darkMode,
|
|
995
|
+
mapSettings
|
|
996
|
+
]);
|
|
808
997
|
useEffect5(() => {
|
|
809
998
|
const map2 = new Map({
|
|
810
999
|
accessToken,
|
|
811
|
-
center: [
|
|
1000
|
+
center: [
|
|
1001
|
+
0,
|
|
1002
|
+
0
|
|
1003
|
+
],
|
|
812
1004
|
container: mapContainerRef.current ?? "",
|
|
813
1005
|
style: `mapbox://styles/${MapStyle.Light}`,
|
|
814
1006
|
zoom,
|
|
@@ -822,202 +1014,201 @@ var MapBox = ({
|
|
|
822
1014
|
console.log("Removing Map");
|
|
823
1015
|
map2.remove();
|
|
824
1016
|
};
|
|
825
|
-
}, [
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1017
|
+
}, [
|
|
1018
|
+
mapContainerRef,
|
|
1019
|
+
setMap,
|
|
1020
|
+
options,
|
|
1021
|
+
zoom,
|
|
1022
|
+
setMapBoxInstance,
|
|
1023
|
+
accessToken
|
|
1024
|
+
]);
|
|
1025
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1026
|
+
ref: /* @__PURE__ */ __name((el) => {
|
|
1027
|
+
mapContainerRef.current = el;
|
|
1028
|
+
}, "ref"),
|
|
1029
|
+
style: {
|
|
1030
|
+
bottom: 0,
|
|
1031
|
+
left: 0,
|
|
1032
|
+
position: "absolute",
|
|
1033
|
+
right: 0,
|
|
1034
|
+
top: 0,
|
|
1035
|
+
...props
|
|
840
1036
|
}
|
|
841
|
-
);
|
|
842
|
-
};
|
|
1037
|
+
});
|
|
1038
|
+
}, "MapBox");
|
|
843
1039
|
|
|
844
1040
|
// src/Components/MapSettingsComponents/Setting.tsx
|
|
845
1041
|
import { FormControlLabel, Switch } from "@mui/material";
|
|
846
|
-
import
|
|
847
|
-
var MapSettingSwitch = ({
|
|
848
|
-
developerMode,
|
|
849
|
-
field,
|
|
850
|
-
...props
|
|
851
|
-
}) => {
|
|
1042
|
+
import React5 from "react";
|
|
1043
|
+
var MapSettingSwitch = /* @__PURE__ */ __name(({ developerMode, field, ...props }) => {
|
|
852
1044
|
const { mapSettings, setMapSettings } = useMapSettings();
|
|
853
1045
|
const setting = mapSettings?.[field];
|
|
854
|
-
const onLocalChange = (event) => {
|
|
1046
|
+
const onLocalChange = /* @__PURE__ */ __name((event) => {
|
|
855
1047
|
if (setting) {
|
|
856
1048
|
setMapSettings?.((previous) => {
|
|
857
1049
|
previous[setting.field].value = event.target.checked;
|
|
858
|
-
return {
|
|
1050
|
+
return {
|
|
1051
|
+
...previous
|
|
1052
|
+
};
|
|
859
1053
|
});
|
|
860
1054
|
}
|
|
861
|
-
};
|
|
1055
|
+
}, "onLocalChange");
|
|
862
1056
|
if (setting?.devMode && developerMode === false) {
|
|
863
1057
|
return null;
|
|
864
1058
|
}
|
|
865
|
-
return setting?.hidden ? null : /* @__PURE__ */
|
|
866
|
-
|
|
1059
|
+
return setting?.hidden ? null : /* @__PURE__ */ React5.createElement(FormControlLabel, {
|
|
1060
|
+
label: setting?.label,
|
|
1061
|
+
control: /* @__PURE__ */ React5.createElement(Switch, {
|
|
1062
|
+
checked: setting?.value,
|
|
1063
|
+
onChange: onLocalChange,
|
|
1064
|
+
...props
|
|
1065
|
+
})
|
|
1066
|
+
});
|
|
1067
|
+
}, "MapSettingSwitch");
|
|
867
1068
|
|
|
868
1069
|
// src/Components/MapSettingsComponents/SettingsBox.tsx
|
|
869
1070
|
import { Paper, Stack } from "@mui/material";
|
|
870
1071
|
import { useAppSettings } from "@xylabs/react-app-settings";
|
|
871
1072
|
import { FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
|
|
872
|
-
import
|
|
873
|
-
var MapSettingsBox = ({ developerMode, ...props }) => {
|
|
1073
|
+
import React6 from "react";
|
|
1074
|
+
var MapSettingsBox = /* @__PURE__ */ __name(({ developerMode, ...props }) => {
|
|
874
1075
|
const { mapSettings } = useMapSettings();
|
|
875
1076
|
const { developerMode: devModeFromContext } = useAppSettings();
|
|
876
1077
|
const resolveDeveloperMode = developerMode ?? devModeFromContext;
|
|
877
|
-
return mapSettings && resolveDeveloperMode ? /* @__PURE__ */
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1078
|
+
return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ React6.createElement(FlexGrowRow, {
|
|
1079
|
+
bottom: 36,
|
|
1080
|
+
left: 10,
|
|
1081
|
+
position: "absolute",
|
|
1082
|
+
...props
|
|
1083
|
+
}, /* @__PURE__ */ React6.createElement(FlexRow, {
|
|
1084
|
+
paddingX: 2
|
|
1085
|
+
}, /* @__PURE__ */ React6.createElement(Paper, null, /* @__PURE__ */ React6.createElement(Stack, {
|
|
1086
|
+
direction: "row",
|
|
1087
|
+
spacing: 1,
|
|
1088
|
+
marginX: 1
|
|
1089
|
+
}, Object.keys(mapSettings).map((key, index) => {
|
|
1090
|
+
return /* @__PURE__ */ React6.createElement(MapSettingSwitch, {
|
|
1091
|
+
key: index,
|
|
1092
|
+
field: mapSettings[key].field,
|
|
1093
|
+
developerMode
|
|
1094
|
+
});
|
|
1095
|
+
}))))) : null;
|
|
1096
|
+
}, "MapSettingsBox");
|
|
881
1097
|
|
|
882
1098
|
// src/Components/MapBoxHeat.tsx
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}) => {
|
|
893
|
-
return /* @__PURE__ */ jsxs(FlexCol, { ...props, children: [
|
|
894
|
-
/* @__PURE__ */ jsx7(MapBox, { accessToken, options: mapBoxOptions, zoom }),
|
|
895
|
-
/* @__PURE__ */ jsx7(MapSettingsBox, { developerMode }),
|
|
896
|
-
legend,
|
|
897
|
-
children
|
|
898
|
-
] });
|
|
899
|
-
};
|
|
1099
|
+
var MapboxHeatFlexBox = /* @__PURE__ */ __name(({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
|
|
1100
|
+
return /* @__PURE__ */ React7.createElement(FlexCol, props, /* @__PURE__ */ React7.createElement(MapBox, {
|
|
1101
|
+
accessToken,
|
|
1102
|
+
options: mapBoxOptions,
|
|
1103
|
+
zoom
|
|
1104
|
+
}), /* @__PURE__ */ React7.createElement(MapSettingsBox, {
|
|
1105
|
+
developerMode
|
|
1106
|
+
}), legend, children);
|
|
1107
|
+
}, "MapboxHeatFlexBox");
|
|
900
1108
|
|
|
901
1109
|
// src/Components/AnimatedHeatMap.tsx
|
|
902
|
-
|
|
903
|
-
var AnimatedHeatMap = ({
|
|
904
|
-
accessToken,
|
|
905
|
-
animatedFeatureSets,
|
|
906
|
-
defaultMapSettings,
|
|
907
|
-
heatMapColorProps,
|
|
908
|
-
staticFeatureSet,
|
|
909
|
-
...props
|
|
910
|
-
}) => {
|
|
1110
|
+
var AnimatedHeatMap = /* @__PURE__ */ __name(({ accessToken, animatedFeatureSets, defaultMapSettings, heatMapColorProps, staticFeatureSet, ...props }) => {
|
|
911
1111
|
const theme = useTheme();
|
|
912
|
-
const {
|
|
913
|
-
staticMapColor,
|
|
914
|
-
lowUsageColor,
|
|
915
|
-
highUsageColor
|
|
916
|
-
} = heatMapColorProps || {};
|
|
1112
|
+
const { staticMapColor, lowUsageColor, highUsageColor } = heatMapColorProps || {};
|
|
917
1113
|
const localStaticMapColor = staticMapColor ?? theme.vars.palette.primary.light;
|
|
918
1114
|
const [layers] = useState5(() => [
|
|
919
1115
|
LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, "static"),
|
|
920
1116
|
LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, "animated"),
|
|
921
1117
|
LocationHeatMapLayerBuilderAnimated(highUsageColor || darkenCss(localStaticMapColor, 0.9), 1, "animated")
|
|
922
1118
|
]);
|
|
923
|
-
return animatedFeatureSets?.length ? /* @__PURE__ */
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
1119
|
+
return animatedFeatureSets?.length ? /* @__PURE__ */ React8.createElement(MapBoxInstanceProvider, null, /* @__PURE__ */ React8.createElement(MapSettingsProvider, {
|
|
1120
|
+
defaultMapSettings,
|
|
1121
|
+
debugLayerName: MapHeatConstants.LocationDebugLayerId
|
|
1122
|
+
}, /* @__PURE__ */ React8.createElement(HeatMapInitializerProvider, {
|
|
1123
|
+
features: staticFeatureSet,
|
|
1124
|
+
layers: [
|
|
1125
|
+
layers[0]
|
|
1126
|
+
],
|
|
1127
|
+
featureSets: animatedFeatureSets,
|
|
1128
|
+
featureSetsLayers: layers.slice(1, 3),
|
|
1129
|
+
heatMapColorProps
|
|
1130
|
+
}, /* @__PURE__ */ React8.createElement(MapboxHeatFlexBox, {
|
|
1131
|
+
accessToken,
|
|
1132
|
+
...props
|
|
1133
|
+
})))) : /* @__PURE__ */ React8.createElement(FlexCol2, {
|
|
1134
|
+
minHeight: 160,
|
|
1135
|
+
minWidth: 160,
|
|
1136
|
+
busy: true
|
|
1137
|
+
});
|
|
1138
|
+
}, "AnimatedHeatMap");
|
|
935
1139
|
|
|
936
1140
|
// src/Components/AnimatedHeatMapLoaded.tsx
|
|
937
1141
|
import { Alert, AlertTitle } from "@mui/material";
|
|
938
1142
|
import { FlexCol as FlexCol5 } from "@xylabs/react-flexbox";
|
|
939
1143
|
import { useWeakArchivistFromNode, useWeakArchivistGet } from "@xyo-network/react-archivist";
|
|
940
|
-
import {
|
|
941
|
-
|
|
942
|
-
useFindHashes,
|
|
943
|
-
useHeatMapColors
|
|
944
|
-
} from "@xyo-network/react-map-model";
|
|
1144
|
+
import { AnimatedHeatMapSettings, useFindHashes, useHeatMapColors } from "@xyo-network/react-map-model";
|
|
1145
|
+
import React11 from "react";
|
|
945
1146
|
|
|
946
1147
|
// src/Components/Legend.tsx
|
|
947
1148
|
import { useMediaQuery, useTheme as useTheme3 } from "@mui/material";
|
|
948
1149
|
import { FlexCol as FlexCol4 } from "@xylabs/react-flexbox";
|
|
1150
|
+
import React10 from "react";
|
|
949
1151
|
|
|
950
1152
|
// src/Components/Legends/ColorGradient.tsx
|
|
951
1153
|
import { Typography, useTheme as useTheme2 } from "@mui/material";
|
|
952
1154
|
import { FlexCol as FlexCol3, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
|
|
953
|
-
import
|
|
954
|
-
var ColorGradientLegend = ({
|
|
955
|
-
startColor,
|
|
956
|
-
endColor,
|
|
957
|
-
startLabel,
|
|
958
|
-
endLabel,
|
|
959
|
-
heading,
|
|
960
|
-
textColor,
|
|
961
|
-
...props
|
|
962
|
-
}) => {
|
|
1155
|
+
import React9 from "react";
|
|
1156
|
+
var ColorGradientLegend = /* @__PURE__ */ __name(({ startColor, endColor, startLabel, endLabel, heading, textColor, ...props }) => {
|
|
963
1157
|
const theme = useTheme2();
|
|
964
|
-
return /* @__PURE__ */
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
1158
|
+
return /* @__PURE__ */ React9.createElement(FlexCol3, props, /* @__PURE__ */ React9.createElement(Typography, {
|
|
1159
|
+
mb: theme.spacing(0.25),
|
|
1160
|
+
color: textColor,
|
|
1161
|
+
variant: "caption",
|
|
1162
|
+
textAlign: "center"
|
|
1163
|
+
}, heading), /* @__PURE__ */ React9.createElement(FlexCol3, {
|
|
1164
|
+
flexGrow: 1,
|
|
1165
|
+
alignItems: "stretch",
|
|
1166
|
+
paddingX: theme.spacing(1),
|
|
1167
|
+
mb: theme.spacing(0.25)
|
|
1168
|
+
}, /* @__PURE__ */ React9.createElement(FlexCol3, {
|
|
1169
|
+
height: theme.spacing(0.75),
|
|
1170
|
+
border: `1px solid ${textColor}`,
|
|
1171
|
+
sx: {
|
|
1172
|
+
backgroundImage: `linear-gradient(to right, ${startColor},${endColor})`
|
|
1173
|
+
}
|
|
1174
|
+
})), /* @__PURE__ */ React9.createElement(FlexRow2, {
|
|
1175
|
+
flexGrow: 1,
|
|
1176
|
+
justifyContent: "space-between"
|
|
1177
|
+
}, /* @__PURE__ */ React9.createElement(Typography, {
|
|
1178
|
+
color: textColor,
|
|
1179
|
+
variant: "caption"
|
|
1180
|
+
}, startLabel), /* @__PURE__ */ React9.createElement(Typography, {
|
|
1181
|
+
color: textColor,
|
|
1182
|
+
variant: "caption"
|
|
1183
|
+
}, endLabel)));
|
|
1184
|
+
}, "ColorGradientLegend");
|
|
980
1185
|
|
|
981
1186
|
// src/Components/Legend.tsx
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
const
|
|
1187
|
+
var AnimatedHeatMapLegend = /* @__PURE__ */ __name(({ ...legendProps }) => {
|
|
1188
|
+
const { startColor, endColor, startLabel, endLabel, heading, textColor } = legendProps;
|
|
1189
|
+
const theme = useTheme3();
|
|
1190
|
+
const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
|
|
1191
|
+
return /* @__PURE__ */ React10.createElement(FlexCol4, {
|
|
1192
|
+
position: "absolute",
|
|
1193
|
+
bottom: 0,
|
|
1194
|
+
right: 0
|
|
1195
|
+
}, /* @__PURE__ */ React10.createElement(ColorGradientLegend, {
|
|
985
1196
|
startColor,
|
|
986
1197
|
endColor,
|
|
987
1198
|
startLabel,
|
|
988
1199
|
endLabel,
|
|
989
1200
|
heading,
|
|
990
|
-
textColor
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
endColor,
|
|
999
|
-
startLabel,
|
|
1000
|
-
endLabel,
|
|
1001
|
-
heading,
|
|
1002
|
-
textColor,
|
|
1003
|
-
...{
|
|
1004
|
-
alignItems: "stretch",
|
|
1005
|
-
marginBottom: theme.spacing(4),
|
|
1006
|
-
marginLeft: isSmall ? theme.spacing(3) : 0,
|
|
1007
|
-
marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
|
|
1008
|
-
width: isSmall ? "40vw" : theme.spacing(18)
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
) });
|
|
1012
|
-
};
|
|
1201
|
+
textColor,
|
|
1202
|
+
alignItems: "stretch",
|
|
1203
|
+
marginBottom: theme.spacing(4),
|
|
1204
|
+
marginLeft: isSmall ? theme.spacing(3) : 0,
|
|
1205
|
+
marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
|
|
1206
|
+
width: isSmall ? "40vw" : theme.spacing(18)
|
|
1207
|
+
}));
|
|
1208
|
+
}, "AnimatedHeatMapLegend");
|
|
1013
1209
|
|
|
1014
1210
|
// src/Components/AnimatedHeatMapLoaded.tsx
|
|
1015
|
-
|
|
1016
|
-
var AnimatedHeatMapLoaded = ({
|
|
1017
|
-
accessToken,
|
|
1018
|
-
archivistNameOrAddress,
|
|
1019
|
-
...props
|
|
1020
|
-
}) => {
|
|
1211
|
+
var AnimatedHeatMapLoaded = /* @__PURE__ */ __name(({ accessToken, archivistNameOrAddress, ...props }) => {
|
|
1021
1212
|
const hashes = useFindHashes();
|
|
1022
1213
|
const [archivist] = useWeakArchivistFromNode(archivistNameOrAddress);
|
|
1023
1214
|
const [payloads, xyoError] = useWeakArchivistGet(archivist, hashes);
|
|
@@ -1025,82 +1216,69 @@ var AnimatedHeatMapLoaded = ({
|
|
|
1025
1216
|
const { heatMapColorProps, legendProps } = useHeatMapColors();
|
|
1026
1217
|
const MapBoxHeatProps = {
|
|
1027
1218
|
flexGrow: 1,
|
|
1028
|
-
legend: legendProps ? /* @__PURE__ */
|
|
1219
|
+
legend: legendProps ? /* @__PURE__ */ React11.createElement(AnimatedHeatMapLegend, legendProps) : null
|
|
1029
1220
|
};
|
|
1030
|
-
return /* @__PURE__ */
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
)
|
|
1047
|
-
] });
|
|
1048
|
-
};
|
|
1221
|
+
return /* @__PURE__ */ React11.createElement(FlexCol5, {
|
|
1222
|
+
alignItems: "stretch",
|
|
1223
|
+
...props
|
|
1224
|
+
}, xyoError ? /* @__PURE__ */ React11.createElement(Alert, {
|
|
1225
|
+
sx: {
|
|
1226
|
+
mt: 2
|
|
1227
|
+
}
|
|
1228
|
+
}, /* @__PURE__ */ React11.createElement(AlertTitle, null, "Error Loading Map"), xyoError.message ? `Error: ${xyoError.message}` : null, "You might try authenticating again.") : null, hashes === void 0 ? /* @__PURE__ */ React11.createElement(Alert, null, "Missing answer hash for heat map query") : /* @__PURE__ */ React11.createElement(AnimatedHeatMap, {
|
|
1229
|
+
accessToken,
|
|
1230
|
+
defaultMapSettings: AnimatedHeatMapSettings,
|
|
1231
|
+
animatedFeatureSets: multipleFeatureSets.slice(1),
|
|
1232
|
+
staticFeatureSet: multipleFeatureSets[0],
|
|
1233
|
+
heatMapColorProps,
|
|
1234
|
+
...MapBoxHeatProps
|
|
1235
|
+
}));
|
|
1236
|
+
}, "AnimatedHeatMapLoaded");
|
|
1049
1237
|
|
|
1050
1238
|
// src/Components/HeatMapSettings.ts
|
|
1051
1239
|
import { DefaultMapSettings } from "@xyo-network/react-map-model";
|
|
1052
1240
|
var HeatMapSettings = DefaultMapSettings();
|
|
1053
|
-
var {
|
|
1054
|
-
debugLayer,
|
|
1055
|
-
scrollToZoom,
|
|
1056
|
-
fitToPoints
|
|
1057
|
-
} = HeatMapSettings;
|
|
1241
|
+
var { debugLayer, scrollToZoom, fitToPoints } = HeatMapSettings;
|
|
1058
1242
|
debugLayer.hidden = false;
|
|
1059
1243
|
scrollToZoom.value = true;
|
|
1060
1244
|
fitToPoints.value = true;
|
|
1061
1245
|
|
|
1062
1246
|
// src/Components/LayerAnimator.tsx
|
|
1063
1247
|
import { useInterval } from "@xylabs/react-shared";
|
|
1064
|
-
import {
|
|
1065
|
-
useCallback,
|
|
1066
|
-
useEffect as useEffect6,
|
|
1067
|
-
useMemo as useMemo7,
|
|
1068
|
-
useRef as useRef2
|
|
1069
|
-
} from "react";
|
|
1070
|
-
import { Fragment, jsx as jsx12 } from "react/jsx-runtime";
|
|
1248
|
+
import React12, { useCallback, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2 } from "react";
|
|
1071
1249
|
var timeIncrement = 2e3;
|
|
1072
1250
|
var animatedLayerCount = 3;
|
|
1073
|
-
var LayerAnimator = ({
|
|
1074
|
-
animateLayers,
|
|
1075
|
-
children,
|
|
1076
|
-
layers,
|
|
1077
|
-
layersInitialized,
|
|
1078
|
-
map
|
|
1079
|
-
}) => {
|
|
1251
|
+
var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, layersInitialized, map }) => {
|
|
1080
1252
|
const layerIndexQueue = useRef2([]);
|
|
1081
1253
|
const fillLayers = useMemo7(() => {
|
|
1082
1254
|
if (layers?.length && map && layersInitialized) {
|
|
1083
1255
|
return layers.filter((layer) => {
|
|
1084
1256
|
const fillLayer = layer.id.startsWith("location-fill");
|
|
1085
1257
|
if (fillLayer) {
|
|
1086
|
-
map.setPaintProperty(layer.id, "fill-opacity-transition", {
|
|
1258
|
+
map.setPaintProperty(layer.id, "fill-opacity-transition", {
|
|
1259
|
+
delay: 0,
|
|
1260
|
+
duration: 4e3
|
|
1261
|
+
});
|
|
1087
1262
|
}
|
|
1088
1263
|
return fillLayer;
|
|
1089
1264
|
});
|
|
1090
1265
|
}
|
|
1091
1266
|
return [];
|
|
1092
|
-
}, [
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1267
|
+
}, [
|
|
1268
|
+
layers,
|
|
1269
|
+
layersInitialized,
|
|
1270
|
+
map
|
|
1271
|
+
]);
|
|
1272
|
+
const incrementQueue = useCallback((index) => {
|
|
1273
|
+
if (fillLayers[index]) {
|
|
1274
|
+
layerIndexQueue.current.push(index);
|
|
1275
|
+
} else {
|
|
1276
|
+
layerIndexQueue.current.push(0);
|
|
1277
|
+
}
|
|
1278
|
+
return layerIndexQueue.current.at(-1);
|
|
1279
|
+
}, [
|
|
1280
|
+
fillLayers
|
|
1281
|
+
]);
|
|
1104
1282
|
const lastQueuedIndex = useCallback(() => {
|
|
1105
1283
|
const last = layerIndexQueue.current.at(-1);
|
|
1106
1284
|
if (last === void 0) {
|
|
@@ -1109,7 +1287,9 @@ var LayerAnimator = ({
|
|
|
1109
1287
|
} else {
|
|
1110
1288
|
return last;
|
|
1111
1289
|
}
|
|
1112
|
-
}, [
|
|
1290
|
+
}, [
|
|
1291
|
+
incrementQueue
|
|
1292
|
+
]);
|
|
1113
1293
|
const unshiftQueue = useCallback(() => {
|
|
1114
1294
|
layerIndexQueue.current.shift();
|
|
1115
1295
|
}, []);
|
|
@@ -1117,21 +1297,25 @@ var LayerAnimator = ({
|
|
|
1117
1297
|
const nextLayer = fillLayers[lastQueuedIndex()];
|
|
1118
1298
|
incrementQueue(lastQueuedIndex() + 1);
|
|
1119
1299
|
return nextLayer;
|
|
1120
|
-
}, [
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1300
|
+
}, [
|
|
1301
|
+
fillLayers,
|
|
1302
|
+
incrementQueue,
|
|
1303
|
+
lastQueuedIndex
|
|
1304
|
+
]);
|
|
1305
|
+
const layerAnimateWorker = useCallback((layer) => {
|
|
1306
|
+
if (layer) {
|
|
1307
|
+
map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
|
|
1308
|
+
setTimeout(() => {
|
|
1309
|
+
map?.setPaintProperty(layer.id, "fill-opacity", 0);
|
|
1310
|
+
unshiftQueue();
|
|
1311
|
+
}, timeIncrement * 2);
|
|
1312
|
+
} else {
|
|
1313
|
+
console.warn("tried to queue an empty layer");
|
|
1314
|
+
}
|
|
1315
|
+
}, [
|
|
1316
|
+
map,
|
|
1317
|
+
unshiftQueue
|
|
1318
|
+
]);
|
|
1135
1319
|
const queueLayerAnimation = useCallback(() => {
|
|
1136
1320
|
const animatedLayers = [];
|
|
1137
1321
|
for (let i = 0; i < animatedLayerCount; i++) {
|
|
@@ -1146,58 +1330,64 @@ var LayerAnimator = ({
|
|
|
1146
1330
|
}, timeIncrement * index);
|
|
1147
1331
|
}
|
|
1148
1332
|
}
|
|
1149
|
-
}, [
|
|
1333
|
+
}, [
|
|
1334
|
+
getNextLayer,
|
|
1335
|
+
layerAnimateWorker
|
|
1336
|
+
]);
|
|
1150
1337
|
useEffect6(() => {
|
|
1151
1338
|
if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
|
|
1152
1339
|
queueLayerAnimation();
|
|
1153
1340
|
}
|
|
1154
|
-
}, [
|
|
1341
|
+
}, [
|
|
1342
|
+
animateLayers,
|
|
1343
|
+
fillLayers.length,
|
|
1344
|
+
layersInitialized,
|
|
1345
|
+
map,
|
|
1346
|
+
queueLayerAnimation
|
|
1347
|
+
]);
|
|
1155
1348
|
useInterval(() => {
|
|
1156
1349
|
if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
|
|
1157
1350
|
queueLayerAnimation();
|
|
1158
1351
|
}
|
|
1159
1352
|
}, timeIncrement * animatedLayerCount);
|
|
1160
|
-
return /* @__PURE__ */
|
|
1161
|
-
};
|
|
1353
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, children);
|
|
1354
|
+
}, "LayerAnimator");
|
|
1162
1355
|
|
|
1163
1356
|
// src/Components/MapBoxPoints.tsx
|
|
1164
1357
|
import { Alert as Alert2 } from "@mui/material";
|
|
1165
1358
|
import { FlexCol as FlexCol6 } from "@xylabs/react-flexbox";
|
|
1166
|
-
import {
|
|
1167
|
-
|
|
1168
|
-
useEffect as useEffect7,
|
|
1169
|
-
useMemo as useMemo8
|
|
1170
|
-
} from "react";
|
|
1171
|
-
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1172
|
-
var MapboxPointsFlexBox = ({
|
|
1173
|
-
accessToken,
|
|
1174
|
-
features,
|
|
1175
|
-
fitToPointsPadding = 20,
|
|
1176
|
-
layers,
|
|
1177
|
-
zoom,
|
|
1178
|
-
...props
|
|
1179
|
-
}) => {
|
|
1359
|
+
import React13, { useCallback as useCallback2, useEffect as useEffect7, useMemo as useMemo8 } from "react";
|
|
1360
|
+
var MapboxPointsFlexBox = /* @__PURE__ */ __name(({ accessToken, features, fitToPointsPadding = 20, layers, zoom, ...props }) => {
|
|
1180
1361
|
const { mapSettings } = useMapSettings();
|
|
1181
1362
|
const { map, mapInitialized } = useMapBoxInstance();
|
|
1182
|
-
const customFitToBoundsOptions = (zoom2) => {
|
|
1363
|
+
const customFitToBoundsOptions = /* @__PURE__ */ __name((zoom2) => {
|
|
1183
1364
|
if (zoom2 !== void 0) {
|
|
1184
|
-
return {
|
|
1365
|
+
return {
|
|
1366
|
+
maxZoom: zoom2
|
|
1367
|
+
};
|
|
1185
1368
|
}
|
|
1186
1369
|
return {};
|
|
1187
|
-
};
|
|
1370
|
+
}, "customFitToBoundsOptions");
|
|
1188
1371
|
const mapPoints = useMemo8(() => {
|
|
1189
1372
|
return map && features?.length ? new MapPoints({
|
|
1190
1373
|
features,
|
|
1191
1374
|
map,
|
|
1192
1375
|
zoom
|
|
1193
1376
|
}) : void 0;
|
|
1194
|
-
}, [
|
|
1377
|
+
}, [
|
|
1378
|
+
map,
|
|
1379
|
+
features,
|
|
1380
|
+
zoom
|
|
1381
|
+
]);
|
|
1195
1382
|
const updateFeatures = useCallback2(() => {
|
|
1196
|
-
if (mapPoints?.isMapReady && features?.length && layers)
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1383
|
+
if (mapPoints?.isMapReady && features?.length && layers) for (const layer of layers) {
|
|
1384
|
+
mapPoints.initializeMapSource(layer);
|
|
1385
|
+
}
|
|
1386
|
+
}, [
|
|
1387
|
+
mapPoints,
|
|
1388
|
+
features,
|
|
1389
|
+
layers
|
|
1390
|
+
]);
|
|
1201
1391
|
const updateMapSetup = useCallback2(() => {
|
|
1202
1392
|
const { fitToPoints: fitToPoints2 } = mapSettings || {};
|
|
1203
1393
|
if (mapPoints && map && fitToPoints2?.value === true) {
|
|
@@ -1211,7 +1401,13 @@ var MapboxPointsFlexBox = ({
|
|
|
1211
1401
|
...customFitToBoundsOptions(zoom)
|
|
1212
1402
|
});
|
|
1213
1403
|
}
|
|
1214
|
-
}, [
|
|
1404
|
+
}, [
|
|
1405
|
+
mapSettings,
|
|
1406
|
+
mapPoints,
|
|
1407
|
+
map,
|
|
1408
|
+
fitToPointsPadding,
|
|
1409
|
+
zoom
|
|
1410
|
+
]);
|
|
1215
1411
|
const reInitializeMap = useCallback2(() => {
|
|
1216
1412
|
mapPoints?.initialMapPositioning({
|
|
1217
1413
|
padding: {
|
|
@@ -1223,18 +1419,33 @@ var MapboxPointsFlexBox = ({
|
|
|
1223
1419
|
...customFitToBoundsOptions(zoom)
|
|
1224
1420
|
});
|
|
1225
1421
|
updateFeatures();
|
|
1226
|
-
}, [
|
|
1422
|
+
}, [
|
|
1423
|
+
mapPoints,
|
|
1424
|
+
fitToPointsPadding,
|
|
1425
|
+
updateFeatures,
|
|
1426
|
+
zoom
|
|
1427
|
+
]);
|
|
1227
1428
|
useEffect7(() => {
|
|
1228
1429
|
if (mapInitialized) {
|
|
1229
1430
|
updateMapSetup();
|
|
1230
1431
|
reInitializeMap();
|
|
1231
1432
|
}
|
|
1232
|
-
}, [
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
]
|
|
1237
|
-
|
|
1433
|
+
}, [
|
|
1434
|
+
mapInitialized,
|
|
1435
|
+
reInitializeMap,
|
|
1436
|
+
updateMapSetup
|
|
1437
|
+
]);
|
|
1438
|
+
return /* @__PURE__ */ React13.createElement(FlexCol6, {
|
|
1439
|
+
alignItems: "stretch",
|
|
1440
|
+
id: "xyo-mapbox-wrap",
|
|
1441
|
+
...props
|
|
1442
|
+
}, features ? /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(MapBox, {
|
|
1443
|
+
accessToken,
|
|
1444
|
+
zoom
|
|
1445
|
+
}), /* @__PURE__ */ React13.createElement(MapSettingsBox, null)) : /* @__PURE__ */ React13.createElement(Alert2, {
|
|
1446
|
+
severity: "error"
|
|
1447
|
+
}, "No data to show"));
|
|
1448
|
+
}, "MapboxPointsFlexBox");
|
|
1238
1449
|
export {
|
|
1239
1450
|
AnimatedHeatMap,
|
|
1240
1451
|
AnimatedHeatMapLegend,
|