@wenle_2523097/agri-map 1.0.2 → 1.0.3
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/components/ConfigProvider/index.d.ts +15 -0
- package/dist/components/ConfigProvider/index.d.ts.map +1 -0
- package/dist/components/DualScaleControl/index.d.ts +10 -0
- package/dist/components/DualScaleControl/index.d.ts.map +1 -0
- package/dist/components/Icons/SelectIcon.d.ts +68 -0
- package/dist/components/Icons/SelectIcon.d.ts.map +1 -0
- package/dist/components/Icons/index.d.ts +43 -0
- package/dist/components/Icons/index.d.ts.map +1 -0
- package/dist/components/Irrigation/index.d.ts +8 -0
- package/dist/components/Irrigation/index.d.ts.map +1 -0
- package/dist/components/Irrigation/toolbar.d.ts +6 -0
- package/dist/components/Irrigation/toolbar.d.ts.map +1 -0
- package/dist/components/Loading/index.d.ts +40 -0
- package/dist/components/Loading/index.d.ts.map +1 -0
- package/dist/components/MapContent/index.d.ts +17 -0
- package/dist/components/MapContent/index.d.ts.map +1 -0
- package/dist/components/MapSizeHandler/index.d.ts +24 -0
- package/dist/components/MapSizeHandler/index.d.ts.map +1 -0
- package/dist/components/Marker/ClusterView.d.ts +29 -0
- package/dist/components/Marker/ClusterView.d.ts.map +1 -0
- package/dist/components/Marker/MapClickHandler.d.ts +25 -0
- package/dist/components/Marker/MapClickHandler.d.ts.map +1 -0
- package/dist/components/Marker/index.d.ts +61 -0
- package/dist/components/Marker/index.d.ts.map +1 -0
- package/dist/components/Marker/parseClusterConfig.d.ts +25 -0
- package/dist/components/Marker/parseClusterConfig.d.ts.map +1 -0
- package/dist/components/Marker/toolbar.d.ts +6 -0
- package/dist/components/Marker/toolbar.d.ts.map +1 -0
- package/dist/components/Marker/useEditHandlers.d.ts +44 -0
- package/dist/components/Marker/useEditHandlers.d.ts.map +1 -0
- package/dist/components/Marker/useIconConfig.d.ts +23 -0
- package/dist/components/Marker/useIconConfig.d.ts.map +1 -0
- package/dist/components/Marker/useMarkerCommands.d.ts +30 -0
- package/dist/components/Marker/useMarkerCommands.d.ts.map +1 -0
- package/dist/components/Measurement/toolbar.d.ts +20 -0
- package/dist/components/Measurement/toolbar.d.ts.map +1 -0
- package/dist/components/MiniMap/index.d.ts +16 -0
- package/dist/components/MiniMap/index.d.ts.map +1 -0
- package/dist/components/Notification/index.d.ts +12 -0
- package/dist/components/Notification/index.d.ts.map +1 -0
- package/dist/components/PlotGroupLayer/index.d.ts +8 -0
- package/dist/components/PlotGroupLayer/index.d.ts.map +1 -0
- package/dist/components/PlotLayer/index.d.ts +7 -0
- package/dist/components/PlotLayer/index.d.ts.map +1 -0
- package/dist/components/PlotLayer/label.d.ts +12 -0
- package/dist/components/PlotLayer/label.d.ts.map +1 -0
- package/dist/components/PlotLayer/leaflet-types.d.ts +59 -0
- package/dist/components/PlotLayer/leaflet-types.d.ts.map +1 -0
- package/dist/components/PlotLayer/parseConfig.d.ts +15 -0
- package/dist/components/PlotLayer/parseConfig.d.ts.map +1 -0
- package/dist/components/PlotLayer/toolbar.d.ts +6 -0
- package/dist/components/PlotLayer/toolbar.d.ts.map +1 -0
- package/dist/components/PlotLayer/types.d.ts +10 -0
- package/dist/components/PlotLayer/types.d.ts.map +1 -0
- package/dist/components/PlotLayer/usePlotCommands.d.ts +33 -0
- package/dist/components/PlotLayer/usePlotCommands.d.ts.map +1 -0
- package/dist/components/PlotLayer/usePlotData.d.ts +32 -0
- package/dist/components/PlotLayer/usePlotData.d.ts.map +1 -0
- package/dist/components/PlotLayer/usePlotEditMode.d.ts +92 -0
- package/dist/components/PlotLayer/usePlotEditMode.d.ts.map +1 -0
- package/dist/components/Road/index.d.ts +8 -0
- package/dist/components/Road/index.d.ts.map +1 -0
- package/dist/components/Road/toolbar.d.ts +6 -0
- package/dist/components/Road/toolbar.d.ts.map +1 -0
- package/dist/components/TianDiTuLayer/index.d.ts +15 -0
- package/dist/components/TianDiTuLayer/index.d.ts.map +1 -0
- package/dist/components/Track/ClusterView.d.ts +20 -0
- package/dist/components/Track/ClusterView.d.ts.map +1 -0
- package/dist/components/Track/TrackView.d.ts +24 -0
- package/dist/components/Track/TrackView.d.ts.map +1 -0
- package/dist/components/Track/commands.d.ts +53 -0
- package/dist/components/Track/commands.d.ts.map +1 -0
- package/dist/components/Track/constants.d.ts +34 -0
- package/dist/components/Track/constants.d.ts.map +1 -0
- package/dist/components/Track/index.d.ts +54 -0
- package/dist/components/Track/index.d.ts.map +1 -0
- package/dist/components/Track/parseConfig.d.ts +40 -0
- package/dist/components/Track/parseConfig.d.ts.map +1 -0
- package/dist/components/Track/types.d.ts +38 -0
- package/dist/components/Track/types.d.ts.map +1 -0
- package/dist/components/Track/useMarkerIcon.d.ts +14 -0
- package/dist/components/Track/useMarkerIcon.d.ts.map +1 -0
- package/dist/components/Track/useTrackCommands.d.ts +56 -0
- package/dist/components/Track/useTrackCommands.d.ts.map +1 -0
- package/dist/components/shared/BaseEditToolbar.d.ts +100 -0
- package/dist/components/shared/BaseEditToolbar.d.ts.map +1 -0
- package/dist/components/shared/ToolbarButton.d.ts +49 -0
- package/dist/components/shared/ToolbarButton.d.ts.map +1 -0
- package/dist/components/shared/index.d.ts +5 -0
- package/dist/components/shared/index.d.ts.map +1 -0
- package/dist/constants/device.d.ts +14 -0
- package/dist/constants/device.d.ts.map +1 -0
- package/dist/constants/index.d.ts +20 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/map.d.ts +13 -0
- package/dist/constants/map.d.ts.map +1 -0
- package/dist/constants/plot.d.ts +33 -0
- package/dist/constants/plot.d.ts.map +1 -0
- package/dist/constants/road.d.ts +12 -0
- package/dist/constants/road.d.ts.map +1 -0
- package/dist/constants/styles.d.ts +57 -0
- package/dist/constants/styles.d.ts.map +1 -0
- package/dist/constants/theme.d.ts +47 -0
- package/dist/constants/theme.d.ts.map +1 -0
- package/dist/constants/unit.d.ts +11 -0
- package/dist/constants/unit.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useEditMode.d.ts +75 -0
- package/dist/hooks/useEditMode.d.ts.map +1 -0
- package/dist/hooks/useLatestRef.d.ts +17 -0
- package/dist/hooks/useLatestRef.d.ts.map +1 -0
- package/dist/hooks/usePolylineEditor.d.ts +65 -0
- package/dist/hooks/usePolylineEditor.d.ts.map +1 -0
- package/dist/hooks/usePolylineRenderer.d.ts +34 -0
- package/dist/hooks/usePolylineRenderer.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +13 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types/basic.d.ts +57 -0
- package/dist/types/basic.d.ts.map +1 -0
- package/dist/types/components.d.ts +56 -0
- package/dist/types/components.d.ts.map +1 -0
- package/dist/types/config.d.ts +112 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/decorator.d.ts +26 -0
- package/dist/types/decorator.d.ts.map +1 -0
- package/dist/types/icon.d.ts +52 -0
- package/dist/types/icon.d.ts.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/irrigation.d.ts +315 -0
- package/dist/types/irrigation.d.ts.map +1 -0
- package/dist/types/layer.d.ts +40 -0
- package/dist/types/layer.d.ts.map +1 -0
- package/dist/types/loading.d.ts +62 -0
- package/dist/types/loading.d.ts.map +1 -0
- package/dist/types/marker.d.ts +299 -0
- package/dist/types/marker.d.ts.map +1 -0
- package/dist/types/measurement.d.ts +121 -0
- package/dist/types/measurement.d.ts.map +1 -0
- package/dist/types/notification.d.ts +50 -0
- package/dist/types/notification.d.ts.map +1 -0
- package/dist/types/plot.d.ts +479 -0
- package/dist/types/plot.d.ts.map +1 -0
- package/dist/types/road.d.ts +382 -0
- package/dist/types/road.d.ts.map +1 -0
- package/dist/types/toolbar.d.ts +176 -0
- package/dist/types/toolbar.d.ts.map +1 -0
- package/dist/types/track.d.ts +386 -0
- package/dist/types/track.d.ts.map +1 -0
- package/dist/utils/area.d.ts +57 -0
- package/dist/utils/area.d.ts.map +1 -0
- package/dist/utils/clusterIcon.d.ts +16 -0
- package/dist/utils/clusterIcon.d.ts.map +1 -0
- package/dist/utils/createAntPath.d.ts +13 -0
- package/dist/utils/createAntPath.d.ts.map +1 -0
- package/dist/utils/geometry.d.ts +41 -0
- package/dist/utils/geometry.d.ts.map +1 -0
- package/dist/utils/iconCache.d.ts +49 -0
- package/dist/utils/iconCache.d.ts.map +1 -0
- package/dist/utils/iconUtils.d.ts +46 -0
- package/dist/utils/iconUtils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/leafletIcons.d.ts +40 -0
- package/dist/utils/leafletIcons.d.ts.map +1 -0
- package/dist/utils/mapAnimation.d.ts +14 -0
- package/dist/utils/mapAnimation.d.ts.map +1 -0
- package/dist/utils/markerSvg.d.ts +19 -0
- package/dist/utils/markerSvg.d.ts.map +1 -0
- package/dist/utils/pulseIcon.d.ts +28 -0
- package/dist/utils/pulseIcon.d.ts.map +1 -0
- package/dist/utils/spatialIndex.d.ts +56 -0
- package/dist/utils/spatialIndex.d.ts.map +1 -0
- package/dist/utils/toggleItemState.d.ts +15 -0
- package/dist/utils/toggleItemState.d.ts.map +1 -0
- package/dist/utils/trackSimplify.d.ts +23 -0
- package/dist/utils/trackSimplify.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 解析编辑模式的 Hook
|
|
3
|
+
* @description 统一处理各组件的 editMode 属性解析逻辑
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
import type { ToolbarColor, ToolbarSize } from '../components/shared/BaseEditToolbar';
|
|
7
|
+
/**
|
|
8
|
+
* 编辑模式对象配置
|
|
9
|
+
*/
|
|
10
|
+
export interface EditModeObjectConfig<T extends string> {
|
|
11
|
+
/** 启用的编辑按钮 */
|
|
12
|
+
enabled?: boolean | T[];
|
|
13
|
+
/** 自定义工具栏内容 */
|
|
14
|
+
toolbar?: ReactNode;
|
|
15
|
+
/** 内置按钮的统一颜色(支持预设色和自定义颜色) */
|
|
16
|
+
color?: ToolbarColor;
|
|
17
|
+
/** 内置按钮的统一尺寸(支持预设尺寸和自定义数字) */
|
|
18
|
+
size?: ToolbarSize;
|
|
19
|
+
/** 是否仅显示图标(不显示文字) */
|
|
20
|
+
iconOnly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 编辑模式类型
|
|
24
|
+
* - `false`: 禁用编辑
|
|
25
|
+
* - `true`: 启用全部编辑功能
|
|
26
|
+
* - `T[]`: 启用指定的编辑按钮
|
|
27
|
+
* - `EditModeObjectConfig<T>`: 对象配置,支持自定义工具栏
|
|
28
|
+
*/
|
|
29
|
+
export type EditModeConfig<T extends string> = boolean | T[] | EditModeObjectConfig<T>;
|
|
30
|
+
/**
|
|
31
|
+
* 编辑模式解析结果
|
|
32
|
+
*/
|
|
33
|
+
export interface EditModeResult<T extends string> {
|
|
34
|
+
/** 是否启用编辑模式 */
|
|
35
|
+
editEnabled: boolean;
|
|
36
|
+
/** 启用的按钮列表 */
|
|
37
|
+
enabledButtons: T[];
|
|
38
|
+
/** 自定义工具栏内容 */
|
|
39
|
+
customToolbar?: ReactNode;
|
|
40
|
+
/** 内置按钮的统一颜色 */
|
|
41
|
+
color?: ToolbarColor;
|
|
42
|
+
/** 内置按钮的统一尺寸 */
|
|
43
|
+
size?: ToolbarSize;
|
|
44
|
+
/** 是否仅显示图标 */
|
|
45
|
+
iconOnly?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 解析编辑模式配置
|
|
49
|
+
* @param editModeProp 编辑模式属性值
|
|
50
|
+
* @param defaultButtons 当 editMode 为 true 时默认启用的按钮
|
|
51
|
+
* @returns EditModeResult
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* // PlotLayer
|
|
56
|
+
* const { editEnabled, enabledButtons } = useEditMode(
|
|
57
|
+
* editModeProp,
|
|
58
|
+
* ['redraw', 'clip', 'move', 'create', 'delete'] as const
|
|
59
|
+
* );
|
|
60
|
+
*
|
|
61
|
+
* // Marker
|
|
62
|
+
* const { editEnabled, enabledButtons } = useEditMode(
|
|
63
|
+
* editModeProp,
|
|
64
|
+
* ['create', 'move', 'delete'] as const
|
|
65
|
+
* );
|
|
66
|
+
*
|
|
67
|
+
* // 使用对象配置
|
|
68
|
+
* const { editEnabled, enabledButtons, customToolbar } = useEditMode(
|
|
69
|
+
* { enabled: ['create', 'move'], toolbar: <Button>自定义</Button> },
|
|
70
|
+
* ['create', 'move', 'delete'] as const
|
|
71
|
+
* );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function useEditMode<T extends string>(editModeProp: EditModeConfig<T> | undefined, defaultButtons: readonly T[]): EditModeResult<T>;
|
|
75
|
+
export default useEditMode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditMode.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM;IACpD,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC;IACxB,eAAe;IACf,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,OAAO,GAAG,CAAC,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM;IAC9C,eAAe;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc;IACd,cAAc,EAAE,CAAC,EAAE,CAAC;IACpB,eAAe;IACf,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,gBAAgB;IAChB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,gBAAgB;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,cAAc;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC1C,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,EAC3C,cAAc,EAAE,SAAS,CAAC,EAAE,GAC3B,cAAc,CAAC,CAAC,CAAC,CAkDnB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 保持 ref 始终指向最新值的 Hook
|
|
3
|
+
* @description 用于在回调中访问最新值,避免闭包陷阱
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 返回一个 ref,其 current 始终指向传入的最新值
|
|
7
|
+
* @param value 需要保持引用的值
|
|
8
|
+
* @returns React.MutableRefObject<T>
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const onClickRef = useLatestRef(onClick);
|
|
13
|
+
* // 在回调中使用 onClickRef.current
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function useLatestRef<T>(value: T): import("react").MutableRefObject<T>;
|
|
17
|
+
export default useLatestRef;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLatestRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useLatestRef.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,uCAMvC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 折线编辑器状态管理 Hook
|
|
3
|
+
*
|
|
4
|
+
* 封装 Irrigation / Road 等折线类组件共享的编辑状态机逻辑:
|
|
5
|
+
* - currentMode / tempPoints 状态管理
|
|
6
|
+
* - pendingCreate 流程(新建 → 保存 → 抽屉 → 完成/取消)
|
|
7
|
+
* - handleCancel(清理编辑状态)
|
|
8
|
+
* - Escape 快捷键取消
|
|
9
|
+
* - normalizedData 变化时自动重置 pendingCreate 状态
|
|
10
|
+
* - pm:create / pm:edit 事件监听
|
|
11
|
+
*/
|
|
12
|
+
import L from 'leaflet';
|
|
13
|
+
import type { Coordinate } from '../types';
|
|
14
|
+
export interface UsePolylineEditorOptions {
|
|
15
|
+
/** Leaflet 地图实例 */
|
|
16
|
+
map: L.Map;
|
|
17
|
+
/** 编辑中的图层引用(由组件持有,类型各不相同) */
|
|
18
|
+
editingLayerRef: React.MutableRefObject<L.Polyline | null>;
|
|
19
|
+
/** 标准化后的数据源,用于检测 pendingCreate 保存后的数据变化 */
|
|
20
|
+
normalizedData: unknown[];
|
|
21
|
+
/** Whether PM event listeners (pm:create, pm:edit, etc.) should be active. Default: true */
|
|
22
|
+
pmEventsEnabled?: boolean;
|
|
23
|
+
/** Called when pm:create fires. Use this to convert the drawn layer type (e.g., asIrrigationLayer). */
|
|
24
|
+
onDrawnLayer?: (drawnLayer: L.Polyline) => void;
|
|
25
|
+
/** Optional runtime guard for pm:create event. Return false to skip handling. */
|
|
26
|
+
pmCreateGuard?: () => boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface UsePolylineEditorReturn {
|
|
29
|
+
/** 当前编辑模式 */
|
|
30
|
+
currentMode: 'idle' | 'create' | 'edit';
|
|
31
|
+
/** 设置当前编辑模式 */
|
|
32
|
+
setCurrentMode: React.Dispatch<React.SetStateAction<'idle' | 'create' | 'edit'>>;
|
|
33
|
+
/** 临时坐标点(绘制/编辑中的坐标) */
|
|
34
|
+
tempPoints: Coordinate[];
|
|
35
|
+
/** 设置临时坐标点 */
|
|
36
|
+
setTempPoints: React.Dispatch<React.SetStateAction<Coordinate[]>>;
|
|
37
|
+
/** 新建待提交标记 ref(详见各组件中 pendingCreateRef 注释) */
|
|
38
|
+
pendingCreateRef: React.MutableRefObject<boolean>;
|
|
39
|
+
/** 编辑前原始坐标 ref */
|
|
40
|
+
originalPointsRef: React.MutableRefObject<Coordinate[] | null>;
|
|
41
|
+
/** currentMode 的最新引用(用于在回调和事件处理中读取最新值) */
|
|
42
|
+
currentModeRef: React.MutableRefObject<'idle' | 'create' | 'edit'>;
|
|
43
|
+
/** 取消操作:清理所有编辑状态 */
|
|
44
|
+
handleCancel: () => void;
|
|
45
|
+
}
|
|
46
|
+
export declare function usePolylineEditor(options: UsePolylineEditorOptions): UsePolylineEditorReturn;
|
|
47
|
+
export interface UsePolylineSaveOptions {
|
|
48
|
+
map: L.Map;
|
|
49
|
+
currentMode: 'idle' | 'create' | 'edit';
|
|
50
|
+
tempPoints: Coordinate[];
|
|
51
|
+
value: string | number | null;
|
|
52
|
+
editingLayerRef: React.MutableRefObject<L.Polyline | null>;
|
|
53
|
+
pendingCreateRef: React.MutableRefObject<boolean>;
|
|
54
|
+
originalPointsRef: React.MutableRefObject<Coordinate[] | null>;
|
|
55
|
+
layerByIdRef: React.MutableRefObject<Record<string | number, L.Polyline>>;
|
|
56
|
+
setCurrentMode: React.Dispatch<React.SetStateAction<'idle' | 'create' | 'edit'>>;
|
|
57
|
+
setTempPoints: React.Dispatch<React.SetStateAction<Coordinate[]>>;
|
|
58
|
+
/** Called when create save is triggered with the new points */
|
|
59
|
+
onCreateSave: (points: Coordinate[]) => void;
|
|
60
|
+
/** Called when edit save is triggered with id, oldPoints, newPoints */
|
|
61
|
+
onEditSave: (id: string | number, oldPoints: Coordinate[], newPoints: Coordinate[]) => void;
|
|
62
|
+
}
|
|
63
|
+
export declare function usePolylineSave(options: UsePolylineSaveOptions): {
|
|
64
|
+
handleSave: () => void;
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePolylineEditor.d.ts","sourceRoot":"","sources":["../../src/hooks/usePolylineEditor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,CAAC,MAAM,SAAS,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,WAAW,wBAAwB;IACvC,mBAAmB;IACnB,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;IACX,6BAA6B;IAC7B,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC3D,2CAA2C;IAC3C,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B,4FAA4F;IAC5F,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uGAAuG;IACvG,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;IAChD,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa;IACb,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACxC,eAAe;IACf,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC;IACjF,uBAAuB;IACvB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,cAAc;IACd,aAAa,EAAE,KAAK,CAAC,Q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,UAAU,EAAE,CAAC,CAAC,CAAC;IAClE,+DAA+D;IAC/D,YAAY,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAC7C,uEAAuE;IACvE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CAC7F;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG;IAAE,UAAU,EAAE,MAAM,IAAI,CAAA;CAAE,CAkE3F"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 线要素渲染 hook(共享逻辑)
|
|
3
|
+
* @description 提取 Irrigation 和 Road 组件中重复的图层管理逻辑:
|
|
4
|
+
* - 主渲染 useEffect 的图层创建/销毁/编辑模式过滤
|
|
5
|
+
* - 组件卸载时清理编辑图层 (editingLayerRef)
|
|
6
|
+
* @module hooks/usePolylineRenderer
|
|
7
|
+
*/
|
|
8
|
+
import { type MutableRefObject } from 'react';
|
|
9
|
+
import L from 'leaflet';
|
|
10
|
+
interface UsePolylineRendererOptions {
|
|
11
|
+
map: L.Map | null;
|
|
12
|
+
normalizedData: any[];
|
|
13
|
+
value: string | number | null;
|
|
14
|
+
currentMode: 'idle' | 'create' | 'edit';
|
|
15
|
+
/** 渲染单条数据到 layerGroup 中 */
|
|
16
|
+
renderItem: (item: any, layerGroup: L.LayerGroup, index: number) => void;
|
|
17
|
+
layerGroupRef: MutableRefObject<L.LayerGroup | null>;
|
|
18
|
+
layerByIdRef: MutableRefObject<Record<string | number, any>>;
|
|
19
|
+
editingLayerRef: MutableRefObject<any | null>;
|
|
20
|
+
deps: any[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 管理线要素图层的创建与清理
|
|
24
|
+
*
|
|
25
|
+
* 负责:
|
|
26
|
+
* 1. 编辑模式下过滤数据(create/edit 模式不渲染已有要素)
|
|
27
|
+
* 2. 创建 LayerGroup 并将数据渲染进去
|
|
28
|
+
* 3. 组件卸载时移除 editingLayerRef
|
|
29
|
+
*
|
|
30
|
+
* 注意:editingLayerRef 的日常生命周期(handleRedraw/handleEdit 创建、
|
|
31
|
+
* handleCancel/handleSave 销毁)由组件自行管理,此 hook 仅在组件卸载时兜底清理。
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePolylineRenderer(options: UsePolylineRendererOptions): void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePolylineRenderer.d.ts","sourceRoot":"","sources":["../../src/hooks/usePolylineRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,CAAC,MAAM,SAAS,CAAC;AAExB,UAAU,0BAA0B;IAClC,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;IAClB,cAAc,EAAE,GAAG,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACxC,2BAA2B;IAC3B,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACrD,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7D,eAAe,EAAE,gBAAgB,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAC9C,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI,CA6E7E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题 Hook
|
|
3
|
+
* @description 提供统一的主题访问接口
|
|
4
|
+
*/
|
|
5
|
+
import { type ThemeMode, type ThemeColors } from '../constants/theme';
|
|
6
|
+
/**
|
|
7
|
+
* 获取当前主题及颜色配置的 Hook
|
|
8
|
+
* @returns 主题模式和颜色配置
|
|
9
|
+
*/
|
|
10
|
+
export declare const useTheme: () => {
|
|
11
|
+
theme: ThemeMode;
|
|
12
|
+
colors: ThemeColors;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAkB,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAO;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAOlE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 农业地图组件库主入口文件
|
|
3
|
+
* @description 导出所有公共组件和工具函数
|
|
4
|
+
*/
|
|
5
|
+
import './styles/index.scss';
|
|
6
|
+
/**
|
|
7
|
+
* 高性能地块图层组件
|
|
8
|
+
* @description 使用Leaflet原生GeoJSON Layer,支持大规模地块数据(上万条),支持单击和右键事件
|
|
9
|
+
* @see docs/PERFORMANCE_OPTIMIZATION.md 性能优化指南
|
|
10
|
+
* @example
|
|
11
|
+
* <PlotLayer plots={plotDataArray} onPlotClick={handleClick} onPlotContextMenu={handleContextMenu} />
|
|
12
|
+
*/
|
|
13
|
+
export { default as PlotLayer } from './components/PlotLayer';
|
|
14
|
+
/**
|
|
15
|
+
* 多类型地块分组编排组件
|
|
16
|
+
* @description 将多种类型的地块分组渲染,每种类型对应一个独立的 PlotLayer 实例,
|
|
17
|
+
* 支持跨类型互斥选中、统一分组高亮、合并渲染统计等功能。
|
|
18
|
+
* @example
|
|
19
|
+
* <PlotGroupLayer
|
|
20
|
+
* dataSource={{
|
|
21
|
+
* wasteland: { dataSource: wastelandData, path: { color: '#8B7355', fillColor: '#8B7355', fillOpacity: 0.3 } },
|
|
22
|
+
* paddyField: { dataSource: paddyFieldData, path: { color: '#52c41a', fillColor: '#52c41a', fillOpacity: 0.3 } },
|
|
23
|
+
* }}
|
|
24
|
+
* mode="single"
|
|
25
|
+
* groupKey="possessor"
|
|
26
|
+
* />
|
|
27
|
+
*/
|
|
28
|
+
export { default as PlotGroupLayer } from './components/PlotGroupLayer';
|
|
29
|
+
/**
|
|
30
|
+
* 天地图图层组件
|
|
31
|
+
* @description 封装天地图的矢量图层和标注图层,支持多种图层风格(矢量、卫星、地形)和叠加瓦片
|
|
32
|
+
* @example
|
|
33
|
+
* <TianDiTuLayer apiKey="your-key" layerType="satellite" showAnnotation={true} />
|
|
34
|
+
* <TianDiTuLayer apiKey="your-key" overlayUrl="https://your-server.com/overlay/{z}/{x}/{y}.png" overlayOpacity={0.5} />
|
|
35
|
+
*/
|
|
36
|
+
export { default as TianDiTuLayer, LAYER_TYPES } from './components/TianDiTuLayer';
|
|
37
|
+
/**
|
|
38
|
+
* 双向标尺组件
|
|
39
|
+
* @description 在地图上同时显示水平和垂直两个标尺
|
|
40
|
+
* @example
|
|
41
|
+
* <DualScaleControl />
|
|
42
|
+
* <DualScaleControl config={{ metric: true, imperial: false, showZoomControl: true }} />
|
|
43
|
+
*/
|
|
44
|
+
export { default as DualScaleControl } from './components/DualScaleControl';
|
|
45
|
+
/**
|
|
46
|
+
* 测量工具栏组件
|
|
47
|
+
* @description 提供地图上的长度和面积测量功能,采用统一的工具栏样式
|
|
48
|
+
* @features
|
|
49
|
+
* - 测长度:绘制折线,实时显示长度
|
|
50
|
+
* - 测面积:绘制多边形,实时显示面积
|
|
51
|
+
* - 支持多种单位:m/km/ft/mi(长度), sqm/sqkm/sqft/acre/hectare(面积)
|
|
52
|
+
* - 可配置位置:topleft/topright/bottomleft/bottomright
|
|
53
|
+
* - 实时显示测量值
|
|
54
|
+
* - 统一工具栏样式,与 BaseEditToolbar 保持一致
|
|
55
|
+
* @example
|
|
56
|
+
* // 基础用法
|
|
57
|
+
* <MeasurementToolbar />
|
|
58
|
+
*
|
|
59
|
+
* // 自定义位置和单位
|
|
60
|
+
* <MeasurementToolbar position="topright" lengthUnit="km" areaUnit="hectare" />
|
|
61
|
+
*/
|
|
62
|
+
export { default as MeasurementToolbar } from './components/Measurement/toolbar';
|
|
63
|
+
/**
|
|
64
|
+
* 全局配置提供者组件
|
|
65
|
+
* @description 为子组件提供统一的全局配置(如主题)
|
|
66
|
+
* @example
|
|
67
|
+
* <ConfigProvider theme="dark" dualScaleControl tianDiTuLayer={{ apiKey: 'xxx' }}>
|
|
68
|
+
* <MapContainer>
|
|
69
|
+
* <MapContent />
|
|
70
|
+
* </MapContainer>
|
|
71
|
+
* </ConfigProvider>
|
|
72
|
+
*/
|
|
73
|
+
export { default as ConfigProvider, useConfig } from './components/ConfigProvider';
|
|
74
|
+
/**
|
|
75
|
+
* 地图内容组件
|
|
76
|
+
* @description 根据 ConfigProvider 配置自动渲染 DualScaleControl、TianDiTuLayer 和 MapSizeHandler
|
|
77
|
+
* @example
|
|
78
|
+
* <ConfigProvider dualScaleControl tianDiTuLayer={{ apiKey: 'xxx' }} mapSizeHandler>
|
|
79
|
+
* <MapContainer>
|
|
80
|
+
* <MapContent />
|
|
81
|
+
* </MapContainer>
|
|
82
|
+
* </ConfigProvider>
|
|
83
|
+
*/
|
|
84
|
+
export { default as MapContent } from './components/MapContent';
|
|
85
|
+
/**
|
|
86
|
+
* 地图尺寸处理器组件
|
|
87
|
+
* @description 解决地图容器尺寸变化后(如抽屉/对话框打开),地图不自动刷新的问题
|
|
88
|
+
* @example
|
|
89
|
+
* // 通过 ConfigProvider 配置(推荐)
|
|
90
|
+
* <ConfigProvider mapSizeHandler>
|
|
91
|
+
* <MapContainer>
|
|
92
|
+
* <MapContent />
|
|
93
|
+
* </MapContainer>
|
|
94
|
+
* </ConfigProvider>
|
|
95
|
+
*
|
|
96
|
+
* // 或直接使用
|
|
97
|
+
* <MapContainer>
|
|
98
|
+
* <MapSizeHandler />
|
|
99
|
+
* </MapContainer>
|
|
100
|
+
*/
|
|
101
|
+
export { default as MapSizeHandler } from './components/MapSizeHandler';
|
|
102
|
+
/**
|
|
103
|
+
* 地图标注组件
|
|
104
|
+
* @description 用于在地图上显示多个标注点,支持自定义图标
|
|
105
|
+
* @example
|
|
106
|
+
* <Marker
|
|
107
|
+
* icon="point"
|
|
108
|
+
* dataSource={[{ id: 1, position: [29.94, 117.90], title: '标注点1' }]}
|
|
109
|
+
* onClick={handleClick}
|
|
110
|
+
* />
|
|
111
|
+
*/
|
|
112
|
+
export { default as Marker } from './components/Marker';
|
|
113
|
+
/**
|
|
114
|
+
* 标注点编辑工具栏组件
|
|
115
|
+
* @description 提供标注点编辑功能的工具栏,包含新建、移动、删除等操作
|
|
116
|
+
*/
|
|
117
|
+
export { default as MarkerEditToolbar } from './components/Marker/toolbar';
|
|
118
|
+
/**
|
|
119
|
+
* 农机轨迹组件
|
|
120
|
+
* @description 用于在地图上显示农机作业轨迹,支持轨迹分段显示(路上/作业中不同颜色)、方向指示、轨迹选中等功能
|
|
121
|
+
* @example
|
|
122
|
+
* <Track
|
|
123
|
+
* data={trackData}
|
|
124
|
+
* showDirection={true}
|
|
125
|
+
* showStartEnd={true}
|
|
126
|
+
* onClick={(key, track) => console.log(key, track)}
|
|
127
|
+
* />
|
|
128
|
+
*/
|
|
129
|
+
export { default as Track } from './components/Track';
|
|
130
|
+
/**
|
|
131
|
+
* 小地图组件
|
|
132
|
+
* @description 在主地图上显示轨迹概览和当前视口位置的小地图,用于导航引导
|
|
133
|
+
* @example
|
|
134
|
+
* // 在 Track 组件中启用
|
|
135
|
+
* <Track dataSource={trackData} miniMap />
|
|
136
|
+
*
|
|
137
|
+
* // 自定义配置
|
|
138
|
+
* <Track
|
|
139
|
+
* dataSource={trackData}
|
|
140
|
+
* miniMap={{
|
|
141
|
+
* width: 200,
|
|
142
|
+
* height: 150,
|
|
143
|
+
* zoomOffset: -5,
|
|
144
|
+
* draggable: true,
|
|
145
|
+
* showTrackOverview: true,
|
|
146
|
+
* }}
|
|
147
|
+
* />
|
|
148
|
+
*/
|
|
149
|
+
export { default as MiniMap } from './components/MiniMap';
|
|
150
|
+
/**
|
|
151
|
+
* 田间道路组件
|
|
152
|
+
* @description 用于在地图上绘制和管理田间道路,支持新建、编辑、删除等编辑功能
|
|
153
|
+
*/
|
|
154
|
+
export { default as Road } from './components/Road';
|
|
155
|
+
/**
|
|
156
|
+
* 道路编辑工具栏组件
|
|
157
|
+
* @description 提供道路编辑功能的工具栏,包含新建、编辑、删除等操作
|
|
158
|
+
*/
|
|
159
|
+
export { default as RoadEditToolbar } from './components/Road/toolbar';
|
|
160
|
+
/**
|
|
161
|
+
* 工具栏按钮组件
|
|
162
|
+
* @description 提供统一样式的工具栏按钮,用于自定义工具栏内容
|
|
163
|
+
* @example
|
|
164
|
+
* ```tsx
|
|
165
|
+
* import { Marker, ToolbarButton } from 'agri-map-components';
|
|
166
|
+
*
|
|
167
|
+
* <Marker
|
|
168
|
+
* editMode={{
|
|
169
|
+
* enabled: ['create', 'move', 'delete'],
|
|
170
|
+
* toolbar: (
|
|
171
|
+
* <>
|
|
172
|
+
* <ToolbarButton variant="primary" onClick={() => console.log('自定义操作')}>
|
|
173
|
+
* 自定义按钮
|
|
174
|
+
* </ToolbarButton>
|
|
175
|
+
* </>
|
|
176
|
+
* )
|
|
177
|
+
* }}
|
|
178
|
+
* />
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export { default as ToolbarButton, type ToolbarButtonProps } from './components/shared/ToolbarButton';
|
|
182
|
+
/**
|
|
183
|
+
* 灌溉渠组件
|
|
184
|
+
* @description 用于在地图上绘制和管理灌溉渠,支持新建、编辑、删除等编辑功能,可显示流向箭头
|
|
185
|
+
*/
|
|
186
|
+
export { default as Irrigation } from './components/Irrigation';
|
|
187
|
+
/**
|
|
188
|
+
* 灌溉渠编辑工具栏组件
|
|
189
|
+
* @description 提供灌溉渠编辑功能的工具栏,包含新建、编辑、删除等操作
|
|
190
|
+
*/
|
|
191
|
+
export { default as IrrigationEditToolbar } from './components/Irrigation/toolbar';
|
|
192
|
+
/**
|
|
193
|
+
* Loading 加载组件
|
|
194
|
+
* @description 显示加载状态的组件,支持多种加载图标和自定义配置
|
|
195
|
+
* @example
|
|
196
|
+
* // 基础用法
|
|
197
|
+
* <Loading />
|
|
198
|
+
*
|
|
199
|
+
* // 自定义图标和描述
|
|
200
|
+
* <Loading icon="loading-dots" description="加载中..." />
|
|
201
|
+
*
|
|
202
|
+
* // 自定义尺寸
|
|
203
|
+
* <Loading size="large" />
|
|
204
|
+
* <Loading size={64} />
|
|
205
|
+
*
|
|
206
|
+
* // 在 Marker 中使用
|
|
207
|
+
* <Marker loading={true} />
|
|
208
|
+
*/
|
|
209
|
+
export { default as Loading } from './components/Loading';
|
|
210
|
+
/**
|
|
211
|
+
* SVG 图标组件库
|
|
212
|
+
* @description 统一的 SVG 图标组件,包含重绘、剪切、移动、删除、取消、保存、新建等图标
|
|
213
|
+
* @example
|
|
214
|
+
* import { PlotRedrawIcon, CreateIcon } from 'agri-map-components';
|
|
215
|
+
* // 或
|
|
216
|
+
* import Icons from 'agri-map-components';
|
|
217
|
+
* <Icons.Create />
|
|
218
|
+
*/
|
|
219
|
+
export { default as Icons, MarkerRedrawIcon, PlotRedrawIcon, RoadRedrawIcon, IrrigationRedrawIcon, ClipIcon, MoveIcon, DeleteIcon, CancelIcon, SaveIcon, CreateIcon, EditIcon, ReverseIcon } from './components/Icons';
|
|
220
|
+
/**
|
|
221
|
+
* 图标选择器组件
|
|
222
|
+
* @description 兼容 antd Form 的 value/onChange 接口,用于选择预设地图图标
|
|
223
|
+
* @example
|
|
224
|
+
* // antd Form 中使用
|
|
225
|
+
* import { SelectIcon } from 'agri-map-components';
|
|
226
|
+
* <Form.Item label="图标" name="icon">
|
|
227
|
+
* <SelectIcon />
|
|
228
|
+
* </Form.Item>
|
|
229
|
+
*
|
|
230
|
+
* // 独立使用
|
|
231
|
+
* const [icon, setIcon] = useState('marker-blue');
|
|
232
|
+
* <SelectIcon value={icon} onChange={setIcon} allowClear />
|
|
233
|
+
*/
|
|
234
|
+
export { SelectIcon, IconPreview, DEFAULT_ICON_GROUPS } from './components/Icons/SelectIcon';
|
|
235
|
+
export type { SelectIconProps, IconPreviewProps, IconGroupItem, IconGroup } from './components/Icons/SelectIcon';
|
|
236
|
+
/**
|
|
237
|
+
* 图标工具函数
|
|
238
|
+
* @description 统一的图标检测和处理工具
|
|
239
|
+
* @example
|
|
240
|
+
* import { detectIconType, PRESET_ICONS } from 'agri-map-components';
|
|
241
|
+
* const result = detectIconType('marker-blue'); // { type: 'preset', value: 'marker-blue' }
|
|
242
|
+
*/
|
|
243
|
+
export { detectIconType, PRESET_ICONS, isUrlIcon, isPresetIcon, generateSvgHtml, PULSE_ICONS } from './utils/iconUtils';
|
|
244
|
+
export { generateTractorSvg, generateTractor2Svg } from './utils/iconCache';
|
|
245
|
+
export { generatePulseSvg } from './utils/pulseIcon';
|
|
246
|
+
/**
|
|
247
|
+
* 面积计算工具
|
|
248
|
+
* @description 包含面积计算、单位转换、格式化等函数
|
|
249
|
+
*/
|
|
250
|
+
export { calculatePolygonArea, convertArea, formatArea, getAreaUnitConfig, AREA_UNIT_CONFIGS, computeDataBounds } from './utils/area';
|
|
251
|
+
/**
|
|
252
|
+
* 常量配置
|
|
253
|
+
* @description 地图组件库的常量定义
|
|
254
|
+
*/
|
|
255
|
+
export * from './constants';
|
|
256
|
+
/**
|
|
257
|
+
* 工具函数
|
|
258
|
+
* @description 包含地图相关的计算和判断工具函数
|
|
259
|
+
*/
|
|
260
|
+
export * from './utils';
|
|
261
|
+
/**
|
|
262
|
+
* 双向标尺配置类型
|
|
263
|
+
* @description DualScaleControl 组件的 config 属性配置
|
|
264
|
+
* @property metric - 是否显示公制单位(km/m/cm),默认 true
|
|
265
|
+
* @property imperial - 是否显示英制单位(mi/ft/in),默认 false
|
|
266
|
+
* @property showZoomControl - 是否显示缩放控件(放大/缩小按钮和缩放级别),默认 true
|
|
267
|
+
* @example
|
|
268
|
+
* const config: DualScaleControlConfig = {
|
|
269
|
+
* metric: true, // 显示公制单位
|
|
270
|
+
* imperial: false, // 不显示英制单位
|
|
271
|
+
* showZoomControl: true // 显示缩放控件
|
|
272
|
+
* };
|
|
273
|
+
* <DualScaleControl config={config} />
|
|
274
|
+
*/
|
|
275
|
+
export type { DualScaleControlConfig } from './types';
|
|
276
|
+
/**
|
|
277
|
+
* 天地图图层配置类型
|
|
278
|
+
* @description ConfigProvider 的 tianDiTuLayer 属性配置
|
|
279
|
+
* @property apiKey - 天地图 API Key(必填)
|
|
280
|
+
* @property layerType - 图层类型:vector(矢量) | satellite(卫星) | terrain(地形),默认 vector
|
|
281
|
+
* @property showAnnotation - 是否显示标注图层,默认 true
|
|
282
|
+
* @property overlayUrl - 自定义瓦片叠加层 URL
|
|
283
|
+
* @property subdomains - 瓦片服务子域名
|
|
284
|
+
* @property maxZoom - 最大缩放级别
|
|
285
|
+
* @property minZoom - 最小缩放级别
|
|
286
|
+
* @example
|
|
287
|
+
* const config: TianDiTuLayerConfig = {
|
|
288
|
+
* apiKey: 'your-api-key',
|
|
289
|
+
* layerType: 'satellite',
|
|
290
|
+
* showAnnotation: true,
|
|
291
|
+
* overlayUrl: 'https://example.com/tile/{z}/{x}/{y}.png'
|
|
292
|
+
* };
|
|
293
|
+
*/
|
|
294
|
+
export type { TianDiTuLayerConfig } from './types';
|
|
295
|
+
/**
|
|
296
|
+
* 地图尺寸处理器配置类型
|
|
297
|
+
* @description ConfigProvider 的 mapSizeHandler 属性配置
|
|
298
|
+
* @property enabled - 是否启用,默认 true
|
|
299
|
+
* @property delay - 首次刷新的延迟时间(毫秒),默认 100
|
|
300
|
+
* @property retries - 重试次数,默认 3
|
|
301
|
+
* @example
|
|
302
|
+
* const config: MapSizeHandlerConfig = {
|
|
303
|
+
* enabled: true,
|
|
304
|
+
* delay: 200,
|
|
305
|
+
* retries: 5
|
|
306
|
+
* };
|
|
307
|
+
* <ConfigProvider mapSizeHandler={config}>
|
|
308
|
+
* ...
|
|
309
|
+
* </ConfigProvider>
|
|
310
|
+
*/
|
|
311
|
+
export type { MapSizeHandlerConfig } from './types';
|
|
312
|
+
export type { Coordinate, BoundingBox, PathOptions, PlotType, PlotStatus, PlotData, PlotStyle, PlotEditMode, PlotEditResult, PlotClipResult, PlotMoveResult, PlotCreateResult, PlotDeleteResult, RenderStats, PlotLayerProps, PlotRef, PlotFieldNames, PlotGroupConfig, GroupRenderStats, PlotGroupLayerProps, PlotGroupRef, MarkerData, MarkerIconOptions, MarkerCreateResult, MarkerMoveResult, MarkerDeleteResult, MarkerEditResult, MarkerProps, MarkerRef, MarkerEditModeConfig, MarkerEvents, RoadData, RoadCreateResult, RoadEditResult, RoadDeleteResult, RoadProps, RoadRef, RoadEditModeConfig, RoadEvents, IrrigationFieldNames, IrrigationData, IrrigationCreateResult, IrrigationEditResult, IrrigationDeleteResult, IrrigationReverseResult, IrrigationProps, IrrigationRef, IrrigationEvents, DecoratorConfig, LayerType, TianDiTuLayerProps, ConfigContextValue, ConfigProviderProps, DualScaleControlProps, MapContentProps, NotificationType, NotificationOptions, NotificationInstance, NotificationProps, PlotEditToolbarProps, MarkerEditToolbarProps, RoadEditToolbarProps, IrrigationEditToolbarProps, PlotLabelProps, TrackData, TrackProps, TrackRef, TrackPoint, MiniMapProps, LoadingIconName, LoadingSize, LoadingMaskConfig, LoadingProps, LengthUnit, MeasurementAreaUnit, MeasurementMode, MeasurementControlPosition, MeasurementToolbarProps, MeasurementData, UnitConfig, } from './types';
|
|
@@ -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,UAAU,EACV,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,UAAU,GACX,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基础类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 坐标点
|
|
6
|
+
* @description 纬度和经度组成的元组 [lat, lng]
|
|
7
|
+
* @example [30.0, 120.0]
|
|
8
|
+
*/
|
|
9
|
+
export type Coordinate = [number, number];
|
|
10
|
+
/**
|
|
11
|
+
* 坐标数组类型
|
|
12
|
+
* @description 二维坐标数组 [[lat,lng],...] 或三维坐标数组 [[[lat,lng],...], [孔洞], ...]
|
|
13
|
+
*/
|
|
14
|
+
export type Positions2D = Coordinate[];
|
|
15
|
+
export type Positions3D = Coordinate[][];
|
|
16
|
+
/**
|
|
17
|
+
* 判断坐标数组是否为三维数组(GeoJSON 格式:[[外环], [孔洞1], ...])
|
|
18
|
+
* @param positions 待检测的坐标数组
|
|
19
|
+
* @returns true 表示三维数组,false 表示二维数组或无效
|
|
20
|
+
*/
|
|
21
|
+
export declare function is3DPositions(positions: unknown): positions is Positions3D;
|
|
22
|
+
/**
|
|
23
|
+
* 边界框
|
|
24
|
+
* @description 地图边界范围 [南纬, 西经, 北纬, 东经]
|
|
25
|
+
* @example [29.9, 119.9, 30.1, 120.1]
|
|
26
|
+
*/
|
|
27
|
+
export type BoundingBox = [number, number, number, number];
|
|
28
|
+
/**
|
|
29
|
+
* 路径样式选项
|
|
30
|
+
* @description 用于配置线条、多边形等图形的样式
|
|
31
|
+
*/
|
|
32
|
+
export interface PathOptions {
|
|
33
|
+
/** 边框颜色 */
|
|
34
|
+
color?: string;
|
|
35
|
+
/** 填充颜色 */
|
|
36
|
+
fillColor?: string;
|
|
37
|
+
/** 边框宽度(像素) */
|
|
38
|
+
weight?: number;
|
|
39
|
+
/** 边框透明度 (0-1) */
|
|
40
|
+
opacity?: number;
|
|
41
|
+
/** 填充透明度 (0-1) */
|
|
42
|
+
fillOpacity?: number;
|
|
43
|
+
/** 虚线模式,如 '5, 10' 或 [5, 10] */
|
|
44
|
+
dashArray?: string | number[];
|
|
45
|
+
/** 自定义 CSS 类名 */
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 地块类型
|
|
50
|
+
* @description 农业地块的分类类型
|
|
51
|
+
*/
|
|
52
|
+
export type PlotType = 'farmland' | 'vegetable' | 'orchard' | 'forest' | 'grassland' | 'paddy' | 'greenhouse';
|
|
53
|
+
/**
|
|
54
|
+
* 地块状态
|
|
55
|
+
* @description 地块的当前耕作状态
|
|
56
|
+
*/
|
|
57
|
+
export type PlotStatus = 'cultivating' | 'fallow' | 'harvesting' | 'planting' | 'irrigating';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../src/types/basic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AACvC,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,EAAE,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,WAAW,CAI1E;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,YAAY,CAAC;AAE9G;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC"}
|