@superrouteca/smap-react 1.1.6 → 1.2.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/CHANGELOG.md +19 -0
- package/README.md +22 -1
- package/dist/index.cjs +209 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -3
- package/dist/index.d.ts +48 -3
- package/dist/index.js +198 -35
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0 — 2026-10-28
|
|
4
|
+
|
|
5
|
+
- `<CustomMarkers>`: your own React content at points, rendered into each marker the map lays out (context, state
|
|
6
|
+
and events work as anywhere in the app); dragged with `draggable`, with tooltips and popups. The content keeps its
|
|
7
|
+
state while its point is out of view; the release of a drag is no click on anything inside it.
|
|
8
|
+
- `<Heatmap>`, `<Models>` (glTF 3D models), `<CanvasTiles>` (tiles you paint) and `<DrawTool>` (drawing and editing;
|
|
9
|
+
`onTool` hands over the tool).
|
|
10
|
+
- Every 1.2.0 call of the map works through the ref or `useSMap()`: `setBaseImagery`, `setGoogleBase`, `setTerrain`,
|
|
11
|
+
`syncWith`, `selectArea`, `addControl`, the layer switcher (`<Tool kind="layers">`), and on points, lines and areas
|
|
12
|
+
tooltips, dragging, colour-ring or HTML clusters and labels along lines.
|
|
13
|
+
|
|
14
|
+
## 1.1.7 — 2026-10-28
|
|
15
|
+
|
|
16
|
+
- Plan editor: faster edits through sMap's fast path, with no code change. When your plan editor token answer names a
|
|
17
|
+
fast path, or your map key's configuration on sMap does, every edit goes there and falls back to the Open Platform
|
|
18
|
+
by itself when the fast path asks for it, fails, or does not answer within 2 seconds (5 seconds for a refine). Quota
|
|
19
|
+
and rate-limit refusals stay final. `<PlanEditor>` and `usePlanEditor` take `fastPath` and `fastPathTimeout`, and
|
|
20
|
+
the state says which path answered (`path`).
|
|
21
|
+
|
|
3
22
|
## 1.1.6 — 2026-10-28
|
|
4
23
|
|
|
5
24
|
- Plan editor: `<PlanEditor>` edits a plan of routes on the map with the ready-made panel in 14 languages — drag stops
|
package/README.md
CHANGED
|
@@ -105,6 +105,24 @@ the map's toolbar) that shows or hides each of them, with *Show all* and *Hide a
|
|
|
105
105
|
yourself. The ref's `setToolVisible`, `setToolsVisible` and `tools()` switch and read them in code.
|
|
106
106
|
- The map data credit and the sMap badge are never tools and always stay.
|
|
107
107
|
|
|
108
|
+
## Markers, drawing and more (1.2.0)
|
|
109
|
+
|
|
110
|
+
```jsx
|
|
111
|
+
<SMap center={[-79.38, 43.65]} zoom={12}>
|
|
112
|
+
{/* Your own React content at each point; drag it with the mouse or a finger. */}
|
|
113
|
+
<CustomMarkers id="vans" data={vans} idProperty="id" anchor="bottom" draggable
|
|
114
|
+
render={(p) => <VanBadge name={p.name} />} onDragEnd={(f, e) => save(f.properties.id, e.lngLat)} />
|
|
115
|
+
<Points id="stops" data={stops} options={{ cluster: { ring: 'color' }, tooltip: '{name}' }} />
|
|
116
|
+
<Lines id="route" data={route} options={{ label: 'name' }} />
|
|
117
|
+
<Heatmap id="density" data={stops} options={{ radius: 18 }} />
|
|
118
|
+
<DrawTool toolbar="top-left" onChange={(e) => setShapes(e.features)} />
|
|
119
|
+
<Tool id="layers" kind="layers" options={{ base: [{ id: 'streets', label: 'Streets' }, { id: 'satellite', label: 'Satellite', imagery }] }} />
|
|
120
|
+
</SMap>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`<Models>` draws glTF models at points and `<CanvasTiles>` raster tiles you paint. The rest goes through the map
|
|
124
|
+
(the ref or `useSMap()`): `setBaseImagery`, `setGoogleBase`, `setTerrain`, `syncWith`, `selectArea`, `addControl`.
|
|
125
|
+
|
|
108
126
|
## Plan editor
|
|
109
127
|
|
|
110
128
|
`<PlanEditor>` edits a plan of routes on the map with the ready-made panel (see the Web SDK's *Plan editor*): drag
|
|
@@ -129,7 +147,10 @@ const editor = useRef<MapPlanEditor>(null);
|
|
|
129
147
|
- `usePlanEditor(props)` gives the editor and its state (`plan`, `result`, `busy`, `error`, `canUndo`, `canRedo`,
|
|
130
148
|
`choices`, `preview`) for an interface of your own; with `panel={false}` the map shows only the routes.
|
|
131
149
|
- Every option of `map.planEditor` is a prop (`region`, `profile`, `insertLimit`, `objective`, `colors`, `panel`,
|
|
132
|
-
`labels`, …); `onBusy`, `onSnapshot` and `onReady` report the rest.
|
|
150
|
+
`labels`, `fastPath`, `fastPathTimeout`, `fastPathRefineTimeout`, …); `onBusy`, `onSnapshot` and `onReady` report the rest.
|
|
151
|
+
- Fast path (no code change): a token answer with `fast_path.url`, or a map key whose configuration on the map's sMap
|
|
152
|
+
service names one, sends the calls there and falls back to the standard path by itself (see the Web SDK's *Plan
|
|
153
|
+
editor*); the state's `path` says which path answered.
|
|
133
154
|
|
|
134
155
|
## Basemap and custom styles
|
|
135
156
|
|
package/dist/index.cjs
CHANGED
|
@@ -32,10 +32,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
ArcGisLayer: () => ArcGisLayer,
|
|
35
|
+
CanvasTiles: () => CanvasTiles,
|
|
36
|
+
CustomMarkers: () => CustomMarkers,
|
|
35
37
|
Data: () => Data,
|
|
36
38
|
DeckLayer: () => DeckLayer,
|
|
39
|
+
DrawTool: () => DrawTool,
|
|
40
|
+
Heatmap: () => Heatmap,
|
|
37
41
|
Layers: () => Layers,
|
|
38
42
|
Lines: () => Lines,
|
|
43
|
+
Models: () => Models,
|
|
39
44
|
PlanEditor: () => PlanEditor,
|
|
40
45
|
Points: () => Points,
|
|
41
46
|
Polygons: () => Polygons,
|
|
@@ -389,8 +394,157 @@ function Tool(props) {
|
|
|
389
394
|
return box ? (0, import_react_dom.createPortal)(props.children, box) : null;
|
|
390
395
|
}
|
|
391
396
|
|
|
392
|
-
// src/
|
|
397
|
+
// src/features.tsx
|
|
393
398
|
var import_react4 = require("react");
|
|
399
|
+
var import_react_dom2 = require("react-dom");
|
|
400
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
401
|
+
function CustomMarkers(props) {
|
|
402
|
+
const map = useSMap();
|
|
403
|
+
const { id, data, render: _render, ...rest } = props;
|
|
404
|
+
const latest = (0, import_react4.useRef)(props);
|
|
405
|
+
latest.current = props;
|
|
406
|
+
const [entries, setEntries] = (0, import_react4.useState)(/* @__PURE__ */ new Map());
|
|
407
|
+
const held = (0, import_react4.useRef)(/* @__PURE__ */ new Map());
|
|
408
|
+
const shown = (0, import_react4.useRef)(null);
|
|
409
|
+
const looks = optionsKey(rest);
|
|
410
|
+
const keyOf = (properties, feature) => {
|
|
411
|
+
const by = latest.current.idProperty;
|
|
412
|
+
const v = by ? properties[by] : feature.id;
|
|
413
|
+
return v === void 0 || v === null ? `@${JSON.stringify(feature.geometry)}` : String(v);
|
|
414
|
+
};
|
|
415
|
+
(0, import_react4.useEffect)(() => {
|
|
416
|
+
if (!map) {
|
|
417
|
+
return void 0;
|
|
418
|
+
}
|
|
419
|
+
held.current = /* @__PURE__ */ new Map();
|
|
420
|
+
let scheduled = false;
|
|
421
|
+
const publish = () => {
|
|
422
|
+
if (scheduled) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
scheduled = true;
|
|
426
|
+
queueMicrotask(() => {
|
|
427
|
+
scheduled = false;
|
|
428
|
+
setEntries(new Map(held.current));
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
const options = {
|
|
432
|
+
...latest.current,
|
|
433
|
+
render: (properties, feature) => {
|
|
434
|
+
const el = document.createElement("div");
|
|
435
|
+
held.current.set(keyOf(properties, feature), { el, properties, feature });
|
|
436
|
+
publish();
|
|
437
|
+
return el;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
delete options.id;
|
|
441
|
+
delete options.data;
|
|
442
|
+
map.addCustomMarkers(id, latest.current.data, options);
|
|
443
|
+
shown.current = latest.current.data;
|
|
444
|
+
return () => {
|
|
445
|
+
shown.current = null;
|
|
446
|
+
held.current = /* @__PURE__ */ new Map();
|
|
447
|
+
setEntries(/* @__PURE__ */ new Map());
|
|
448
|
+
if (!removedMaps.has(map)) {
|
|
449
|
+
map.removeLayer(id);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}, [map, id, looks]);
|
|
453
|
+
(0, import_react4.useEffect)(() => {
|
|
454
|
+
if (!map || shown.current === null || shown.current === data) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
shown.current = data;
|
|
458
|
+
map.setData(id, data);
|
|
459
|
+
const keep = /* @__PURE__ */ new Set();
|
|
460
|
+
const features = data && !Array.isArray(data) && data.features || [];
|
|
461
|
+
for (const f of features) {
|
|
462
|
+
keep.add(keyOf(f.properties || {}, f));
|
|
463
|
+
}
|
|
464
|
+
const by = latest.current.idProperty;
|
|
465
|
+
if (Array.isArray(data) && by) {
|
|
466
|
+
data.forEach((p) => keep.add(String(p[by])));
|
|
467
|
+
}
|
|
468
|
+
if (!Array.isArray(data) || by) {
|
|
469
|
+
let changed = false;
|
|
470
|
+
for (const k of [...held.current.keys()]) {
|
|
471
|
+
if (!keep.has(k)) {
|
|
472
|
+
held.current.delete(k);
|
|
473
|
+
changed = true;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (changed) {
|
|
477
|
+
setEntries(new Map(held.current));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}, [map, id, data]);
|
|
481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: [...entries.entries()].map(([k, e]) => (0, import_react_dom2.createPortal)(latest.current.render(e.properties, e.feature), e.el, `${id}\0${k}`)) });
|
|
482
|
+
}
|
|
483
|
+
function useNativeLayer(add, id, looks, data) {
|
|
484
|
+
const map = useSMap();
|
|
485
|
+
const shown = (0, import_react4.useRef)(null);
|
|
486
|
+
const addRef = (0, import_react4.useRef)(add);
|
|
487
|
+
addRef.current = add;
|
|
488
|
+
(0, import_react4.useEffect)(() => {
|
|
489
|
+
if (!map) {
|
|
490
|
+
return void 0;
|
|
491
|
+
}
|
|
492
|
+
addRef.current(map);
|
|
493
|
+
shown.current = data;
|
|
494
|
+
return () => {
|
|
495
|
+
shown.current = null;
|
|
496
|
+
if (!removedMaps.has(map)) {
|
|
497
|
+
map.removeLayer(id);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}, [map, id, looks]);
|
|
501
|
+
(0, import_react4.useEffect)(() => {
|
|
502
|
+
if (!map || data === void 0 || shown.current === null || shown.current === data) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
shown.current = data;
|
|
506
|
+
map.setData(id, data);
|
|
507
|
+
}, [map, id, data]);
|
|
508
|
+
}
|
|
509
|
+
function Heatmap(props) {
|
|
510
|
+
useNativeLayer((m) => m.addHeatmap(props.id, props.data, props.options), props.id, optionsKey(props.options), props.data);
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
function Models(props) {
|
|
514
|
+
useNativeLayer((m) => m.addModels(props.id, props.data, props.options), props.id, optionsKey(props.options), props.data);
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
function CanvasTiles(props) {
|
|
518
|
+
const draw = (0, import_react4.useRef)(props.draw);
|
|
519
|
+
draw.current = props.draw;
|
|
520
|
+
useNativeLayer((m) => m.addCanvasTiles(props.id, (...a) => draw.current(...a), props.options), props.id, optionsKey(props.options));
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
function DrawTool(props) {
|
|
524
|
+
const map = useSMap();
|
|
525
|
+
const latest = (0, import_react4.useRef)(props);
|
|
526
|
+
latest.current = props;
|
|
527
|
+
const { onChange: _c, onTool: _t, ...rest } = props;
|
|
528
|
+
const looks = optionsKey(rest);
|
|
529
|
+
(0, import_react4.useEffect)(() => {
|
|
530
|
+
if (!map) {
|
|
531
|
+
return void 0;
|
|
532
|
+
}
|
|
533
|
+
const { onChange: _a, onTool: _b, ...o } = latest.current;
|
|
534
|
+
const tool = map.drawTool({ ...o, onChange: (e) => latest.current.onChange?.(e) });
|
|
535
|
+
latest.current.onTool?.(tool);
|
|
536
|
+
return () => {
|
|
537
|
+
latest.current.onTool?.(null);
|
|
538
|
+
if (!removedMaps.has(map)) {
|
|
539
|
+
tool.destroy();
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}, [map, looks]);
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/plan.tsx
|
|
547
|
+
var import_react5 = require("react");
|
|
394
548
|
function destroyOffMap(made) {
|
|
395
549
|
made.layer.remove = () => {
|
|
396
550
|
};
|
|
@@ -418,15 +572,16 @@ var EMPTY = {
|
|
|
418
572
|
choices: null,
|
|
419
573
|
locked: [],
|
|
420
574
|
last: null,
|
|
421
|
-
preview: null
|
|
575
|
+
preview: null,
|
|
576
|
+
path: null
|
|
422
577
|
};
|
|
423
578
|
function usePlanEditor(props) {
|
|
424
579
|
const map = useSMap();
|
|
425
|
-
const [editor, setEditor] = (0,
|
|
426
|
-
const [state, setState] = (0,
|
|
427
|
-
const latest = (0,
|
|
580
|
+
const [editor, setEditor] = (0, import_react5.useState)(null);
|
|
581
|
+
const [state, setState] = (0, import_react5.useState)(EMPTY);
|
|
582
|
+
const latest = (0, import_react5.useRef)(props);
|
|
428
583
|
latest.current = props;
|
|
429
|
-
const applied = (0,
|
|
584
|
+
const applied = (0, import_react5.useRef)(null);
|
|
430
585
|
const credentialKey = "key" in props.credentials ? "key:" + props.credentials.key : "token";
|
|
431
586
|
const madeKey = key2({
|
|
432
587
|
baseUrl: props.baseUrl,
|
|
@@ -441,9 +596,13 @@ function usePlanEditor(props) {
|
|
|
441
596
|
colors: props.colors,
|
|
442
597
|
preview: props.preview,
|
|
443
598
|
panel: props.panel,
|
|
444
|
-
labels: props.labels
|
|
599
|
+
labels: props.labels,
|
|
600
|
+
smapUrl: props.smapUrl,
|
|
601
|
+
fastPath: props.fastPath,
|
|
602
|
+
fastPathTimeout: props.fastPathTimeout,
|
|
603
|
+
fastPathRefineTimeout: props.fastPathRefineTimeout
|
|
445
604
|
});
|
|
446
|
-
(0,
|
|
605
|
+
(0, import_react5.useEffect)(() => {
|
|
447
606
|
if (!map) {
|
|
448
607
|
return void 0;
|
|
449
608
|
}
|
|
@@ -465,7 +624,11 @@ function usePlanEditor(props) {
|
|
|
465
624
|
preview: p.preview,
|
|
466
625
|
language: p.language,
|
|
467
626
|
labels: p.labels,
|
|
468
|
-
panel: p.panel
|
|
627
|
+
panel: p.panel,
|
|
628
|
+
smapUrl: p.smapUrl,
|
|
629
|
+
fastPath: p.fastPath,
|
|
630
|
+
fastPathTimeout: p.fastPathTimeout,
|
|
631
|
+
fastPathRefineTimeout: p.fastPathRefineTimeout
|
|
469
632
|
};
|
|
470
633
|
for (const k of Object.keys(options)) {
|
|
471
634
|
if (options[k] === void 0) {
|
|
@@ -502,7 +665,7 @@ function usePlanEditor(props) {
|
|
|
502
665
|
};
|
|
503
666
|
}, [map, credentialKey, madeKey]);
|
|
504
667
|
const incoming = planKey(props.plan);
|
|
505
|
-
(0,
|
|
668
|
+
(0, import_react5.useEffect)(() => {
|
|
506
669
|
if (!editor || !latest.current.plan) {
|
|
507
670
|
return;
|
|
508
671
|
}
|
|
@@ -514,39 +677,39 @@ function usePlanEditor(props) {
|
|
|
514
677
|
editor.setPlan(latest.current.plan).catch(() => {
|
|
515
678
|
});
|
|
516
679
|
}, [editor, incoming]);
|
|
517
|
-
(0,
|
|
680
|
+
(0, import_react5.useEffect)(() => {
|
|
518
681
|
if (editor && editor.panel && props.language) {
|
|
519
682
|
editor.panel.setLanguage(props.language);
|
|
520
683
|
}
|
|
521
684
|
}, [editor, props.language]);
|
|
522
685
|
return { ...state, editor };
|
|
523
686
|
}
|
|
524
|
-
var PlanEditor = (0,
|
|
687
|
+
var PlanEditor = (0, import_react5.forwardRef)(function PlanEditor2(props, ref) {
|
|
525
688
|
const { editor } = usePlanEditor(props);
|
|
526
|
-
(0,
|
|
689
|
+
(0, import_react5.useImperativeHandle)(ref, () => editor, [editor]);
|
|
527
690
|
return null;
|
|
528
691
|
});
|
|
529
692
|
|
|
530
693
|
// src/interop.tsx
|
|
531
|
-
var
|
|
694
|
+
var import_react6 = require("react");
|
|
532
695
|
var sdk = __toESM(require("@superrouteca/smap"), 1);
|
|
533
|
-
var
|
|
696
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
534
697
|
function quietly(f) {
|
|
535
698
|
try {
|
|
536
699
|
f();
|
|
537
700
|
} catch {
|
|
538
701
|
}
|
|
539
702
|
}
|
|
540
|
-
var SourceContext = (0,
|
|
703
|
+
var SourceContext = (0, import_react6.createContext)(null);
|
|
541
704
|
function Source(props) {
|
|
542
705
|
const map = useSMap();
|
|
543
706
|
const { id, source, children } = props;
|
|
544
|
-
const latest = (0,
|
|
707
|
+
const latest = (0, import_react6.useRef)(source);
|
|
545
708
|
latest.current = source;
|
|
546
|
-
const inside = (0,
|
|
547
|
-
const [shown, setShown] = (0,
|
|
709
|
+
const inside = (0, import_react6.useRef)(/* @__PURE__ */ new Set());
|
|
710
|
+
const [shown, setShown] = (0, import_react6.useState)(null);
|
|
548
711
|
const sourceKey = optionsKey(source);
|
|
549
|
-
(0,
|
|
712
|
+
(0, import_react6.useEffect)(() => {
|
|
550
713
|
if (!map) {
|
|
551
714
|
return void 0;
|
|
552
715
|
}
|
|
@@ -561,7 +724,7 @@ function Source(props) {
|
|
|
561
724
|
quietly(() => map.removeSource(id));
|
|
562
725
|
};
|
|
563
726
|
}, [map, id, sourceKey]);
|
|
564
|
-
const scope = (0,
|
|
727
|
+
const scope = (0, import_react6.useMemo)(() => ({
|
|
565
728
|
id,
|
|
566
729
|
register: (layerId) => {
|
|
567
730
|
inside.current.add(layerId);
|
|
@@ -571,7 +734,7 @@ function Source(props) {
|
|
|
571
734
|
if (!map || !shown || shown.map !== map) {
|
|
572
735
|
return null;
|
|
573
736
|
}
|
|
574
|
-
return /* @__PURE__ */ (0,
|
|
737
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SourceContext.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.Fragment, { children }, shown.generation) });
|
|
575
738
|
}
|
|
576
739
|
function effectiveLayer(layer, sourceId, visible) {
|
|
577
740
|
const out = { ...layer };
|
|
@@ -598,14 +761,14 @@ function applyDiff(prev, next, set) {
|
|
|
598
761
|
}
|
|
599
762
|
function StyleLayer(props) {
|
|
600
763
|
const map = useSMap();
|
|
601
|
-
const scope = (0,
|
|
764
|
+
const scope = (0, import_react6.useContext)(SourceContext);
|
|
602
765
|
const { layer, before, slot, visible = true } = props;
|
|
603
766
|
const current = effectiveLayer(layer, scope?.id, visible);
|
|
604
|
-
const latest = (0,
|
|
767
|
+
const latest = (0, import_react6.useRef)(current);
|
|
605
768
|
latest.current = current;
|
|
606
|
-
const shown = (0,
|
|
769
|
+
const shown = (0, import_react6.useRef)(null);
|
|
607
770
|
const structure = structureKey(current, before, slot);
|
|
608
|
-
(0,
|
|
771
|
+
(0, import_react6.useEffect)(() => {
|
|
609
772
|
if (!map) {
|
|
610
773
|
return void 0;
|
|
611
774
|
}
|
|
@@ -629,7 +792,7 @@ function StyleLayer(props) {
|
|
|
629
792
|
};
|
|
630
793
|
}, [map, structure, scope]);
|
|
631
794
|
const looks = optionsKey(current.paint) + optionsKey(current.layout) + optionsKey(current.filter);
|
|
632
|
-
(0,
|
|
795
|
+
(0, import_react6.useEffect)(() => {
|
|
633
796
|
const s = shown.current;
|
|
634
797
|
if (!map || !s || s.map !== map) {
|
|
635
798
|
return;
|
|
@@ -650,12 +813,12 @@ function StyleLayer(props) {
|
|
|
650
813
|
}
|
|
651
814
|
function useAddedLayer(method, id, options, remove) {
|
|
652
815
|
const map = useSMap();
|
|
653
|
-
const latest = (0,
|
|
816
|
+
const latest = (0, import_react6.useRef)(options);
|
|
654
817
|
latest.current = options;
|
|
655
|
-
const removeLatest = (0,
|
|
818
|
+
const removeLatest = (0, import_react6.useRef)(remove);
|
|
656
819
|
removeLatest.current = remove;
|
|
657
820
|
const looks = optionsKey(options);
|
|
658
|
-
(0,
|
|
821
|
+
(0, import_react6.useEffect)(() => {
|
|
659
822
|
if (!map) {
|
|
660
823
|
return void 0;
|
|
661
824
|
}
|
|
@@ -702,13 +865,13 @@ var dataLayerIds = (id) => [id, `${id}:lines`, `${id}:areas`];
|
|
|
702
865
|
function Data(props) {
|
|
703
866
|
const map = useSMap();
|
|
704
867
|
const { id, data, format, lat, lng, options, slot, onTap, visible = true, popupOptions } = props;
|
|
705
|
-
const latest = (0,
|
|
868
|
+
const latest = (0, import_react6.useRef)(props);
|
|
706
869
|
latest.current = props;
|
|
707
|
-
const shownVisible = (0,
|
|
870
|
+
const shownVisible = (0, import_react6.useRef)(true);
|
|
708
871
|
const hasTap = !!onTap || typeof options?.onClick === "function";
|
|
709
872
|
const hasPopup = !!props.popup || typeof options?.popup === "function";
|
|
710
873
|
const looks = optionsKey(options) + optionsKey(popupOptions) + (slot ?? "") + "|" + (format ?? "") + "|" + (lat ?? "") + "|" + (lng ?? "");
|
|
711
|
-
(0,
|
|
874
|
+
(0, import_react6.useEffect)(() => {
|
|
712
875
|
if (!map) {
|
|
713
876
|
return void 0;
|
|
714
877
|
}
|
|
@@ -751,7 +914,7 @@ function Data(props) {
|
|
|
751
914
|
ids.forEach((l) => quietly(() => map.removeLayer(l)));
|
|
752
915
|
};
|
|
753
916
|
}, [map, id, data, looks, hasTap, hasPopup]);
|
|
754
|
-
(0,
|
|
917
|
+
(0, import_react6.useEffect)(() => {
|
|
755
918
|
if (!map || shownVisible.current === visible) {
|
|
756
919
|
return;
|
|
757
920
|
}
|
|
@@ -763,10 +926,10 @@ function Data(props) {
|
|
|
763
926
|
}
|
|
764
927
|
function Layers(props) {
|
|
765
928
|
const map = useSMap();
|
|
766
|
-
const latest = (0,
|
|
929
|
+
const latest = (0, import_react6.useRef)(props.json);
|
|
767
930
|
latest.current = props.json;
|
|
768
931
|
const jsonKey = typeof props.json === "string" ? props.json : optionsKey(props.json);
|
|
769
|
-
(0,
|
|
932
|
+
(0, import_react6.useEffect)(() => {
|
|
770
933
|
if (!map) {
|
|
771
934
|
return void 0;
|
|
772
935
|
}
|
|
@@ -786,10 +949,10 @@ function Layers(props) {
|
|
|
786
949
|
function DeckLayer(props) {
|
|
787
950
|
const map = useSMap();
|
|
788
951
|
const { layer } = props;
|
|
789
|
-
const latest = (0,
|
|
952
|
+
const latest = (0, import_react6.useRef)(layer);
|
|
790
953
|
latest.current = layer;
|
|
791
|
-
const shown = (0,
|
|
792
|
-
(0,
|
|
954
|
+
const shown = (0, import_react6.useRef)(null);
|
|
955
|
+
(0, import_react6.useEffect)(() => {
|
|
793
956
|
if (!map) {
|
|
794
957
|
return void 0;
|
|
795
958
|
}
|
|
@@ -802,7 +965,7 @@ function DeckLayer(props) {
|
|
|
802
965
|
}
|
|
803
966
|
};
|
|
804
967
|
}, [map, layer.id]);
|
|
805
|
-
(0,
|
|
968
|
+
(0, import_react6.useEffect)(() => {
|
|
806
969
|
const s = shown.current;
|
|
807
970
|
if (!map || !s || s.map !== map || s.layer === layer) {
|
|
808
971
|
return;
|
|
@@ -816,7 +979,7 @@ function useRasterUrl(style, options) {
|
|
|
816
979
|
const map = useSMap();
|
|
817
980
|
const lang = options?.lang;
|
|
818
981
|
const retina = options?.retina;
|
|
819
|
-
return (0,
|
|
982
|
+
return (0, import_react6.useMemo)(() => {
|
|
820
983
|
if (!map) {
|
|
821
984
|
return null;
|
|
822
985
|
}
|
|
@@ -845,10 +1008,15 @@ var import_smap2 = require("@superrouteca/smap");
|
|
|
845
1008
|
// Annotate the CommonJS export names for ESM import in node:
|
|
846
1009
|
0 && (module.exports = {
|
|
847
1010
|
ArcGisLayer,
|
|
1011
|
+
CanvasTiles,
|
|
1012
|
+
CustomMarkers,
|
|
848
1013
|
Data,
|
|
849
1014
|
DeckLayer,
|
|
1015
|
+
DrawTool,
|
|
1016
|
+
Heatmap,
|
|
850
1017
|
Layers,
|
|
851
1018
|
Lines,
|
|
1019
|
+
Models,
|
|
852
1020
|
PlanEditor,
|
|
853
1021
|
Points,
|
|
854
1022
|
Polygons,
|