@xingm/vmap-cesium-toolbar 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ declare class DrawHelper {
30
30
  private currentDrawer;
31
31
  private screenSpaceEventHandler;
32
32
  private entityClickHandler;
33
+ private readonly pickGovernor;
33
34
  private terrainRefineQueue;
34
35
  private terrainRefineInFlight;
35
36
  private terrainRefineLastTick;
@@ -80,11 +80,11 @@ export interface MapType {
80
80
  id: string;
81
81
  name: string;
82
82
  nameKey?: string;
83
- /** 选中态左上角“地名”文案(可选,未配置时走 i18n 默认 key) */
83
+ /** 选中态左上角“路网”文案(可选,未配置时走 i18n 默认 key) */
84
84
  placeNameLabel?: string;
85
- /** 选中态左上角“地名”文案 i18n key(可选) */
85
+ /** 选中态左上角“路网”文案 i18n key(可选) */
86
86
  placeNameLabelKey?: string;
87
- /** 是否强制始终显示地名层(不受 placeName 开关影响) */
87
+ /** 是否强制始终显示路网层(不受 placeName 开关影响) */
88
88
  forcePlaceName?: boolean;
89
89
  thumbnail: string;
90
90
  provider: (token: string) => Cesium.ImageryProvider[];
@@ -23,6 +23,12 @@ export interface CesiumOverlayServiceOptions {
23
23
  * 参数为“已回写后的覆盖物 entity”。
24
24
  */
25
25
  onOverlayEditChange?: (entity: DrawEntity & OverlayEntity) => void;
26
+ /**
27
+ * 点击 pick 节流间隔(毫秒)。
28
+ * 用于降低 “贴地几何 + pick + ground pipeline” 的偶发 DataCloneError 风险。
29
+ * @default 120
30
+ */
31
+ clickPickMinIntervalMs?: number;
26
32
  }
27
33
  /**
28
34
  * Cesium 覆盖物服务类
@@ -42,12 +48,11 @@ export declare class CesiumOverlayService {
42
48
  private hoverPickPos;
43
49
  private overlayMutationRevision;
44
50
  private hoverSuspendUntil;
45
- private lastHoverPickTime;
46
- private lastHoverPickPos;
47
51
  private bulkUpdateDepth;
48
- private static readonly HOVER_PICK_MIN_INTERVAL_MS;
49
- private static readonly HOVER_PICK_MIN_MOVE_PX;
52
+ private readonly clickPickMinIntervalMs;
53
+ private readonly pickGovernor;
50
54
  private static readonly HOVER_SUSPEND_AFTER_MUTATION_MS;
55
+ private static readonly CLICK_PICK_MIN_INTERVAL_MS;
51
56
  private markOverlayMutated;
52
57
  /**
53
58
  * 显式开始一次批量更新:在 begin/end 期间暂停 hover pick。
@@ -66,6 +66,7 @@ export interface PointClusterLayerOptions {
66
66
  }
67
67
  export default class CesiumPointClusterLayer {
68
68
  private static readonly CLUSTER_STYLE_MIN_INTERVAL_MS;
69
+ private static readonly CLICK_PICK_MIN_INTERVAL_MS;
69
70
  private viewer;
70
71
  private readonly options;
71
72
  private dataSource;
@@ -76,6 +77,7 @@ export default class CesiumPointClusterLayer {
76
77
  private clusterStyleRAF;
77
78
  private clusterStyleTimer;
78
79
  private lastClusterStyleFlushTime;
80
+ private readonly pickGovernor;
79
81
  constructor(viewer: Viewer, options?: PointClusterLayerOptions);
80
82
  /** 设置/替换点数据(经纬度单位:度) */
81
83
  setData(points: ClusterPoint[]): void;
@@ -0,0 +1,23 @@
1
+ export type PickGovernorKind = 'hover' | 'click' | 'cluster' | 'draw' | 'edit';
2
+ export interface PickGovernorProfile {
3
+ minIntervalMs: number;
4
+ minMovePx: number;
5
+ }
6
+ export interface PickGovernorOptions {
7
+ profiles?: Partial<Record<PickGovernorKind, Partial<PickGovernorProfile>>>;
8
+ }
9
+ type PointLike = {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ export declare function isMacPlatform(): boolean;
14
+ export declare class PickGovernor {
15
+ private readonly profiles;
16
+ private readonly lastByKind;
17
+ private suspendUntil;
18
+ constructor(options?: PickGovernorOptions);
19
+ shouldPick(kind: PickGovernorKind, point: PointLike, nowMs?: number): boolean;
20
+ suspend(ms: number): void;
21
+ private isFinitePoint;
22
+ }
23
+ export {};
@@ -9,6 +9,7 @@ export declare class DrawLine extends BaseDraw {
9
9
  private currentTotalLabel;
10
10
  private currentLinePositions;
11
11
  private isTotalLabelWarmedUp;
12
+ private readonly avoidGroundPipeline;
12
13
  /**
13
14
  * 清理当前线段/总距离标签(不影响线实体本身)
14
15
  */
@@ -32,6 +32,9 @@ declare const enUS: {
32
32
  overlay: {
33
33
  airport: string;
34
34
  };
35
+ map_type: {
36
+ place_name: string;
37
+ };
35
38
  };
36
39
  map_type: {
37
40
  normal: string;
@@ -32,6 +32,9 @@ declare const zhCN: {
32
32
  overlay: {
33
33
  airport: string;
34
34
  };
35
+ map_type: {
36
+ place_name: string;
37
+ };
35
38
  };
36
39
  map_type: {
37
40
  normal: string;
@@ -29,6 +29,8 @@ export interface CircleOptions {
29
29
  * - false:填充与边框都使用 position 高度悬空。
30
30
  */
31
31
  clampToGround?: boolean;
32
+ /** 贴地抬高量(米,clampToGround=true 时生效) */
33
+ groundHeightEpsilon?: number;
32
34
  heightReference?: HeightReference;
33
35
  extrudedHeight?: number;
34
36
  heightEpsilon?: number;
@@ -23,6 +23,8 @@ export interface PolygonOptions {
23
23
  * - false:填充与边框都在统一的 baseHeight 上悬空。
24
24
  */
25
25
  clampToGround?: boolean;
26
+ /** 贴地抬高量(米,clampToGround=true 时生效) */
27
+ groundHeightEpsilon?: number;
26
28
  heightReference?: HeightReference;
27
29
  extrudedHeight?: number;
28
30
  /** 点击该覆盖物时是否高亮显示(默认 false)。支持传入自定义颜色等参数 */
@@ -9,6 +9,8 @@ export interface PolylineOptions {
9
9
  width?: number;
10
10
  material?: Cesium.MaterialProperty | Color | string;
11
11
  clampToGround?: boolean;
12
+ /** 贴地抬高量(米,clampToGround=true 时生效) */
13
+ groundHeightEpsilon?: number;
12
14
  /** 点击该覆盖物时是否高亮显示(默认 false)。支持传入自定义颜色等参数 */
13
15
  clickHighlight?: boolean | {
14
16
  color?: Color | string;
@@ -28,6 +30,7 @@ export interface PolylineOptions {
28
30
  export declare class MapPolyline {
29
31
  private viewer;
30
32
  private entities;
33
+ private readonly avoidGroundPipeline;
31
34
  constructor(viewer: Viewer);
32
35
  /**
33
36
  * 转换位置为 Cartesian3
@@ -41,6 +44,7 @@ export declare class MapPolyline {
41
44
  * 解析材质
42
45
  */
43
46
  private resolveMaterial;
47
+ private elevatePositions;
44
48
  /**
45
49
  * 添加 Polyline(折线)
46
50
  */
@@ -19,6 +19,8 @@ export interface RectangleOptions {
19
19
  outlineWidth?: number;
20
20
  /** 是否贴地(默认:在粗边框模式下为 true) */
21
21
  clampToGround?: boolean;
22
+ /** 贴地抬高量(米,clampToGround=true 时生效) */
23
+ groundHeightEpsilon?: number;
22
24
  /** 悬空时的基准高度(米,clampToGround=false 时有效) */
23
25
  height?: number;
24
26
  heightReference?: HeightReference;
@@ -36,6 +36,8 @@ export interface RingOptions {
36
36
  glowPower?: number;
37
37
  /** 是否贴地(默认 true) */
38
38
  clampToGround?: boolean;
39
+ /** 贴地抬高量(米,clampToGround=true 时生效) */
40
+ groundHeightEpsilon?: number;
39
41
  /** 圆环分段数(默认 128),越大越圆滑 */
40
42
  segments?: number;
41
43
  /** 覆盖物点击回调 */
@@ -93,7 +95,7 @@ export declare class MapRing {
93
95
  /**
94
96
  * 更新 Ring 样式
95
97
  */
96
- updateStyle(entity: Entity, options: Partial<Pick<RingOptions, "color" | "showInnerLine" | "lineColor" | "lineStyle" | "lineMaterialMode" | "stripeRepeat" | "dashLength" | "dashPattern" | "gapColor" | "width" | "glowWidth" | "lineWidth" | "glowPower" | "clampToGround" | "segments">>): void;
98
+ updateStyle(entity: Entity, options: Partial<Pick<RingOptions, "color" | "showInnerLine" | "lineColor" | "lineStyle" | "lineMaterialMode" | "stripeRepeat" | "dashLength" | "dashPattern" | "gapColor" | "width" | "glowWidth" | "lineWidth" | "glowPower" | "clampToGround" | "segments" | "groundHeightEpsilon">>): void;
97
99
  /**
98
100
  * 显示/隐藏 Ring
99
101
  */
@@ -1,6 +1,7 @@
1
1
  import { Viewer } from '../../../node_modules/cesium';
2
2
  import { DrawEntity } from '../drawHelper';
3
3
  import { OverlayEntity } from './types';
4
+ import { OverlayEditOptions } from './OverlayEditHandles';
4
5
  import * as Cesium from "cesium";
5
6
  export type OverlayEditChangeCallback = (entity: DrawEntity & OverlayEntity) => void;
6
7
  export interface OverlayEditControllerOptions {
@@ -9,6 +10,8 @@ export interface OverlayEditControllerOptions {
9
10
  * 回调参数为“已回写后的覆盖物 entity”。
10
11
  */
11
12
  onChange?: OverlayEditChangeCallback;
13
+ /** 编辑功能配置项,默认为全开(除 rotate) */
14
+ editCapabilities?: OverlayEditOptions;
12
15
  }
13
16
  export interface OverlayEditHost {
14
17
  getViewer(): Viewer;
@@ -27,13 +30,19 @@ export interface OverlayEditHost {
27
30
  applyPolylinePositions(entity: DrawEntity & OverlayEntity, positions: Cesium.Cartesian3[]): void;
28
31
  applyPointPosition(entity: DrawEntity & OverlayEntity, position: Cesium.Cartesian3): void;
29
32
  }
33
+ /**
34
+ * 覆盖物编辑控制器类,用于管理地图上覆盖物的编辑操作
35
+ * 支持多边形、矩形、圆形、折线和点等类型的编辑
36
+ */
30
37
  export declare class OverlayEditController {
31
38
  private readonly host;
32
39
  private enabled;
33
40
  private handler;
41
+ private readonly pickGovernor;
34
42
  private onChange;
35
43
  private editingTarget;
36
44
  private editingKind;
45
+ private editingOptions;
37
46
  private editingPositions;
38
47
  private editingCircleCenter;
39
48
  private editingCircleRadiusMeters;
@@ -49,11 +58,35 @@ export declare class OverlayEditController {
49
58
  private rotateStartAngle;
50
59
  private scaleStartDistance;
51
60
  private cameraBackup;
61
+ /**
62
+ * 构造函数
63
+ * @param host 覆盖物编辑宿主对象
64
+ * @param options 配置选项
65
+ */
52
66
  constructor(host: OverlayEditHost, options?: OverlayEditControllerOptions);
67
+ /**
68
+ * 设置编辑变化回调函数
69
+ * @param cb 回调函数
70
+ */
53
71
  setOnChange(cb?: OverlayEditChangeCallback | null): void;
72
+ /**
73
+ * 设置编辑器启用状态
74
+ * @param enabled 是否启用
75
+ */
54
76
  setEnabled(enabled: boolean): void;
77
+ /**
78
+ * 获取编辑器启用状态
79
+ * @returns 是否启用
80
+ */
55
81
  getEnabled(): boolean;
82
+ /**
83
+ * 判断是否正在编辑
84
+ * @returns 是否正在编辑
85
+ */
56
86
  isEditing(): boolean;
87
+ /**
88
+ * 销毁编辑器
89
+ */
57
90
  destroy(): void;
58
91
  /** 停止当前正在编辑的覆盖物(不会关闭全局编辑模式) */
59
92
  stop(): void;
@@ -61,7 +94,12 @@ export declare class OverlayEditController {
61
94
  * 主动开始编辑某个覆盖物。
62
95
  * @returns true 表示成功进入编辑
63
96
  */
64
- start(entityOrId: (DrawEntity & OverlayEntity) | string): boolean;
97
+ start(entityOrId: (DrawEntity & OverlayEntity) | string, options?: OverlayEditOptions): boolean;
98
+ /**
99
+ * 解析编辑目标实体,根据特定条件返回合适的实体对象
100
+ * @param entity 输入的实体对象,需要同时满足DrawEntity和OverlayEntity类型
101
+ * @returns 返回解析后的实体对象,可能是原始实体或符合条件的其他实体
102
+ */
65
103
  private resolveEditTarget;
66
104
  private detectEditableKind;
67
105
  private getPropertyValue;
@@ -95,6 +133,10 @@ export declare class OverlayEditController {
95
133
  private lockCameraController;
96
134
  private restoreCameraController;
97
135
  private clearHandles;
136
+ /**
137
+ * 重建处理句柄的方法
138
+ * 根据当前编辑的几何图形类型,调用相应的构建函数创建处理句柄
139
+ */
98
140
  private rebuildHandles;
99
141
  private getHandleHelpers;
100
142
  private createHandle;
@@ -11,6 +11,44 @@ export type HandleStyle = {
11
11
  * 创建编辑句柄实体
12
12
  */
13
13
  export type CreateHandle = (position: Cesium.Cartesian3, style: HandleStyle, meta: any) => Cesium.Entity;
14
+ export interface OverlayEditOptions {
15
+ vertex: {
16
+ enable?: boolean;
17
+ color?: Cesium.Color;
18
+ outlineColor?: Cesium.Color;
19
+ outlineWidth?: number;
20
+ pixelSize?: number;
21
+ } | boolean;
22
+ mid: {
23
+ enable?: boolean;
24
+ color?: Cesium.Color;
25
+ outlineColor?: Cesium.Color;
26
+ outlineWidth?: number;
27
+ pixelSize?: number;
28
+ } | boolean;
29
+ move: {
30
+ enable?: boolean;
31
+ color?: Cesium.Color;
32
+ outlineColor?: Cesium.Color;
33
+ outlineWidth?: number;
34
+ pixelSize?: number;
35
+ } | boolean;
36
+ rotate: {
37
+ enable?: boolean;
38
+ color?: Cesium.Color;
39
+ outlineColor?: Cesium.Color;
40
+ outlineWidth?: number;
41
+ pixelSize?: number;
42
+ } | boolean;
43
+ scale: {
44
+ enable?: boolean;
45
+ color?: Cesium.Color;
46
+ outlineColor?: Cesium.Color;
47
+ outlineWidth?: number;
48
+ pixelSize?: number;
49
+ } | boolean;
50
+ }
51
+ export declare const DEFAULT_OPTIONS: OverlayEditOptions;
14
52
  /**
15
53
  * 构建/更新句柄所需的依赖函数集合
16
54
  */
@@ -24,23 +62,23 @@ export interface HandleHelpers {
24
62
  /**
25
63
  * 构建多边形编辑句柄(顶点/中点/整体移动)
26
64
  */
27
- export declare function buildPolygonHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers): Cesium.Entity[];
65
+ export declare function buildPolygonHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers, options: OverlayEditOptions): Cesium.Entity[];
28
66
  /**
29
67
  * 构建矩形编辑句柄(顶点/边中点/整体移动)
30
68
  */
31
- export declare function buildRectangleHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers): Cesium.Entity[];
69
+ export declare function buildRectangleHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers, options: OverlayEditOptions): Cesium.Entity[];
32
70
  /**
33
71
  * 构建折线编辑句柄(顶点/中点/整体移动/旋转/缩放)
34
72
  */
35
- export declare function buildPolylineHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers): Cesium.Entity[];
73
+ export declare function buildPolylineHandles(verts: Cesium.Cartesian3[], helpers: HandleHelpers, options: OverlayEditOptions): Cesium.Entity[];
36
74
  /**
37
75
  * 构建点编辑句柄
38
76
  */
39
- export declare function buildPointHandles(pos: Cesium.Cartesian3 | null, helpers: HandleHelpers): Cesium.Entity[];
77
+ export declare function buildPointHandles(pos: Cesium.Cartesian3 | null, helpers: HandleHelpers, options: OverlayEditOptions): Cesium.Entity[];
40
78
  /**
41
79
  * 构建圆形编辑句柄(圆心/半径)
42
80
  */
43
- export declare function buildCircleHandles(center: Cesium.Cartesian3 | null, radiusMeters: number, helpers: HandleHelpers): Cesium.Entity[];
81
+ export declare function buildCircleHandles(center: Cesium.Cartesian3 | null, radiusMeters: number, helpers: HandleHelpers, options: OverlayEditOptions): Cesium.Entity[];
44
82
  /**
45
83
  * 更新多边形句柄位置
46
84
  * @returns false 表示句柄数量不匹配,需重建
@@ -36,6 +36,7 @@ export declare class CirclePrimitiveBatch {
36
36
  setColors(circleId: string, ringColor: Cesium.Color, fillColor: Cesium.Color): void;
37
37
  private scheduleApplyColors;
38
38
  private scheduleRebuild;
39
+ private assertCloneableInstanceId;
39
40
  private rebuild;
40
41
  private applyCurrentColors;
41
42
  }
@@ -37,6 +37,7 @@ export declare class PolygonPrimitiveBatch {
37
37
  private scheduleApplyColors;
38
38
  setBorderWidth(polygonId: string, borderWidth: number): void;
39
39
  private scheduleRebuild;
40
+ private assertCloneableInstanceId;
40
41
  private rebuild;
41
42
  private applyCurrentColors;
42
43
  }
@@ -35,6 +35,7 @@ export declare class RectanglePrimitiveBatch {
35
35
  setColors(rectangleId: string, ringColor: Cesium.Color, fillColor: Cesium.Color): void;
36
36
  private scheduleApplyColors;
37
37
  private scheduleRebuild;
38
+ private assertCloneableInstanceId;
38
39
  private rebuild;
39
40
  private applyCurrentColors;
40
41
  }
@@ -87,6 +87,8 @@ export interface OverlayEntity extends Entity {
87
87
  _clampToGround?: boolean;
88
88
  /** 复合形状的基准高度(米,clampToGround=false 时有效) */
89
89
  _baseHeight?: number;
90
+ /** 贴地抬高量(米,clampToGround=true 时有效) */
91
+ _groundHeightEpsilon?: number;
90
92
  _isThickOutline?: boolean;
91
93
  _outlineWidth?: number;
92
94
  _isRing?: boolean;
@@ -35,7 +35,7 @@ export declare class MapLayersService {
35
35
  private useI18n;
36
36
  constructor(viewer: Viewer, toolbarElement: HTMLElement, config: MapLayersServiceConfig);
37
37
  /**
38
- * 初始化当前地图上下文:用于“初始底图不是通过 switchMapType 加载”时的地名层识别。
38
+ * 初始化当前地图上下文:用于“初始底图不是通过 switchMapType 加载”时的路网层识别。
39
39
  */
40
40
  private bootstrapCurrentMapContext;
41
41
  /**
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingm/vmap-cesium-toolbar",
3
- "version": "0.0.4",
3
+ "version": "0.0.4-alpha.2",
4
4
  "description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
5
5
  "type": "module",
6
6
  "main": "index.es.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingm/vmap-cesium-toolbar",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",