@reearth/core 0.0.7-alpha.13 → 0.0.7-alpha.15
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/core.js +6864 -5606
- package/dist/core.umd.cjs +71 -71
- package/dist/index.d.ts +56 -13
- package/package.json +8 -5
- package/src/Map/Layer/hooks.ts +6 -3
- package/src/Map/Layer/index.tsx +2 -0
- package/src/Map/Layers/hooks.ts +17 -0
- package/src/Map/Layers/index.tsx +12 -1
- package/src/Map/Layers/keys.ts +1 -0
- package/src/Map/Sketch/hooks.ts +405 -399
- package/src/Map/Sketch/index.tsx +65 -18
- package/src/Map/Sketch/sketchMachine.ts +359 -4
- package/src/Map/Sketch/sketchMachine.typegen.ts +58 -1
- package/src/Map/Sketch/types.ts +10 -20
- package/src/Map/Sketch/usePluginSketchLayer.ts +105 -0
- package/src/Map/Sketch/useSketch.ts +559 -0
- package/src/Map/Sketch/useSketchFeature.ts +198 -0
- package/src/Map/hooks.ts +32 -1
- package/src/Map/index.tsx +24 -0
- package/src/Map/ref.ts +8 -0
- package/src/Map/types/index.ts +21 -1
- package/src/Map/types/viewerProperty.ts +2 -0
- package/src/Visualizer/coreContext.tsx +2 -0
- package/src/Visualizer/hooks.ts +25 -0
- package/src/Visualizer/index.tsx +13 -0
- package/src/engines/Cesium/Feature/index.tsx +6 -2
- package/src/engines/Cesium/Sketch/ControlPoint.tsx +128 -24
- package/src/engines/Cesium/Sketch/ExtrudedControlPoints.tsx +70 -25
- package/src/engines/Cesium/Sketch/ExtrudedMeasurement.tsx +3 -1
- package/src/engines/Cesium/Sketch/ExtrudedPolygonEntity.tsx +14 -14
- package/src/engines/Cesium/Sketch/PolylineEntity.tsx +7 -4
- package/src/engines/Cesium/Sketch/SurfaceAddingPoints.tsx +60 -0
- package/src/engines/Cesium/Sketch/SurfaceControlPoints.tsx +125 -35
- package/src/engines/Cesium/Sketch/constants.ts +5 -0
- package/src/engines/Cesium/Sketch/index.tsx +68 -29
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapLabelImagery.tsx +8 -1
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapVectorMapLabel.tsx +14 -2
- package/src/engines/Cesium/core/labels/LabelImageryLayers.tsx +10 -1
- package/src/engines/Cesium/hooks/useEngineRef.ts +36 -0
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ import { PropsWithoutRef } from 'react';
|
|
|
17
17
|
import { ReactNode } from 'react';
|
|
18
18
|
import { RefAttributes } from 'react';
|
|
19
19
|
import { RefObject } from 'react';
|
|
20
|
-
import { RequireExactlyOne } from 'type-fest';
|
|
21
20
|
import { WritableAtom } from 'jotai';
|
|
22
21
|
|
|
23
22
|
export declare type AmbientOcclusionProperty = {
|
|
@@ -278,6 +277,7 @@ declare type CommonProps = {
|
|
|
278
277
|
isHidden?: boolean;
|
|
279
278
|
isSelected?: boolean;
|
|
280
279
|
meta?: Record<string, unknown>;
|
|
280
|
+
sketchEditingFeature?: SketchEditingFeature;
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
export declare function computeAtom(cache?: typeof globalDataFeaturesCache): WritableAtom<ComputedLayer | undefined, Command, void>;
|
|
@@ -299,6 +299,8 @@ export declare type ConditionsExpression = {
|
|
|
299
299
|
conditions: [string, string][];
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
+
declare type ControlPointMouseEventHandler = (index: number, isExtrudedPoint: boolean, type: "mousedown" | "click") => void;
|
|
303
|
+
|
|
302
304
|
export declare function convertLayer(l: Layer): LegacyLayer | undefined;
|
|
303
305
|
|
|
304
306
|
export declare function convertLegacyCluster(clusters: LegacyCluster[]): Cluster[];
|
|
@@ -320,6 +322,8 @@ declare type CoreContext = {
|
|
|
320
322
|
handleCameraForceHorizontalRollChange?: (enable?: boolean) => void;
|
|
321
323
|
handleInteractionModeChange?: (mode?: InteractionModeType | undefined) => void;
|
|
322
324
|
onSketchPluginFeatureCreate?: (cb: SketchEventCallback) => void;
|
|
325
|
+
onSketchPluginFeatureUpdate?: (cb: SketchEventCallback) => void;
|
|
326
|
+
onSketchPluginFeatureDelete?: (cb: SketchEventCallback) => void;
|
|
323
327
|
onSketchTypeChange?: (cb: (type: SketchType | undefined) => void) => void;
|
|
324
328
|
onLayerVisibility?: (cb: (e: LayerVisibilityEvent) => void) => void;
|
|
325
329
|
onLayerLoad?: (cb: (e: LayerLoadEvent) => void) => void;
|
|
@@ -359,7 +363,10 @@ export declare type CoreVisualizerProps = {
|
|
|
359
363
|
onMount?: () => void;
|
|
360
364
|
onSketchTypeChangeProp?: (type: SketchType | undefined) => void;
|
|
361
365
|
onSketchFeatureCreate?: (feature: SketchFeature | null) => void;
|
|
366
|
+
onSketchFeatureUpdate?: (feature: SketchFeature | null) => void;
|
|
367
|
+
onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
|
|
362
368
|
onInteractionModeChange?: (mode: InteractionModeType) => void;
|
|
369
|
+
onAPIReady?: () => void;
|
|
363
370
|
};
|
|
364
371
|
|
|
365
372
|
export declare type CursorType = "auto" | "grab" | "crosshair";
|
|
@@ -532,6 +539,7 @@ export declare type EngineRef = {
|
|
|
532
539
|
setView: (camera: CameraPosition) => void;
|
|
533
540
|
toWindowPosition: (position: [x: number, y: number, z: number]) => [x: number, y: number] | undefined;
|
|
534
541
|
getExtrudedHeight: (position: [x: number, y: number, z: number], windowPosition: [x: number, y: number]) => number | undefined;
|
|
542
|
+
getExtrudedPoint: (position: [x: number, y: number, z: number], extrutedHeight: number) => Position3d | undefined;
|
|
535
543
|
getSurfaceDistance: (point1: Cartesian3, point2: Cartesian3) => number | undefined;
|
|
536
544
|
equalsEpsilon2d: (point1: Position2d, point2: Position2d, relativeEpsilon: number | undefined, absoluteEpsilon: number | undefined) => boolean;
|
|
537
545
|
equalsEpsilon3d: (point1: Position3d, point2: Position3d, relativeEpsilon: number | undefined, absoluteEpsilon: number | undefined) => boolean;
|
|
@@ -589,6 +597,7 @@ export declare type EngineRef = {
|
|
|
589
597
|
selectFeatures: (layerId: string, featureId: string[]) => void;
|
|
590
598
|
unselectFeatures: (layerId: string, featureId: string[]) => void;
|
|
591
599
|
pickManyFromViewport: (windowPosition: [x: number, y: number], windowWidth: number, windowHeight: number, condition?: (f: PickedFeature) => boolean) => PickedFeature[] | undefined;
|
|
600
|
+
calcRectangleControlPoint: (p1: Position3d, p2: Position3d, p3: Position3d) => [p1: Position3d, p2: Position3d, p3: Position3d];
|
|
592
601
|
} & MouseEventHandles;
|
|
593
602
|
|
|
594
603
|
export declare const engines: {
|
|
@@ -747,11 +756,6 @@ export declare type FrustumAppearance = {
|
|
|
747
756
|
|
|
748
757
|
export declare type Geometry = Point | LineString | Polygon_2 | MultiPoint | MultiLineString | MultiPolygon;
|
|
749
758
|
|
|
750
|
-
declare type GeometryOptions = {
|
|
751
|
-
type: SketchType;
|
|
752
|
-
controlPoints: readonly Position3d[];
|
|
753
|
-
};
|
|
754
|
-
|
|
755
759
|
export declare type GeometryOptionsXYZ = {
|
|
756
760
|
type: SketchType;
|
|
757
761
|
controlPoints: Position3d[];
|
|
@@ -955,6 +959,7 @@ export declare type LayersRef = {
|
|
|
955
959
|
deleteLayer: (...ids: string[]) => void;
|
|
956
960
|
isLayer: (obj: any) => obj is LazyLayer;
|
|
957
961
|
isComputedLayer: (obj: any) => obj is ComputedLayer;
|
|
962
|
+
isTempLayer: (layerId?: string) => boolean;
|
|
958
963
|
layers: () => LazyLayer[];
|
|
959
964
|
walk: <T>(fn: (layer: LazyLayer, index: number, parents: LazyLayer[]) => T | void) => T | undefined;
|
|
960
965
|
find: (fn: (layer: LazyLayer, index: number, parents: LazyLayer[]) => boolean) => LazyLayer | undefined;
|
|
@@ -985,6 +990,7 @@ export declare type LayerVisibilityEvent = {
|
|
|
985
990
|
*/
|
|
986
991
|
export declare type LazyLayer = Readonly<Layer> & {
|
|
987
992
|
computed?: Readonly<ComputedLayer>;
|
|
993
|
+
isTempLayer?: boolean;
|
|
988
994
|
pluginId?: string;
|
|
989
995
|
extensionId?: string;
|
|
990
996
|
property?: any;
|
|
@@ -1075,7 +1081,8 @@ export declare type LUT = readonly ColorTuple[];
|
|
|
1075
1081
|
declare const Map_2: ForwardRefExoticComponent< {
|
|
1076
1082
|
engines?: Record<string, Engine> | undefined;
|
|
1077
1083
|
engine?: string | undefined;
|
|
1078
|
-
|
|
1084
|
+
onAPIReady?: (() => void) | undefined;
|
|
1085
|
+
} & Omit<Props_2, "Feature" | "viewerProperty" | "selectionReason" | "delegatedDataTypes" | "clusterComponent" | "selectedLayerId"> & Omit<EngineProps, "onLayerSelect" | "selectedLayerId" | "layerSelectionReason"> & Omit<SketchProps, "engineRef" | "SketchComponent" | "layersRef"> & {
|
|
1079
1086
|
cursor?: CursorType | undefined;
|
|
1080
1087
|
} & RefAttributes<MapRef>>;
|
|
1081
1088
|
export { Map_2 as Map }
|
|
@@ -1317,6 +1324,7 @@ declare type PropertyItem<T> = {
|
|
|
1317
1324
|
export declare type Props = {
|
|
1318
1325
|
engines?: Record<string, Engine>;
|
|
1319
1326
|
engine?: string;
|
|
1327
|
+
onAPIReady?: () => void;
|
|
1320
1328
|
} & Omit<Props_2, "Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId" | "viewerProperty"> & Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> & Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent"> & {
|
|
1321
1329
|
cursor?: CursorType;
|
|
1322
1330
|
};
|
|
@@ -1332,6 +1340,7 @@ declare type Props_2 = Omit<Props_3, "atomMap" | "isHidden" | "selectedLayerId">
|
|
|
1332
1340
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
1333
1341
|
engineRef?: RefObject<EngineRef>;
|
|
1334
1342
|
onLayerSelect?: (layerId: string | undefined, featureId: string | undefined, layer: (() => Promise<ComputedLayer | undefined>) | undefined, reason: LayerSelectionReason | undefined, info: SelectedFeatureInfo | undefined) => void;
|
|
1343
|
+
onMount?: () => void;
|
|
1335
1344
|
};
|
|
1336
1345
|
|
|
1337
1346
|
declare type Props_3 = {
|
|
@@ -1459,17 +1468,34 @@ export declare type ShadowProperty = {
|
|
|
1459
1468
|
|
|
1460
1469
|
export declare type SketchAppearance = Partial<LayerAppearanceTypes>;
|
|
1461
1470
|
|
|
1462
|
-
declare type SketchComponentProps =
|
|
1463
|
-
|
|
1464
|
-
|
|
1471
|
+
declare type SketchComponentProps = {
|
|
1472
|
+
geometryOptions?: {
|
|
1473
|
+
type: SketchType;
|
|
1474
|
+
controlPoints: readonly Position3d[];
|
|
1475
|
+
} | null;
|
|
1465
1476
|
extrudedHeight?: number;
|
|
1477
|
+
extrudedPoint?: Position3d;
|
|
1478
|
+
centroidBasePoint?: Position3d;
|
|
1479
|
+
centroidExtrudedPoint?: Position3d;
|
|
1466
1480
|
disableShadow?: boolean;
|
|
1467
|
-
enableRelativeHeight?: boolean;
|
|
1468
1481
|
color?: string;
|
|
1469
|
-
|
|
1482
|
+
isEditing?: boolean;
|
|
1483
|
+
catchedControlPointIndex?: number;
|
|
1484
|
+
catchedExtrudedPoint?: boolean;
|
|
1485
|
+
selectedControlPointIndex?: number;
|
|
1486
|
+
handleControlPointMouseEvent?: ControlPointMouseEventHandler;
|
|
1487
|
+
handleAddControlPoint?: (position: Position3d, index: number) => void;
|
|
1488
|
+
};
|
|
1470
1489
|
|
|
1471
1490
|
export declare type SketchComponentType = ComponentType<SketchComponentProps>;
|
|
1472
1491
|
|
|
1492
|
+
export declare type SketchEditFeatureChangeCb = (feature: SketchEditingFeature | undefined) => void;
|
|
1493
|
+
|
|
1494
|
+
export declare type SketchEditingFeature = {
|
|
1495
|
+
layerId: string;
|
|
1496
|
+
feature: ComputedFeature;
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1473
1499
|
export declare type SketchEventCallback = (event: SketchEventProps) => void;
|
|
1474
1500
|
|
|
1475
1501
|
export declare type SketchEventProps = {
|
|
@@ -1490,9 +1516,9 @@ export declare type SketchOptions = {
|
|
|
1490
1516
|
appearance?: SketchAppearance;
|
|
1491
1517
|
dataOnly?: boolean;
|
|
1492
1518
|
disableShadow?: boolean;
|
|
1493
|
-
enableRelativeHeight?: boolean;
|
|
1494
1519
|
rightClickToAbort?: boolean;
|
|
1495
1520
|
autoResetInteractionMode?: boolean;
|
|
1521
|
+
useCentroidExtrudedHeight?: boolean;
|
|
1496
1522
|
};
|
|
1497
1523
|
|
|
1498
1524
|
export declare type SketchProps = {
|
|
@@ -1505,7 +1531,17 @@ export declare type SketchProps = {
|
|
|
1505
1531
|
onSketchTypeChange?: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
1506
1532
|
onSketchFeatureCreate?: (feature: SketchFeature | null) => void;
|
|
1507
1533
|
onSketchPluginFeatureCreate?: (props: SketchEventProps) => void;
|
|
1534
|
+
onSketchFeatureUpdate?: (feature: SketchFeature | null) => void;
|
|
1535
|
+
onSketchPluginFeatureUpdate?: (props: SketchEventProps) => void;
|
|
1536
|
+
onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
|
|
1537
|
+
onSketchPluginFeatureDelete?: (props: {
|
|
1538
|
+
layerId: string;
|
|
1539
|
+
featureId: string;
|
|
1540
|
+
}) => void;
|
|
1508
1541
|
onLayerSelect?: OnLayerSelectType;
|
|
1542
|
+
sketchEditingFeature?: SketchEditingFeature;
|
|
1543
|
+
onSketchEditFeature?: (feature: SketchEditingFeature | undefined) => void;
|
|
1544
|
+
onMount?: () => void;
|
|
1509
1545
|
};
|
|
1510
1546
|
|
|
1511
1547
|
export declare type SketchRef = {
|
|
@@ -1513,6 +1549,11 @@ export declare type SketchRef = {
|
|
|
1513
1549
|
setType: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
1514
1550
|
getOptions: () => SketchOptions;
|
|
1515
1551
|
overrideOptions: (options: SketchOptions) => void;
|
|
1552
|
+
editFeature: (feature: SketchEditingFeature | undefined) => void;
|
|
1553
|
+
cancelEdit: (ignoreAutoReSelect?: boolean) => void;
|
|
1554
|
+
applyEdit: () => void;
|
|
1555
|
+
deleteFeature: (layerId: string, featureId: string) => void;
|
|
1556
|
+
onEditFeatureChange: (cb: SketchEditFeatureChangeCb) => void;
|
|
1516
1557
|
};
|
|
1517
1558
|
|
|
1518
1559
|
export declare type SketchType = "marker" | "polyline" | "circle" | "rectangle" | "polygon" | "extrudedCircle" | "extrudedRectangle" | "extrudedPolygon";
|
|
@@ -1581,6 +1622,8 @@ export declare type TileLabelProperty = {
|
|
|
1581
1622
|
id: string;
|
|
1582
1623
|
labelType: "japan_gsi_optimal_bvmap";
|
|
1583
1624
|
style: Record<string, any>;
|
|
1625
|
+
near?: number;
|
|
1626
|
+
far?: number;
|
|
1584
1627
|
};
|
|
1585
1628
|
|
|
1586
1629
|
export declare type TileProperty = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.7-alpha.
|
|
3
|
+
"version": "0.0.7-alpha.15",
|
|
4
4
|
"author": "Re:Earth contributors <community@reearth.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "A library that abstracts a map engine as one common API.",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"storybook": "storybook dev -p 6007",
|
|
22
22
|
"build-storybook": "storybook build",
|
|
23
23
|
"preversion": "yarn test run",
|
|
24
|
-
"version": "yarn build"
|
|
24
|
+
"version": "yarn build",
|
|
25
|
+
"sketch-typegen": "xstate typegen src/**/sketchMachine.ts"
|
|
25
26
|
},
|
|
26
27
|
"engines": {
|
|
27
28
|
"node": ">=20"
|
|
@@ -33,12 +34,13 @@
|
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@radix-ui/react-checkbox": "1.1.1",
|
|
36
|
-
"@radix-ui/react-select": "2.1.1",
|
|
37
|
-
"@radix-ui/react-separator": "1.1.0",
|
|
38
|
-
"@radix-ui/react-switch": "1.1.0",
|
|
39
37
|
"@radix-ui/react-dialog": "1.1.1",
|
|
40
38
|
"@radix-ui/react-icons": "1.3.0",
|
|
39
|
+
"@radix-ui/react-select": "2.1.1",
|
|
40
|
+
"@radix-ui/react-separator": "1.1.0",
|
|
41
41
|
"@radix-ui/react-slot": "1.1.0",
|
|
42
|
+
"@radix-ui/react-switch": "1.1.0",
|
|
43
|
+
"@radix-ui/react-toggle": "1.1.0",
|
|
42
44
|
"@reearth/cesium-mvt-imagery-provider": "1.5.4",
|
|
43
45
|
"@rot1024/use-transition": "1.0.0",
|
|
44
46
|
"@seznam/compose-react-refs": "1.0.6",
|
|
@@ -106,6 +108,7 @@
|
|
|
106
108
|
"@typescript-eslint/eslint-plugin": "7.2.0",
|
|
107
109
|
"@typescript-eslint/parser": "7.2.0",
|
|
108
110
|
"@vitejs/plugin-react": "4.2.1",
|
|
111
|
+
"@xstate/cli": "0.5.17",
|
|
109
112
|
"autoprefixer": "10.4.20",
|
|
110
113
|
"cesium": "1.118.0",
|
|
111
114
|
"class-variance-authority": "0.7.0",
|
package/src/Map/Layer/hooks.ts
CHANGED
|
@@ -107,12 +107,15 @@ export default function useHooks({
|
|
|
107
107
|
};
|
|
108
108
|
}, [layer, forceUpdateFeatures]);
|
|
109
109
|
|
|
110
|
-
const prevForceUpdatableData = useRef<Pick<Data, "csv" | "jsonProperties">>();
|
|
110
|
+
const prevForceUpdatableData = useRef<Pick<Data, "csv" | "jsonProperties" | "value">>();
|
|
111
111
|
useLayoutEffect(() => {
|
|
112
112
|
const data = layer?.type === "simple" ? layer.data : undefined;
|
|
113
|
-
const forceUpdatableData = pick(data, "csv", "jsonProperties");
|
|
113
|
+
const forceUpdatableData = pick(data, "csv", "jsonProperties", "value");
|
|
114
114
|
|
|
115
|
-
if (
|
|
115
|
+
if (
|
|
116
|
+
isEqual(forceUpdatableData, prevForceUpdatableData.current) ||
|
|
117
|
+
(!data?.url && !data?.value)
|
|
118
|
+
) {
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
121
|
|
package/src/Map/Layer/index.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ComputedFeature,
|
|
10
10
|
LayerSimple,
|
|
11
11
|
} from "../../mantle";
|
|
12
|
+
import { SketchEditingFeature } from "../Sketch";
|
|
12
13
|
import { ViewerProperty } from "../types";
|
|
13
14
|
|
|
14
15
|
import useHooks, { type Atom, type EvalFeature } from "./hooks";
|
|
@@ -25,6 +26,7 @@ export type CommonProps = {
|
|
|
25
26
|
isHidden?: boolean;
|
|
26
27
|
isSelected?: boolean;
|
|
27
28
|
meta?: Record<string, unknown>;
|
|
29
|
+
sketchEditingFeature?: SketchEditingFeature;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export type FeatureComponentProps = {
|
package/src/Map/Layers/hooks.ts
CHANGED
|
@@ -35,6 +35,7 @@ export type { Layer, NaiveLayer } from "../../mantle";
|
|
|
35
35
|
*/
|
|
36
36
|
export type LazyLayer = Readonly<Layer> & {
|
|
37
37
|
computed?: Readonly<ComputedLayer>;
|
|
38
|
+
isTempLayer?: boolean;
|
|
38
39
|
// compat
|
|
39
40
|
pluginId?: string;
|
|
40
41
|
extensionId?: string;
|
|
@@ -53,6 +54,7 @@ export type Ref = {
|
|
|
53
54
|
deleteLayer: (...ids: string[]) => void;
|
|
54
55
|
isLayer: (obj: any) => obj is LazyLayer;
|
|
55
56
|
isComputedLayer: (obj: any) => obj is ComputedLayer;
|
|
57
|
+
isTempLayer: (layerId?: string) => boolean;
|
|
56
58
|
layers: () => LazyLayer[];
|
|
57
59
|
walk: <T>(
|
|
58
60
|
fn: (layer: LazyLayer, index: number, parents: LazyLayer[]) => T | void,
|
|
@@ -119,6 +121,7 @@ export default function useHooks({
|
|
|
119
121
|
requestingRenderMode,
|
|
120
122
|
onLayerSelect,
|
|
121
123
|
engineRef,
|
|
124
|
+
onMount,
|
|
122
125
|
}: {
|
|
123
126
|
layers?: Layer[];
|
|
124
127
|
ref?: ForwardedRef<Ref>;
|
|
@@ -137,6 +140,7 @@ export default function useHooks({
|
|
|
137
140
|
info: SelectedFeatureInfo | undefined,
|
|
138
141
|
) => void;
|
|
139
142
|
engineRef?: RefObject<EngineRef>;
|
|
143
|
+
onMount?: () => void;
|
|
140
144
|
}) {
|
|
141
145
|
const layerMap = useMemo(() => new Map<string, Layer>(), []);
|
|
142
146
|
const [overriddenLayers, setOverridenLayers] = useState<OverriddenLayer[]>([]);
|
|
@@ -456,6 +460,13 @@ export default function useHooks({
|
|
|
456
460
|
[lazyLayerPrototype],
|
|
457
461
|
);
|
|
458
462
|
|
|
463
|
+
const isTempLayer = useCallback(
|
|
464
|
+
(layerId?: string) => {
|
|
465
|
+
return tempLayersRef.current.some(l => l.id === layerId);
|
|
466
|
+
},
|
|
467
|
+
[tempLayersRef],
|
|
468
|
+
);
|
|
469
|
+
|
|
459
470
|
const isComputedLayer = useCallback(
|
|
460
471
|
(obj: any): obj is ComputedLayer => {
|
|
461
472
|
return typeof obj === "object" && Object.getPrototypeOf(obj) === lazyComputedLayerPrototype;
|
|
@@ -560,6 +571,7 @@ export default function useHooks({
|
|
|
560
571
|
findByIds,
|
|
561
572
|
isLayer,
|
|
562
573
|
isComputedLayer,
|
|
574
|
+
isTempLayer,
|
|
563
575
|
layers: rootLayers,
|
|
564
576
|
walk,
|
|
565
577
|
find,
|
|
@@ -585,6 +597,7 @@ export default function useHooks({
|
|
|
585
597
|
findByIds,
|
|
586
598
|
isLayer,
|
|
587
599
|
isComputedLayer,
|
|
600
|
+
isTempLayer,
|
|
588
601
|
rootLayers,
|
|
589
602
|
walk,
|
|
590
603
|
find,
|
|
@@ -602,6 +615,10 @@ export default function useHooks({
|
|
|
602
615
|
],
|
|
603
616
|
);
|
|
604
617
|
|
|
618
|
+
useEffect(() => {
|
|
619
|
+
onMount?.();
|
|
620
|
+
}, [onMount]);
|
|
621
|
+
|
|
605
622
|
const prevLayers = useRef<Layer[] | undefined>([]);
|
|
606
623
|
useLayoutEffect(() => {
|
|
607
624
|
const ids = new Set<string>();
|
package/src/Map/Layers/index.tsx
CHANGED
|
@@ -46,10 +46,20 @@ export type Props = Omit<ClusteredLayerProps, "atomMap" | "isHidden" | "selected
|
|
|
46
46
|
reason: LayerSelectionReason | undefined,
|
|
47
47
|
info: SelectedFeatureInfo | undefined,
|
|
48
48
|
) => void;
|
|
49
|
+
onMount?: () => void;
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const Layers: ForwardRefRenderFunction<Ref, Props> = (
|
|
52
|
-
{
|
|
53
|
+
{
|
|
54
|
+
layers,
|
|
55
|
+
selectedLayer,
|
|
56
|
+
hiddenLayers,
|
|
57
|
+
requestingRenderMode,
|
|
58
|
+
engineRef,
|
|
59
|
+
onLayerSelect,
|
|
60
|
+
onMount,
|
|
61
|
+
...props
|
|
62
|
+
},
|
|
53
63
|
ref,
|
|
54
64
|
) => {
|
|
55
65
|
const { atomMap, flattenedLayers, isHidden } = useHooks({
|
|
@@ -60,6 +70,7 @@ const Layers: ForwardRefRenderFunction<Ref, Props> = (
|
|
|
60
70
|
requestingRenderMode,
|
|
61
71
|
engineRef,
|
|
62
72
|
onLayerSelect,
|
|
73
|
+
onMount,
|
|
63
74
|
});
|
|
64
75
|
|
|
65
76
|
return (
|