@superrouteca/smap-react 1.6.1 → 1.6.5
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/CHANGELOG.md +8 -0
- package/README.md +18 -0
- package/dist/index.cjs +143 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +129 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.5 — 2026-11-22
|
|
4
|
+
|
|
5
|
+
- `<Indoor>`: a site of sIndoor drawn one level at a time under your layers, with a level control (the Web SDK's `addIndoor`); `level` follows the prop, `onLevelChange`, `onClick` and `onLoad`; a new source adds it again; removed on unmount. Layers take `indoor: { id, level }` in their options.
|
|
6
|
+
|
|
7
|
+
## 1.6.2 — 2026-11-05
|
|
8
|
+
|
|
9
|
+
- Comes with Web SDK 1.6.2: dragging a tilted map drawn by sRender keeps the place under the pointer.
|
|
10
|
+
|
|
3
11
|
## 1.6.1 — 2026-11-04
|
|
4
12
|
|
|
5
13
|
- Comes with Web SDK 1.6.1: dragging a map drawn by sRender keeps the place under the pointer; a double click zooms around the pointer.
|
package/README.md
CHANGED
|
@@ -179,6 +179,24 @@ gives the map's own events in the SDK's shape.
|
|
|
179
179
|
- `<DrawTool>` takes `onDrawing` and the options `measure`, `style`, `allowSelfIntersection` and `snapLayers`;
|
|
180
180
|
`onTool`'s tool has `setProperties`. `<Models>` takes `options.color` per feature.
|
|
181
181
|
|
|
182
|
+
## Indoor maps (sIndoor sites)
|
|
183
|
+
|
|
184
|
+
`<Indoor>` draws a site of sIndoor (a warehouse, a store, a mall) one level at a time under your layers, with a level
|
|
185
|
+
control — the Web SDK's `addIndoor` (see its README, *Indoor maps*).
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
<SMap apiKey="smk_…" indoor="public">
|
|
189
|
+
<Indoor id="mall" source={{ site: 'op-7-mall' }} level={level} onLevelChange={setLevel}
|
|
190
|
+
onClick={(feature) => console.log(feature.properties)} />
|
|
191
|
+
<Points id="dot" data={here} options={{ indoor: { id: 'mall', level: 'B1' } }} />
|
|
192
|
+
</SMap>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Props: `id`, `source` (`{ site }`, `{ geojson }` or `{ url, headers }`; a change adds the layer again), `level` (a
|
|
196
|
+
change shows that level), `control`, `style`, `minzoom`, `basemap`, `onClick`, `onLevelChange` and `onLoad(error)`.
|
|
197
|
+
Removed on unmount. `useSMap()` gives the map for `indoorToLngLat`, `lngLatToIndoor` and `indoorLevels`; `indoor` and
|
|
198
|
+
`indoorUrl` are props of `<SMap>` (read when the map is created).
|
|
199
|
+
|
|
182
200
|
## Plan editor
|
|
183
201
|
|
|
184
202
|
`<PlanEditor>` edits a plan of routes on the map with the ready-made panel (see the Web SDK's *Plan editor*): drag
|
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
DeckLayer: () => DeckLayer,
|
|
40
40
|
DrawTool: () => DrawTool,
|
|
41
41
|
Heatmap: () => Heatmap,
|
|
42
|
+
Indoor: () => Indoor,
|
|
42
43
|
Layers: () => Layers,
|
|
43
44
|
Lines: () => Lines,
|
|
44
45
|
MapImage: () => MapImage,
|
|
@@ -129,6 +130,8 @@ var SMap = (0, import_react.forwardRef)(function SMap2(props, ref) {
|
|
|
129
130
|
popupLoading: p.popupLoading,
|
|
130
131
|
tools: p.tools,
|
|
131
132
|
cooperativeGestures: p.cooperativeGestures,
|
|
133
|
+
...p.indoor ? { indoor: p.indoor } : {},
|
|
134
|
+
...p.indoorUrl ? { indoorUrl: p.indoorUrl } : {},
|
|
132
135
|
unavailableNotice: p.unavailableNotice
|
|
133
136
|
};
|
|
134
137
|
for (const k of Object.keys(options)) {
|
|
@@ -201,7 +204,7 @@ var SMap = (0, import_react.forwardRef)(function SMap2(props, ref) {
|
|
|
201
204
|
container.querySelectorAll(":scope > .smap-unavailable").forEach((n) => n.remove());
|
|
202
205
|
}
|
|
203
206
|
};
|
|
204
|
-
}, [props.apiKey, props.token, props.baseUrl, nodesKey, props.nearest, mapOptionsKey, hasGetToken]);
|
|
207
|
+
}, [props.apiKey, props.token, props.baseUrl, nodesKey, props.nearest, mapOptionsKey, hasGetToken, props.indoor, props.indoorUrl]);
|
|
205
208
|
const styleKey = key(props.style ?? "light");
|
|
206
209
|
(0, import_react.useEffect)(() => {
|
|
207
210
|
if (!map || applied.current.style === styleKey) {
|
|
@@ -467,8 +470,78 @@ function Circles(props) {
|
|
|
467
470
|
return useLayer("addCircles", props);
|
|
468
471
|
}
|
|
469
472
|
|
|
470
|
-
// src/
|
|
473
|
+
// src/indoor.tsx
|
|
471
474
|
var import_react3 = require("react");
|
|
475
|
+
function sourceKey(s) {
|
|
476
|
+
const g = s.geojson;
|
|
477
|
+
if (g && typeof g === "object") {
|
|
478
|
+
const l = g;
|
|
479
|
+
return JSON.stringify(["g", l.site, l.version, l.features?.length]);
|
|
480
|
+
}
|
|
481
|
+
return JSON.stringify(s);
|
|
482
|
+
}
|
|
483
|
+
function Indoor(props) {
|
|
484
|
+
const map = useSMap();
|
|
485
|
+
const latest = (0, import_react3.useRef)(props);
|
|
486
|
+
latest.current = props;
|
|
487
|
+
const { id, level } = props;
|
|
488
|
+
const src = sourceKey(props.source);
|
|
489
|
+
const looks = JSON.stringify({ c: props.control, s: props.style, m: props.minzoom, b: props.basemap, t: !!props.onClick });
|
|
490
|
+
const loaded = (0, import_react3.useRef)(false);
|
|
491
|
+
(0, import_react3.useEffect)(() => {
|
|
492
|
+
if (!map) {
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
const p = latest.current;
|
|
496
|
+
loaded.current = false;
|
|
497
|
+
let gone = false;
|
|
498
|
+
const onClick = p.onClick ? (f, at2) => latest.current.onClick?.(f, at2) : void 0;
|
|
499
|
+
const listener = (e) => {
|
|
500
|
+
if (e.id === id) {
|
|
501
|
+
latest.current.onLevelChange?.(e.level);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
map.on("indoorlevelchange", listener);
|
|
505
|
+
let added;
|
|
506
|
+
try {
|
|
507
|
+
added = map.addIndoor(id, p.source, { level: p.level, control: p.control, style: p.style, minzoom: p.minzoom, basemap: p.basemap, onClick });
|
|
508
|
+
} catch (e) {
|
|
509
|
+
added = Promise.reject(e);
|
|
510
|
+
}
|
|
511
|
+
added.then(() => {
|
|
512
|
+
if (gone) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
loaded.current = true;
|
|
516
|
+
const want = latest.current.level;
|
|
517
|
+
if (want !== void 0 && want !== map.getIndoorLevel(id)) {
|
|
518
|
+
map.setIndoorLevel(id, want);
|
|
519
|
+
}
|
|
520
|
+
latest.current.onLoad?.(null);
|
|
521
|
+
}, (e) => {
|
|
522
|
+
if (!gone) {
|
|
523
|
+
latest.current.onLoad?.(e instanceof Error ? e : new Error(String(e)));
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
return () => {
|
|
527
|
+
gone = true;
|
|
528
|
+
map.off("indoorlevelchange", listener);
|
|
529
|
+
if (!removedMaps.has(map)) {
|
|
530
|
+
map.removeIndoor(id);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
}, [map, id, src, looks]);
|
|
534
|
+
(0, import_react3.useEffect)(() => {
|
|
535
|
+
if (!map || !loaded.current || level === void 0 || map.getIndoorLevel(id) === level) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
map.setIndoorLevel(id, level);
|
|
539
|
+
}, [map, id, level]);
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/tools.tsx
|
|
544
|
+
var import_react4 = require("react");
|
|
472
545
|
var import_react_dom = require("react-dom");
|
|
473
546
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
474
547
|
var optionsKey2 = (v) => JSON.stringify(v ?? null);
|
|
@@ -480,22 +553,22 @@ function Tool(props) {
|
|
|
480
553
|
const isLayer = layerKey !== null;
|
|
481
554
|
const position = isLayer ? void 0 : props.position ?? (kind ? void 0 : "top-left");
|
|
482
555
|
const inPlace = !kind && !isLayer && position === "none";
|
|
483
|
-
const [box, setBox] = (0,
|
|
484
|
-
(0,
|
|
556
|
+
const [box, setBox] = (0, import_react4.useState)(null);
|
|
557
|
+
(0, import_react4.useEffect)(() => {
|
|
485
558
|
if (!kind && !isLayer && !inPlace && !box) {
|
|
486
559
|
setBox(document.createElement("div"));
|
|
487
560
|
}
|
|
488
561
|
}, [kind, isLayer, inPlace, box]);
|
|
489
|
-
const inPlaceRef = (0,
|
|
562
|
+
const inPlaceRef = (0, import_react4.useRef)(null);
|
|
490
563
|
const kindOptions = optionsKey2(props.options);
|
|
491
|
-
const latestOptions = (0,
|
|
564
|
+
const latestOptions = (0, import_react4.useRef)(props.options);
|
|
492
565
|
latestOptions.current = props.options;
|
|
493
566
|
if (box) {
|
|
494
567
|
box.className = props.className ?? "";
|
|
495
568
|
box.removeAttribute("style");
|
|
496
569
|
Object.assign(box.style, props.style || {});
|
|
497
570
|
}
|
|
498
|
-
(0,
|
|
571
|
+
(0, import_react4.useEffect)(() => {
|
|
499
572
|
if (!map) {
|
|
500
573
|
return void 0;
|
|
501
574
|
}
|
|
@@ -528,11 +601,11 @@ function Tool(props) {
|
|
|
528
601
|
}
|
|
529
602
|
function SearchTool(props) {
|
|
530
603
|
const map = useSMap();
|
|
531
|
-
const latest = (0,
|
|
604
|
+
const latest = (0, import_react4.useRef)(props);
|
|
532
605
|
latest.current = props;
|
|
533
606
|
const { id, search: _s, onPick: _p, ...rest } = props;
|
|
534
607
|
const looks = optionsKey2(rest);
|
|
535
|
-
(0,
|
|
608
|
+
(0, import_react4.useEffect)(() => {
|
|
536
609
|
if (!map) {
|
|
537
610
|
return void 0;
|
|
538
611
|
}
|
|
@@ -552,24 +625,24 @@ function SearchTool(props) {
|
|
|
552
625
|
}
|
|
553
626
|
|
|
554
627
|
// src/features.tsx
|
|
555
|
-
var
|
|
628
|
+
var import_react5 = require("react");
|
|
556
629
|
var import_react_dom2 = require("react-dom");
|
|
557
630
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
558
631
|
function CustomMarkers(props) {
|
|
559
632
|
const map = useSMap();
|
|
560
633
|
const { id, data, render: _render, featureStates, ...rest } = props;
|
|
561
|
-
const latest = (0,
|
|
634
|
+
const latest = (0, import_react5.useRef)(props);
|
|
562
635
|
latest.current = props;
|
|
563
|
-
const [entries, setEntries] = (0,
|
|
564
|
-
const held = (0,
|
|
565
|
-
const shown = (0,
|
|
636
|
+
const [entries, setEntries] = (0, import_react5.useState)(/* @__PURE__ */ new Map());
|
|
637
|
+
const held = (0, import_react5.useRef)(/* @__PURE__ */ new Map());
|
|
638
|
+
const shown = (0, import_react5.useRef)(null);
|
|
566
639
|
const looks = optionsKey(rest);
|
|
567
640
|
const keyOf = (properties, feature) => {
|
|
568
641
|
const by = latest.current.idProperty;
|
|
569
642
|
const v = by ? properties[by] : feature.id;
|
|
570
643
|
return v === void 0 || v === null ? `@${JSON.stringify(feature.geometry)}` : String(v);
|
|
571
644
|
};
|
|
572
|
-
(0,
|
|
645
|
+
(0, import_react5.useEffect)(() => {
|
|
573
646
|
if (!map) {
|
|
574
647
|
return void 0;
|
|
575
648
|
}
|
|
@@ -608,7 +681,7 @@ function CustomMarkers(props) {
|
|
|
608
681
|
}
|
|
609
682
|
};
|
|
610
683
|
}, [map, id, looks]);
|
|
611
|
-
(0,
|
|
684
|
+
(0, import_react5.useEffect)(() => {
|
|
612
685
|
if (!map || shown.current === null || shown.current === data) {
|
|
613
686
|
return;
|
|
614
687
|
}
|
|
@@ -641,10 +714,10 @@ function CustomMarkers(props) {
|
|
|
641
714
|
}
|
|
642
715
|
function useNativeLayer(add, id, looks, data) {
|
|
643
716
|
const map = useSMap();
|
|
644
|
-
const shown = (0,
|
|
645
|
-
const addRef = (0,
|
|
717
|
+
const shown = (0, import_react5.useRef)(null);
|
|
718
|
+
const addRef = (0, import_react5.useRef)(add);
|
|
646
719
|
addRef.current = add;
|
|
647
|
-
(0,
|
|
720
|
+
(0, import_react5.useEffect)(() => {
|
|
648
721
|
if (!map) {
|
|
649
722
|
return void 0;
|
|
650
723
|
}
|
|
@@ -657,7 +730,7 @@ function useNativeLayer(add, id, looks, data) {
|
|
|
657
730
|
}
|
|
658
731
|
};
|
|
659
732
|
}, [map, id, looks]);
|
|
660
|
-
(0,
|
|
733
|
+
(0, import_react5.useEffect)(() => {
|
|
661
734
|
if (!map || data === void 0 || shown.current === null || shown.current === data) {
|
|
662
735
|
return;
|
|
663
736
|
}
|
|
@@ -666,7 +739,7 @@ function useNativeLayer(add, id, looks, data) {
|
|
|
666
739
|
}, [map, id, data]);
|
|
667
740
|
}
|
|
668
741
|
function useLatest(value) {
|
|
669
|
-
const ref = (0,
|
|
742
|
+
const ref = (0, import_react5.useRef)(value);
|
|
670
743
|
ref.current = value;
|
|
671
744
|
return ref;
|
|
672
745
|
}
|
|
@@ -681,18 +754,18 @@ function Models(props) {
|
|
|
681
754
|
return null;
|
|
682
755
|
}
|
|
683
756
|
function CanvasTiles(props) {
|
|
684
|
-
const draw = (0,
|
|
757
|
+
const draw = (0, import_react5.useRef)(props.draw);
|
|
685
758
|
draw.current = props.draw;
|
|
686
759
|
useNativeLayer((m) => m.addCanvasTiles(props.id, (...a) => draw.current(...a), props.options), props.id, optionsKey(props.options));
|
|
687
760
|
return null;
|
|
688
761
|
}
|
|
689
762
|
function DrawTool(props) {
|
|
690
763
|
const map = useSMap();
|
|
691
|
-
const latest = (0,
|
|
764
|
+
const latest = (0, import_react5.useRef)(props);
|
|
692
765
|
latest.current = props;
|
|
693
766
|
const { onChange: _c, onTool: _t, onDrawing: _d, ...rest } = props;
|
|
694
767
|
const looks = optionsKey(rest) + (props.onDrawing ? "|drawing" : "");
|
|
695
|
-
(0,
|
|
768
|
+
(0, import_react5.useEffect)(() => {
|
|
696
769
|
if (!map) {
|
|
697
770
|
return void 0;
|
|
698
771
|
}
|
|
@@ -714,14 +787,14 @@ function DrawTool(props) {
|
|
|
714
787
|
}
|
|
715
788
|
function useMapImage(id, image, options) {
|
|
716
789
|
const map = useSMap();
|
|
717
|
-
const [loaded, setLoaded] = (0,
|
|
790
|
+
const [loaded, setLoaded] = (0, import_react5.useState)(null);
|
|
718
791
|
const onError = useLatest(options?.onError);
|
|
719
792
|
const pixelRatio = options?.pixelRatio;
|
|
720
793
|
const sdf = options?.sdf;
|
|
721
|
-
const last = (0,
|
|
722
|
-
const lastTarget = (0,
|
|
794
|
+
const last = (0, import_react5.useRef)(null);
|
|
795
|
+
const lastTarget = (0, import_react5.useRef)({ map: null, id: "" });
|
|
723
796
|
lastTarget.current = { map, id };
|
|
724
|
-
(0,
|
|
797
|
+
(0, import_react5.useEffect)(() => {
|
|
725
798
|
if (!map || image === null || image === void 0) {
|
|
726
799
|
return void 0;
|
|
727
800
|
}
|
|
@@ -767,7 +840,7 @@ function useMapImage(id, image, options) {
|
|
|
767
840
|
function MapImage(props) {
|
|
768
841
|
const loaded = useMapImage(props.id, props.image, { pixelRatio: props.pixelRatio, sdf: props.sdf, onError: props.onError });
|
|
769
842
|
const onLoad = useLatest(props.onLoad);
|
|
770
|
-
(0,
|
|
843
|
+
(0, import_react5.useEffect)(() => {
|
|
771
844
|
if (loaded) {
|
|
772
845
|
onLoad.current?.();
|
|
773
846
|
}
|
|
@@ -779,7 +852,7 @@ function ThreeLayer(props) {
|
|
|
779
852
|
const latest = useLatest(props);
|
|
780
853
|
const { id, onAdd, render, onRemove, onError: _e, ...placement } = props;
|
|
781
854
|
const looks = optionsKey(placement) + (onAdd ? "a" : "") + (render ? "r" : "") + (onRemove ? "x" : "");
|
|
782
|
-
(0,
|
|
855
|
+
(0, import_react5.useEffect)(() => {
|
|
783
856
|
if (!map) {
|
|
784
857
|
return void 0;
|
|
785
858
|
}
|
|
@@ -800,7 +873,7 @@ function ThreeLayer(props) {
|
|
|
800
873
|
}
|
|
801
874
|
|
|
802
875
|
// src/plan.tsx
|
|
803
|
-
var
|
|
876
|
+
var import_react6 = require("react");
|
|
804
877
|
function destroyOffMap(made) {
|
|
805
878
|
made.layer.remove = () => {
|
|
806
879
|
};
|
|
@@ -833,11 +906,11 @@ var EMPTY = {
|
|
|
833
906
|
};
|
|
834
907
|
function usePlanEditor(props) {
|
|
835
908
|
const map = useSMap();
|
|
836
|
-
const [editor, setEditor] = (0,
|
|
837
|
-
const [state, setState] = (0,
|
|
838
|
-
const latest = (0,
|
|
909
|
+
const [editor, setEditor] = (0, import_react6.useState)(null);
|
|
910
|
+
const [state, setState] = (0, import_react6.useState)(EMPTY);
|
|
911
|
+
const latest = (0, import_react6.useRef)(props);
|
|
839
912
|
latest.current = props;
|
|
840
|
-
const applied = (0,
|
|
913
|
+
const applied = (0, import_react6.useRef)(null);
|
|
841
914
|
const credentialKey = "key" in props.credentials ? "key:" + props.credentials.key : "token";
|
|
842
915
|
const madeKey = key2({
|
|
843
916
|
baseUrl: props.baseUrl,
|
|
@@ -861,7 +934,7 @@ function usePlanEditor(props) {
|
|
|
861
934
|
insertWaitMinAge: props.insertWaitMinAge,
|
|
862
935
|
insertWaitBudget: props.insertWaitBudget
|
|
863
936
|
});
|
|
864
|
-
(0,
|
|
937
|
+
(0, import_react6.useEffect)(() => {
|
|
865
938
|
if (!map) {
|
|
866
939
|
return void 0;
|
|
867
940
|
}
|
|
@@ -927,7 +1000,7 @@ function usePlanEditor(props) {
|
|
|
927
1000
|
};
|
|
928
1001
|
}, [map, credentialKey, madeKey]);
|
|
929
1002
|
const incoming = planKey(props.plan);
|
|
930
|
-
(0,
|
|
1003
|
+
(0, import_react6.useEffect)(() => {
|
|
931
1004
|
if (!editor || !latest.current.plan) {
|
|
932
1005
|
return;
|
|
933
1006
|
}
|
|
@@ -939,21 +1012,21 @@ function usePlanEditor(props) {
|
|
|
939
1012
|
editor.setPlan(latest.current.plan).catch(() => {
|
|
940
1013
|
});
|
|
941
1014
|
}, [editor, incoming]);
|
|
942
|
-
(0,
|
|
1015
|
+
(0, import_react6.useEffect)(() => {
|
|
943
1016
|
if (editor && editor.panel && props.language) {
|
|
944
1017
|
editor.panel.setLanguage(props.language);
|
|
945
1018
|
}
|
|
946
1019
|
}, [editor, props.language]);
|
|
947
1020
|
return { ...state, editor };
|
|
948
1021
|
}
|
|
949
|
-
var PlanEditor = (0,
|
|
1022
|
+
var PlanEditor = (0, import_react6.forwardRef)(function PlanEditor2(props, ref) {
|
|
950
1023
|
const { editor } = usePlanEditor(props);
|
|
951
|
-
(0,
|
|
1024
|
+
(0, import_react6.useImperativeHandle)(ref, () => editor, [editor]);
|
|
952
1025
|
return null;
|
|
953
1026
|
});
|
|
954
1027
|
|
|
955
1028
|
// src/interop.tsx
|
|
956
|
-
var
|
|
1029
|
+
var import_react7 = require("react");
|
|
957
1030
|
var sdk = __toESM(require("@superrouteca/smap"), 1);
|
|
958
1031
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
959
1032
|
function quietly(f) {
|
|
@@ -962,16 +1035,16 @@ function quietly(f) {
|
|
|
962
1035
|
} catch {
|
|
963
1036
|
}
|
|
964
1037
|
}
|
|
965
|
-
var SourceContext = (0,
|
|
1038
|
+
var SourceContext = (0, import_react7.createContext)(null);
|
|
966
1039
|
function Source(props) {
|
|
967
1040
|
const map = useSMap();
|
|
968
1041
|
const { id, source, children } = props;
|
|
969
|
-
const latest = (0,
|
|
1042
|
+
const latest = (0, import_react7.useRef)(source);
|
|
970
1043
|
latest.current = source;
|
|
971
|
-
const inside = (0,
|
|
972
|
-
const [shown, setShown] = (0,
|
|
973
|
-
const
|
|
974
|
-
(0,
|
|
1044
|
+
const inside = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
|
|
1045
|
+
const [shown, setShown] = (0, import_react7.useState)(null);
|
|
1046
|
+
const sourceKey2 = optionsKey(source);
|
|
1047
|
+
(0, import_react7.useEffect)(() => {
|
|
975
1048
|
if (!map) {
|
|
976
1049
|
return void 0;
|
|
977
1050
|
}
|
|
@@ -985,8 +1058,8 @@ function Source(props) {
|
|
|
985
1058
|
inside.current.clear();
|
|
986
1059
|
quietly(() => map.removeSource(id));
|
|
987
1060
|
};
|
|
988
|
-
}, [map, id,
|
|
989
|
-
const scope = (0,
|
|
1061
|
+
}, [map, id, sourceKey2]);
|
|
1062
|
+
const scope = (0, import_react7.useMemo)(() => ({
|
|
990
1063
|
id,
|
|
991
1064
|
register: (layerId) => {
|
|
992
1065
|
inside.current.add(layerId);
|
|
@@ -996,7 +1069,7 @@ function Source(props) {
|
|
|
996
1069
|
if (!map || !shown || shown.map !== map) {
|
|
997
1070
|
return null;
|
|
998
1071
|
}
|
|
999
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SourceContext.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SourceContext.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.Fragment, { children }, shown.generation) });
|
|
1000
1073
|
}
|
|
1001
1074
|
function effectiveLayer(layer, sourceId, visible) {
|
|
1002
1075
|
const out = { ...layer };
|
|
@@ -1023,14 +1096,14 @@ function applyDiff(prev, next, set) {
|
|
|
1023
1096
|
}
|
|
1024
1097
|
function StyleLayer(props) {
|
|
1025
1098
|
const map = useSMap();
|
|
1026
|
-
const scope = (0,
|
|
1099
|
+
const scope = (0, import_react7.useContext)(SourceContext);
|
|
1027
1100
|
const { layer, before, slot, visible = true } = props;
|
|
1028
1101
|
const current = effectiveLayer(layer, scope?.id, visible);
|
|
1029
|
-
const latest = (0,
|
|
1102
|
+
const latest = (0, import_react7.useRef)(current);
|
|
1030
1103
|
latest.current = current;
|
|
1031
|
-
const shown = (0,
|
|
1104
|
+
const shown = (0, import_react7.useRef)(null);
|
|
1032
1105
|
const structure = structureKey(current, before, slot);
|
|
1033
|
-
(0,
|
|
1106
|
+
(0, import_react7.useEffect)(() => {
|
|
1034
1107
|
if (!map) {
|
|
1035
1108
|
return void 0;
|
|
1036
1109
|
}
|
|
@@ -1054,7 +1127,7 @@ function StyleLayer(props) {
|
|
|
1054
1127
|
};
|
|
1055
1128
|
}, [map, structure, scope]);
|
|
1056
1129
|
const looks = optionsKey(current.paint) + optionsKey(current.layout) + optionsKey(current.filter);
|
|
1057
|
-
(0,
|
|
1130
|
+
(0, import_react7.useEffect)(() => {
|
|
1058
1131
|
const s = shown.current;
|
|
1059
1132
|
if (!map || !s || s.map !== map) {
|
|
1060
1133
|
return;
|
|
@@ -1075,12 +1148,12 @@ function StyleLayer(props) {
|
|
|
1075
1148
|
}
|
|
1076
1149
|
function useAddedLayer(method, id, options, remove) {
|
|
1077
1150
|
const map = useSMap();
|
|
1078
|
-
const latest = (0,
|
|
1151
|
+
const latest = (0, import_react7.useRef)(options);
|
|
1079
1152
|
latest.current = options;
|
|
1080
|
-
const removeLatest = (0,
|
|
1153
|
+
const removeLatest = (0, import_react7.useRef)(remove);
|
|
1081
1154
|
removeLatest.current = remove;
|
|
1082
1155
|
const looks = optionsKey(options);
|
|
1083
|
-
(0,
|
|
1156
|
+
(0, import_react7.useEffect)(() => {
|
|
1084
1157
|
if (!map) {
|
|
1085
1158
|
return void 0;
|
|
1086
1159
|
}
|
|
@@ -1127,13 +1200,13 @@ var dataLayerIds = (id) => [id, `${id}:lines`, `${id}:areas`];
|
|
|
1127
1200
|
function Data(props) {
|
|
1128
1201
|
const map = useSMap();
|
|
1129
1202
|
const { id, data, format, lat, lng, options, slot, onTap, visible = true, popupOptions } = props;
|
|
1130
|
-
const latest = (0,
|
|
1203
|
+
const latest = (0, import_react7.useRef)(props);
|
|
1131
1204
|
latest.current = props;
|
|
1132
|
-
const shownVisible = (0,
|
|
1205
|
+
const shownVisible = (0, import_react7.useRef)(true);
|
|
1133
1206
|
const hasTap = !!onTap || typeof options?.onClick === "function";
|
|
1134
1207
|
const hasPopup = !!props.popup || typeof options?.popup === "function";
|
|
1135
1208
|
const looks = optionsKey(options) + optionsKey(popupOptions) + (slot ?? "") + "|" + (format ?? "") + "|" + (lat ?? "") + "|" + (lng ?? "");
|
|
1136
|
-
(0,
|
|
1209
|
+
(0, import_react7.useEffect)(() => {
|
|
1137
1210
|
if (!map) {
|
|
1138
1211
|
return void 0;
|
|
1139
1212
|
}
|
|
@@ -1176,7 +1249,7 @@ function Data(props) {
|
|
|
1176
1249
|
ids.forEach((l) => quietly(() => map.removeLayer(l)));
|
|
1177
1250
|
};
|
|
1178
1251
|
}, [map, id, data, looks, hasTap, hasPopup]);
|
|
1179
|
-
(0,
|
|
1252
|
+
(0, import_react7.useEffect)(() => {
|
|
1180
1253
|
if (!map || shownVisible.current === visible) {
|
|
1181
1254
|
return;
|
|
1182
1255
|
}
|
|
@@ -1188,10 +1261,10 @@ function Data(props) {
|
|
|
1188
1261
|
}
|
|
1189
1262
|
function Layers(props) {
|
|
1190
1263
|
const map = useSMap();
|
|
1191
|
-
const latest = (0,
|
|
1264
|
+
const latest = (0, import_react7.useRef)(props.json);
|
|
1192
1265
|
latest.current = props.json;
|
|
1193
1266
|
const jsonKey = typeof props.json === "string" ? props.json : optionsKey(props.json);
|
|
1194
|
-
(0,
|
|
1267
|
+
(0, import_react7.useEffect)(() => {
|
|
1195
1268
|
if (!map) {
|
|
1196
1269
|
return void 0;
|
|
1197
1270
|
}
|
|
@@ -1211,10 +1284,10 @@ function Layers(props) {
|
|
|
1211
1284
|
function DeckLayer(props) {
|
|
1212
1285
|
const map = useSMap();
|
|
1213
1286
|
const { layer } = props;
|
|
1214
|
-
const latest = (0,
|
|
1287
|
+
const latest = (0, import_react7.useRef)(layer);
|
|
1215
1288
|
latest.current = layer;
|
|
1216
|
-
const shown = (0,
|
|
1217
|
-
(0,
|
|
1289
|
+
const shown = (0, import_react7.useRef)(null);
|
|
1290
|
+
(0, import_react7.useEffect)(() => {
|
|
1218
1291
|
if (!map) {
|
|
1219
1292
|
return void 0;
|
|
1220
1293
|
}
|
|
@@ -1227,7 +1300,7 @@ function DeckLayer(props) {
|
|
|
1227
1300
|
}
|
|
1228
1301
|
};
|
|
1229
1302
|
}, [map, layer.id]);
|
|
1230
|
-
(0,
|
|
1303
|
+
(0, import_react7.useEffect)(() => {
|
|
1231
1304
|
const s = shown.current;
|
|
1232
1305
|
if (!map || !s || s.map !== map || s.layer === layer) {
|
|
1233
1306
|
return;
|
|
@@ -1241,7 +1314,7 @@ function useRasterUrl(style, options) {
|
|
|
1241
1314
|
const map = useSMap();
|
|
1242
1315
|
const lang = options?.lang;
|
|
1243
1316
|
const retina = options?.retina;
|
|
1244
|
-
return (0,
|
|
1317
|
+
return (0, import_react7.useMemo)(() => {
|
|
1245
1318
|
if (!map) {
|
|
1246
1319
|
return null;
|
|
1247
1320
|
}
|
|
@@ -1277,6 +1350,7 @@ var import_smap2 = require("@superrouteca/smap");
|
|
|
1277
1350
|
DeckLayer,
|
|
1278
1351
|
DrawTool,
|
|
1279
1352
|
Heatmap,
|
|
1353
|
+
Indoor,
|
|
1280
1354
|
Layers,
|
|
1281
1355
|
Lines,
|
|
1282
1356
|
MapImage,
|