@superrouteca/smap-react 1.1.5 → 1.1.7
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 +36 -4
- package/dist/index.cjs +200 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.js +190 -29
- 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.1.7 — 2026-10-28
|
|
4
|
+
|
|
5
|
+
- Plan editor: faster edits through sMap's fast path, with no code change. When your plan editor token answer names a
|
|
6
|
+
fast path, or your map key's configuration on sMap does, every edit goes there and falls back to the Open Platform
|
|
7
|
+
by itself when the fast path asks for it, fails, or does not answer within 2 seconds (5 seconds for a refine). Quota
|
|
8
|
+
and rate-limit refusals stay final. `<PlanEditor>` and `usePlanEditor` take `fastPath` and `fastPathTimeout`, and
|
|
9
|
+
the state says which path answered (`path`).
|
|
10
|
+
|
|
11
|
+
## 1.1.6 — 2026-10-28
|
|
12
|
+
|
|
13
|
+
- Plan editor: `<PlanEditor>` edits a plan of routes on the map with the ready-made panel in 14 languages — drag stops
|
|
14
|
+
within and between routes, remove, insert, refine, undo and redo — and reports every new plan to `onChange`.
|
|
15
|
+
`usePlanEditor` gives the editor and its state for an interface of your own.
|
|
16
|
+
- Map tools: `<Tool layer="stops">` (or `layer={['stops', 'stop-labels']}`) makes a data layer a tool, shown and
|
|
17
|
+
hidden by the tools control like every other tool.
|
|
18
|
+
- Map tools: the tools control is the last button of the map's toolbar by default (the corner of the zoom buttons,
|
|
19
|
+
top left without one); `tools={{ control: 'top-right' }}` keeps a corner as before. Its corner is drawn above the
|
|
20
|
+
others while the panel is open.
|
|
21
|
+
|
|
3
22
|
## 1.1.5 — 2026-10-28
|
|
4
23
|
|
|
5
24
|
- Map tools: `<Tool>` puts a control or panel on the map that the map's tools control shows and hides, one by one or
|
package/README.md
CHANGED
|
@@ -82,8 +82,8 @@ replaces the data and keeps the look, new `options` draw the layer again. Higher
|
|
|
82
82
|
|
|
83
83
|
## Map tools
|
|
84
84
|
|
|
85
|
-
Put controls and
|
|
86
|
-
hides each of them, with *Show all* and *Hide all*:
|
|
85
|
+
Put controls, panels and data layers on the map as `<Tool>`s; the map gets a tools control (one button, the last of
|
|
86
|
+
the map's toolbar) that shows or hides each of them, with *Show all* and *Hide all*:
|
|
87
87
|
|
|
88
88
|
```jsx
|
|
89
89
|
<SMap apiKey="smk_…" tools={{ hidden: saved }} onToolsChange={(e) => save(e.hidden)}>
|
|
@@ -91,17 +91,49 @@ hides each of them, with *Show all* and *Hide all*:
|
|
|
91
91
|
<Tool id="fullscreen" kind="fullscreen" />
|
|
92
92
|
<Tool id="legend" label="Legend" position="bottom-left"><Legend /></Tool>
|
|
93
93
|
<Tool id="orders" label="Orders list" position="none"><OrdersList /></Tool>
|
|
94
|
+
<Tool id="stops" label="Stops" layer={['stops', 'stop-labels']} />
|
|
94
95
|
</SMap>
|
|
95
96
|
```
|
|
96
97
|
|
|
97
98
|
- `kind` makes a control: `navigation`, `geolocate`, `fullscreen` or `scale`. Otherwise the children are the tool,
|
|
98
99
|
drawn in a corner (`position`, default `top-left`) or where `<Tool>` is (`position="none"`).
|
|
100
|
+
- `layer` makes a data-layer tool: one or more layer ids (`<Points>`, `<Lines>`, `<Polygons>`, the map's layer calls,
|
|
101
|
+
or the basemap's). Hiding the tool hides them, showing it shows them; it renders nothing.
|
|
99
102
|
- A hidden tool stays mounted: its state is kept and it comes back as it was.
|
|
100
|
-
- `tools` is read when the map is created: `hidden` (ids hidden from the start), `control` (
|
|
101
|
-
none) and `labels` (`button`, `showAll`, `hideAll`). The map keeps no state: keep `onToolsChange`'s `hidden`
|
|
103
|
+
- `tools` is read when the map is created: `hidden` (ids hidden from the start), `control` (`'toolbar'` by default: the last
|
|
104
|
+
button of the corner holding the zoom buttons, top left without one; a corner; or `false` for none) and `labels` (`button`, `showAll`, `hideAll`). The map keeps no state: keep `onToolsChange`'s `hidden`
|
|
102
105
|
yourself. The ref's `setToolVisible`, `setToolsVisible` and `tools()` switch and read them in code.
|
|
103
106
|
- The map data credit and the sMap badge are never tools and always stay.
|
|
104
107
|
|
|
108
|
+
## Plan editor
|
|
109
|
+
|
|
110
|
+
`<PlanEditor>` edits a plan of routes on the map with the ready-made panel (see the Web SDK's *Plan editor*): drag
|
|
111
|
+
stops within and between routes, remove, insert, refine, undo and redo, each a call of the Open Platform's plan
|
|
112
|
+
editing. The ref is the editor once the map is ready.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
const [plan, setPlan] = useState<Plan>(initialPlan);
|
|
116
|
+
const editor = useRef<MapPlanEditor>(null);
|
|
117
|
+
|
|
118
|
+
<SMap apiKey="smk_…">
|
|
119
|
+
<PlanEditor ref={editor} credentials={{ token: getPlanToken }} plan={plan} language="de"
|
|
120
|
+
onChange={(e) => { if (!e.pending) { setPlan(e.plan!); } }} onError={(err) => report(err.code)} />
|
|
121
|
+
</SMap>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- `credentials`: `{ token: () => Promise<string | PlanTokenAnswer> }` (the latest function is called; your own
|
|
125
|
+
server mints the token with `POST /v1/plan/token` and may hand its answer on as it is) or `{ key: 'smk_…' }` (a map
|
|
126
|
+
key with plan editing switched on). Both are sent as `Authorization: Bearer …`.
|
|
127
|
+
- `plan`: a plan that differs from the one the editor holds replaces it; handing back the plan of `onChange` is not a
|
|
128
|
+
change.
|
|
129
|
+
- `usePlanEditor(props)` gives the editor and its state (`plan`, `result`, `busy`, `error`, `canUndo`, `canRedo`,
|
|
130
|
+
`choices`, `preview`) for an interface of your own; with `panel={false}` the map shows only the routes.
|
|
131
|
+
- Every option of `map.planEditor` is a prop (`region`, `profile`, `insertLimit`, `objective`, `colors`, `panel`,
|
|
132
|
+
`labels`, `fastPath`, `fastPathTimeout`, `fastPathRefineTimeout`, …); `onBusy`, `onSnapshot` and `onReady` report the rest.
|
|
133
|
+
- Fast path (no code change): a token answer with `fast_path.url`, or a map key whose configuration on the map's sMap
|
|
134
|
+
service names one, sends the calls there and falls back to the standard path by itself (see the Web SDK's *Plan
|
|
135
|
+
editor*); the state's `path` says which path answered.
|
|
136
|
+
|
|
105
137
|
## Basemap and custom styles
|
|
106
138
|
|
|
107
139
|
`basemap` shows, hides and recolours the basemap by class — `water`, `land`, `parks`, `roads` (and `roads.highway`,
|
package/dist/index.cjs
CHANGED
|
@@ -12,9 +12,9 @@ var __export = (target, all) => {
|
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
14
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let
|
|
16
|
-
if (!__hasOwnProp.call(to,
|
|
17
|
-
__defProp(to,
|
|
15
|
+
for (let key3 of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key3) && key3 !== except)
|
|
17
|
+
__defProp(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc(from, key3)) || desc.enumerable });
|
|
18
18
|
}
|
|
19
19
|
return to;
|
|
20
20
|
};
|
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
DeckLayer: () => DeckLayer,
|
|
37
37
|
Layers: () => Layers,
|
|
38
38
|
Lines: () => Lines,
|
|
39
|
+
PlanEditor: () => PlanEditor,
|
|
39
40
|
Points: () => Points,
|
|
40
41
|
Polygons: () => Polygons,
|
|
41
42
|
RasterLayer: () => RasterLayer,
|
|
@@ -47,7 +48,9 @@ __export(index_exports, {
|
|
|
47
48
|
WmsLayer: () => WmsLayer,
|
|
48
49
|
WmtsLayer: () => WmtsLayer,
|
|
49
50
|
formats: () => formats2,
|
|
51
|
+
planTexts: () => import_smap2.planTexts,
|
|
50
52
|
popupTemplate: () => import_smap2.popupTemplate,
|
|
53
|
+
usePlanEditor: () => usePlanEditor,
|
|
51
54
|
useRasterUrl: () => useRasterUrl,
|
|
52
55
|
useSMap: () => useSMap
|
|
53
56
|
});
|
|
@@ -334,14 +337,17 @@ var optionsKey2 = (v) => JSON.stringify(v ?? null);
|
|
|
334
337
|
function Tool(props) {
|
|
335
338
|
const map = useSMap();
|
|
336
339
|
const { id, label, kind } = props;
|
|
337
|
-
const
|
|
338
|
-
const
|
|
340
|
+
const layer = props.layer;
|
|
341
|
+
const layerKey = layer === void 0 ? null : JSON.stringify(layer);
|
|
342
|
+
const isLayer = layerKey !== null;
|
|
343
|
+
const position = isLayer ? void 0 : props.position ?? (kind ? void 0 : "top-left");
|
|
344
|
+
const inPlace = !kind && !isLayer && position === "none";
|
|
339
345
|
const [box, setBox] = (0, import_react3.useState)(null);
|
|
340
346
|
(0, import_react3.useEffect)(() => {
|
|
341
|
-
if (!kind && !inPlace && !box) {
|
|
347
|
+
if (!kind && !isLayer && !inPlace && !box) {
|
|
342
348
|
setBox(document.createElement("div"));
|
|
343
349
|
}
|
|
344
|
-
}, [kind, inPlace, box]);
|
|
350
|
+
}, [kind, isLayer, inPlace, box]);
|
|
345
351
|
const inPlaceRef = (0, import_react3.useRef)(null);
|
|
346
352
|
const kindOptions = optionsKey2(props.options);
|
|
347
353
|
const latestOptions = (0, import_react3.useRef)(props.options);
|
|
@@ -355,6 +361,14 @@ function Tool(props) {
|
|
|
355
361
|
if (!map) {
|
|
356
362
|
return void 0;
|
|
357
363
|
}
|
|
364
|
+
if (layerKey !== null) {
|
|
365
|
+
map.addTool(id, { layer: JSON.parse(layerKey) }, { label });
|
|
366
|
+
return () => {
|
|
367
|
+
if (!removedMaps.has(map)) {
|
|
368
|
+
map.removeTool(id);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
358
372
|
const target = kind ?? (inPlace ? inPlaceRef.current : box);
|
|
359
373
|
if (!target) {
|
|
360
374
|
return void 0;
|
|
@@ -365,8 +379,8 @@ function Tool(props) {
|
|
|
365
379
|
map.removeTool(id);
|
|
366
380
|
}
|
|
367
381
|
};
|
|
368
|
-
}, [map, id, label, position, kind, inPlace, kindOptions, box]);
|
|
369
|
-
if (kind) {
|
|
382
|
+
}, [map, id, label, position, kind, inPlace, kindOptions, box, layerKey]);
|
|
383
|
+
if (kind || isLayer) {
|
|
370
384
|
return null;
|
|
371
385
|
}
|
|
372
386
|
if (inPlace) {
|
|
@@ -375,8 +389,155 @@ function Tool(props) {
|
|
|
375
389
|
return box ? (0, import_react_dom.createPortal)(props.children, box) : null;
|
|
376
390
|
}
|
|
377
391
|
|
|
378
|
-
// src/
|
|
392
|
+
// src/plan.tsx
|
|
379
393
|
var import_react4 = require("react");
|
|
394
|
+
function destroyOffMap(made) {
|
|
395
|
+
made.layer.remove = () => {
|
|
396
|
+
};
|
|
397
|
+
try {
|
|
398
|
+
made.destroy();
|
|
399
|
+
} catch {
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
var key2 = (v) => JSON.stringify(v ?? null);
|
|
403
|
+
function planKey(plan) {
|
|
404
|
+
if (!plan) {
|
|
405
|
+
return key2(null);
|
|
406
|
+
}
|
|
407
|
+
const routes = (plan.routes || []).map((r) => ({ v: String(r.vehicle_id), s: (r.reverse ? r.stops.slice().reverse() : r.stops).map(String) })).filter((r) => r.s.length).sort((a, b) => a.v < b.v ? -1 : a.v > b.v ? 1 : 0);
|
|
408
|
+
const jobs = (plan.jobs || []).map((j) => j.id).sort();
|
|
409
|
+
return key2({ vehicles: plan.vehicles, jobs, routes, region: plan.region ?? null, profile: plan.profile ?? null, departed_at: plan.departed_at ?? null });
|
|
410
|
+
}
|
|
411
|
+
var EMPTY = {
|
|
412
|
+
plan: null,
|
|
413
|
+
result: null,
|
|
414
|
+
busy: false,
|
|
415
|
+
error: null,
|
|
416
|
+
canUndo: false,
|
|
417
|
+
canRedo: false,
|
|
418
|
+
choices: null,
|
|
419
|
+
locked: [],
|
|
420
|
+
last: null,
|
|
421
|
+
preview: null,
|
|
422
|
+
path: null
|
|
423
|
+
};
|
|
424
|
+
function usePlanEditor(props) {
|
|
425
|
+
const map = useSMap();
|
|
426
|
+
const [editor, setEditor] = (0, import_react4.useState)(null);
|
|
427
|
+
const [state, setState] = (0, import_react4.useState)(EMPTY);
|
|
428
|
+
const latest = (0, import_react4.useRef)(props);
|
|
429
|
+
latest.current = props;
|
|
430
|
+
const applied = (0, import_react4.useRef)(null);
|
|
431
|
+
const credentialKey = "key" in props.credentials ? "key:" + props.credentials.key : "token";
|
|
432
|
+
const madeKey = key2({
|
|
433
|
+
baseUrl: props.baseUrl,
|
|
434
|
+
app: props.app,
|
|
435
|
+
region: props.region,
|
|
436
|
+
profile: props.profile,
|
|
437
|
+
snapshot: props.snapshot,
|
|
438
|
+
geometry: props.geometry,
|
|
439
|
+
insertLimit: props.insertLimit,
|
|
440
|
+
objective: props.objective,
|
|
441
|
+
id: props.id,
|
|
442
|
+
colors: props.colors,
|
|
443
|
+
preview: props.preview,
|
|
444
|
+
panel: props.panel,
|
|
445
|
+
labels: props.labels,
|
|
446
|
+
smapUrl: props.smapUrl,
|
|
447
|
+
fastPath: props.fastPath,
|
|
448
|
+
fastPathTimeout: props.fastPathTimeout,
|
|
449
|
+
fastPathRefineTimeout: props.fastPathRefineTimeout
|
|
450
|
+
});
|
|
451
|
+
(0, import_react4.useEffect)(() => {
|
|
452
|
+
if (!map) {
|
|
453
|
+
return void 0;
|
|
454
|
+
}
|
|
455
|
+
const p = latest.current;
|
|
456
|
+
const credentials = "key" in p.credentials ? { key: p.credentials.key } : { token: () => latest.current.credentials.token() };
|
|
457
|
+
const options = {
|
|
458
|
+
credentials,
|
|
459
|
+
app: p.app,
|
|
460
|
+
baseUrl: p.baseUrl,
|
|
461
|
+
fetch: p.fetch,
|
|
462
|
+
region: p.region,
|
|
463
|
+
profile: p.profile,
|
|
464
|
+
snapshot: p.snapshot,
|
|
465
|
+
geometry: p.geometry,
|
|
466
|
+
insertLimit: p.insertLimit,
|
|
467
|
+
objective: p.objective,
|
|
468
|
+
id: p.id,
|
|
469
|
+
colors: p.colors,
|
|
470
|
+
preview: p.preview,
|
|
471
|
+
language: p.language,
|
|
472
|
+
labels: p.labels,
|
|
473
|
+
panel: p.panel,
|
|
474
|
+
smapUrl: p.smapUrl,
|
|
475
|
+
fastPath: p.fastPath,
|
|
476
|
+
fastPathTimeout: p.fastPathTimeout,
|
|
477
|
+
fastPathRefineTimeout: p.fastPathRefineTimeout
|
|
478
|
+
};
|
|
479
|
+
for (const k of Object.keys(options)) {
|
|
480
|
+
if (options[k] === void 0) {
|
|
481
|
+
delete options[k];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const made = map.planEditor(options);
|
|
485
|
+
const refresh = () => setState(made.state());
|
|
486
|
+
made.on("change", (e) => {
|
|
487
|
+
refresh();
|
|
488
|
+
latest.current.onChange?.(e);
|
|
489
|
+
});
|
|
490
|
+
made.on("busy", (e) => {
|
|
491
|
+
refresh();
|
|
492
|
+
latest.current.onBusy?.(e.busy);
|
|
493
|
+
});
|
|
494
|
+
made.on("error", (e) => {
|
|
495
|
+
refresh();
|
|
496
|
+
latest.current.onError?.(e.error, e.kind);
|
|
497
|
+
});
|
|
498
|
+
made.on("preview", refresh);
|
|
499
|
+
made.on("snapshot", (e) => latest.current.onSnapshot?.(e));
|
|
500
|
+
applied.current = null;
|
|
501
|
+
setEditor(made);
|
|
502
|
+
latest.current.onReady?.(made);
|
|
503
|
+
return () => {
|
|
504
|
+
setEditor(null);
|
|
505
|
+
setState(EMPTY);
|
|
506
|
+
if (!removedMaps.has(map)) {
|
|
507
|
+
made.destroy();
|
|
508
|
+
} else {
|
|
509
|
+
destroyOffMap(made);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
}, [map, credentialKey, madeKey]);
|
|
513
|
+
const incoming = planKey(props.plan);
|
|
514
|
+
(0, import_react4.useEffect)(() => {
|
|
515
|
+
if (!editor || !latest.current.plan) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (incoming === applied.current || incoming === planKey(editor.getPlan())) {
|
|
519
|
+
applied.current = incoming;
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
applied.current = incoming;
|
|
523
|
+
editor.setPlan(latest.current.plan).catch(() => {
|
|
524
|
+
});
|
|
525
|
+
}, [editor, incoming]);
|
|
526
|
+
(0, import_react4.useEffect)(() => {
|
|
527
|
+
if (editor && editor.panel && props.language) {
|
|
528
|
+
editor.panel.setLanguage(props.language);
|
|
529
|
+
}
|
|
530
|
+
}, [editor, props.language]);
|
|
531
|
+
return { ...state, editor };
|
|
532
|
+
}
|
|
533
|
+
var PlanEditor = (0, import_react4.forwardRef)(function PlanEditor2(props, ref) {
|
|
534
|
+
const { editor } = usePlanEditor(props);
|
|
535
|
+
(0, import_react4.useImperativeHandle)(ref, () => editor, [editor]);
|
|
536
|
+
return null;
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
// src/interop.tsx
|
|
540
|
+
var import_react5 = require("react");
|
|
380
541
|
var sdk = __toESM(require("@superrouteca/smap"), 1);
|
|
381
542
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
382
543
|
function quietly(f) {
|
|
@@ -385,16 +546,16 @@ function quietly(f) {
|
|
|
385
546
|
} catch {
|
|
386
547
|
}
|
|
387
548
|
}
|
|
388
|
-
var SourceContext = (0,
|
|
549
|
+
var SourceContext = (0, import_react5.createContext)(null);
|
|
389
550
|
function Source(props) {
|
|
390
551
|
const map = useSMap();
|
|
391
552
|
const { id, source, children } = props;
|
|
392
|
-
const latest = (0,
|
|
553
|
+
const latest = (0, import_react5.useRef)(source);
|
|
393
554
|
latest.current = source;
|
|
394
|
-
const inside = (0,
|
|
395
|
-
const [shown, setShown] = (0,
|
|
555
|
+
const inside = (0, import_react5.useRef)(/* @__PURE__ */ new Set());
|
|
556
|
+
const [shown, setShown] = (0, import_react5.useState)(null);
|
|
396
557
|
const sourceKey = optionsKey(source);
|
|
397
|
-
(0,
|
|
558
|
+
(0, import_react5.useEffect)(() => {
|
|
398
559
|
if (!map) {
|
|
399
560
|
return void 0;
|
|
400
561
|
}
|
|
@@ -409,7 +570,7 @@ function Source(props) {
|
|
|
409
570
|
quietly(() => map.removeSource(id));
|
|
410
571
|
};
|
|
411
572
|
}, [map, id, sourceKey]);
|
|
412
|
-
const scope = (0,
|
|
573
|
+
const scope = (0, import_react5.useMemo)(() => ({
|
|
413
574
|
id,
|
|
414
575
|
register: (layerId) => {
|
|
415
576
|
inside.current.add(layerId);
|
|
@@ -419,7 +580,7 @@ function Source(props) {
|
|
|
419
580
|
if (!map || !shown || shown.map !== map) {
|
|
420
581
|
return null;
|
|
421
582
|
}
|
|
422
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SourceContext.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SourceContext.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react5.Fragment, { children }, shown.generation) });
|
|
423
584
|
}
|
|
424
585
|
function effectiveLayer(layer, sourceId, visible) {
|
|
425
586
|
const out = { ...layer };
|
|
@@ -446,14 +607,14 @@ function applyDiff(prev, next, set) {
|
|
|
446
607
|
}
|
|
447
608
|
function StyleLayer(props) {
|
|
448
609
|
const map = useSMap();
|
|
449
|
-
const scope = (0,
|
|
610
|
+
const scope = (0, import_react5.useContext)(SourceContext);
|
|
450
611
|
const { layer, before, slot, visible = true } = props;
|
|
451
612
|
const current = effectiveLayer(layer, scope?.id, visible);
|
|
452
|
-
const latest = (0,
|
|
613
|
+
const latest = (0, import_react5.useRef)(current);
|
|
453
614
|
latest.current = current;
|
|
454
|
-
const shown = (0,
|
|
615
|
+
const shown = (0, import_react5.useRef)(null);
|
|
455
616
|
const structure = structureKey(current, before, slot);
|
|
456
|
-
(0,
|
|
617
|
+
(0, import_react5.useEffect)(() => {
|
|
457
618
|
if (!map) {
|
|
458
619
|
return void 0;
|
|
459
620
|
}
|
|
@@ -477,7 +638,7 @@ function StyleLayer(props) {
|
|
|
477
638
|
};
|
|
478
639
|
}, [map, structure, scope]);
|
|
479
640
|
const looks = optionsKey(current.paint) + optionsKey(current.layout) + optionsKey(current.filter);
|
|
480
|
-
(0,
|
|
641
|
+
(0, import_react5.useEffect)(() => {
|
|
481
642
|
const s = shown.current;
|
|
482
643
|
if (!map || !s || s.map !== map) {
|
|
483
644
|
return;
|
|
@@ -498,12 +659,12 @@ function StyleLayer(props) {
|
|
|
498
659
|
}
|
|
499
660
|
function useAddedLayer(method, id, options, remove) {
|
|
500
661
|
const map = useSMap();
|
|
501
|
-
const latest = (0,
|
|
662
|
+
const latest = (0, import_react5.useRef)(options);
|
|
502
663
|
latest.current = options;
|
|
503
|
-
const removeLatest = (0,
|
|
664
|
+
const removeLatest = (0, import_react5.useRef)(remove);
|
|
504
665
|
removeLatest.current = remove;
|
|
505
666
|
const looks = optionsKey(options);
|
|
506
|
-
(0,
|
|
667
|
+
(0, import_react5.useEffect)(() => {
|
|
507
668
|
if (!map) {
|
|
508
669
|
return void 0;
|
|
509
670
|
}
|
|
@@ -550,13 +711,13 @@ var dataLayerIds = (id) => [id, `${id}:lines`, `${id}:areas`];
|
|
|
550
711
|
function Data(props) {
|
|
551
712
|
const map = useSMap();
|
|
552
713
|
const { id, data, format, lat, lng, options, slot, onTap, visible = true, popupOptions } = props;
|
|
553
|
-
const latest = (0,
|
|
714
|
+
const latest = (0, import_react5.useRef)(props);
|
|
554
715
|
latest.current = props;
|
|
555
|
-
const shownVisible = (0,
|
|
716
|
+
const shownVisible = (0, import_react5.useRef)(true);
|
|
556
717
|
const hasTap = !!onTap || typeof options?.onClick === "function";
|
|
557
718
|
const hasPopup = !!props.popup || typeof options?.popup === "function";
|
|
558
719
|
const looks = optionsKey(options) + optionsKey(popupOptions) + (slot ?? "") + "|" + (format ?? "") + "|" + (lat ?? "") + "|" + (lng ?? "");
|
|
559
|
-
(0,
|
|
720
|
+
(0, import_react5.useEffect)(() => {
|
|
560
721
|
if (!map) {
|
|
561
722
|
return void 0;
|
|
562
723
|
}
|
|
@@ -599,7 +760,7 @@ function Data(props) {
|
|
|
599
760
|
ids.forEach((l) => quietly(() => map.removeLayer(l)));
|
|
600
761
|
};
|
|
601
762
|
}, [map, id, data, looks, hasTap, hasPopup]);
|
|
602
|
-
(0,
|
|
763
|
+
(0, import_react5.useEffect)(() => {
|
|
603
764
|
if (!map || shownVisible.current === visible) {
|
|
604
765
|
return;
|
|
605
766
|
}
|
|
@@ -611,10 +772,10 @@ function Data(props) {
|
|
|
611
772
|
}
|
|
612
773
|
function Layers(props) {
|
|
613
774
|
const map = useSMap();
|
|
614
|
-
const latest = (0,
|
|
775
|
+
const latest = (0, import_react5.useRef)(props.json);
|
|
615
776
|
latest.current = props.json;
|
|
616
777
|
const jsonKey = typeof props.json === "string" ? props.json : optionsKey(props.json);
|
|
617
|
-
(0,
|
|
778
|
+
(0, import_react5.useEffect)(() => {
|
|
618
779
|
if (!map) {
|
|
619
780
|
return void 0;
|
|
620
781
|
}
|
|
@@ -634,10 +795,10 @@ function Layers(props) {
|
|
|
634
795
|
function DeckLayer(props) {
|
|
635
796
|
const map = useSMap();
|
|
636
797
|
const { layer } = props;
|
|
637
|
-
const latest = (0,
|
|
798
|
+
const latest = (0, import_react5.useRef)(layer);
|
|
638
799
|
latest.current = layer;
|
|
639
|
-
const shown = (0,
|
|
640
|
-
(0,
|
|
800
|
+
const shown = (0, import_react5.useRef)(null);
|
|
801
|
+
(0, import_react5.useEffect)(() => {
|
|
641
802
|
if (!map) {
|
|
642
803
|
return void 0;
|
|
643
804
|
}
|
|
@@ -650,7 +811,7 @@ function DeckLayer(props) {
|
|
|
650
811
|
}
|
|
651
812
|
};
|
|
652
813
|
}, [map, layer.id]);
|
|
653
|
-
(0,
|
|
814
|
+
(0, import_react5.useEffect)(() => {
|
|
654
815
|
const s = shown.current;
|
|
655
816
|
if (!map || !s || s.map !== map || s.layer === layer) {
|
|
656
817
|
return;
|
|
@@ -664,7 +825,7 @@ function useRasterUrl(style, options) {
|
|
|
664
825
|
const map = useSMap();
|
|
665
826
|
const lang = options?.lang;
|
|
666
827
|
const retina = options?.retina;
|
|
667
|
-
return (0,
|
|
828
|
+
return (0, import_react5.useMemo)(() => {
|
|
668
829
|
if (!map) {
|
|
669
830
|
return null;
|
|
670
831
|
}
|
|
@@ -697,6 +858,7 @@ var import_smap2 = require("@superrouteca/smap");
|
|
|
697
858
|
DeckLayer,
|
|
698
859
|
Layers,
|
|
699
860
|
Lines,
|
|
861
|
+
PlanEditor,
|
|
700
862
|
Points,
|
|
701
863
|
Polygons,
|
|
702
864
|
RasterLayer,
|
|
@@ -708,7 +870,9 @@ var import_smap2 = require("@superrouteca/smap");
|
|
|
708
870
|
WmsLayer,
|
|
709
871
|
WmtsLayer,
|
|
710
872
|
formats,
|
|
873
|
+
planTexts,
|
|
711
874
|
popupTemplate,
|
|
875
|
+
usePlanEditor,
|
|
712
876
|
useRasterUrl,
|
|
713
877
|
useSMap
|
|
714
878
|
});
|