@xingm/vmap-cesium-toolbar 0.0.1-beta.8 → 0.0.1-beta.9

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.
@@ -19,6 +19,9 @@ declare class DrawHelper {
19
19
  private finishedPointEntities;
20
20
  private publicEntities;
21
21
  private _doubleClickPending;
22
+ private currentLineEntity;
23
+ private currentSegmentLabels;
24
+ private currentTotalLabel;
22
25
  private screenSpaceEventHandler;
23
26
  private onDrawStartCallback;
24
27
  private onDrawEndCallback;
@@ -129,6 +132,13 @@ declare class DrawHelper {
129
132
  private calculateRectangleArea;
130
133
  private calculatePolygonArea;
131
134
  private calculatePolygonCenter;
135
+ /**
136
+ * 格式化距离显示
137
+ * 超过1000m时转换为km,保留两位小数
138
+ * @param distance 距离(米)
139
+ * @returns 格式化后的距离字符串
140
+ */
141
+ private formatDistance;
132
142
  /**
133
143
  * 设置开始绘制时的回调函数
134
144
  * @param callback 回调函数
@@ -172,6 +182,11 @@ declare class DrawHelper {
172
182
  name?: string;
173
183
  groundHeight?: number;
174
184
  }): Cesium.Entity;
185
+ /**
186
+ * 更新所有已完成实体以适应场景模式变化
187
+ * 当从2D切换到3D或从3D切换到2D时,需要更新实体的高度参考和位置
188
+ */
189
+ private updateFinishedEntitiesForModeChange;
175
190
  /**
176
191
  * 销毁工具,清理所有事件监听器
177
192
  */
@@ -19,6 +19,7 @@ interface InitOptions {
19
19
  sceneModePicker?: boolean;
20
20
  timeline?: boolean;
21
21
  animation?: boolean;
22
+ isFly?: boolean;
22
23
  baseLayerPicker?: boolean;
23
24
  navigationInstructionsInitiallyVisible?: boolean;
24
25
  clock?: Cesium.Clock;
@@ -43,6 +43,7 @@ export interface CustomButtonConfig {
43
43
  activeColor?: string;
44
44
  backgroundColor?: string;
45
45
  activeIcon?: string | HTMLElement | false;
46
+ callback?: () => void;
46
47
  onClick?: (buttonId: string, buttonElement: HTMLElement) => void;
47
48
  }
48
49
  export interface SearchCallback {
@@ -18,6 +18,8 @@ export declare class CesiumMapToolbar {
18
18
  private currentMapType;
19
19
  TD_Token: string;
20
20
  mapTypes: MapType[];
21
+ private noFlyZoneEntities;
22
+ private isNoFlyZoneVisible;
21
23
  constructor(viewer: Viewer, container: HTMLElement, config?: ToolbarConfig, callbacks?: {
22
24
  search?: SearchCallback;
23
25
  measurement?: MeasurementCallback;
@@ -69,6 +71,13 @@ export declare class CesiumMapToolbar {
69
71
  * 设置绘图助手回调
70
72
  */
71
73
  private setupDrawHelperCallbacks;
74
+ /**
75
+ * 格式化距离显示
76
+ * 超过1000m时转换为km,保留两位小数
77
+ * @param distance 距离(米)
78
+ * @returns 格式化后的距离字符串
79
+ */
80
+ private formatDistance;
72
81
  /**
73
82
  * 计算多边形面积
74
83
  */
@@ -109,6 +118,10 @@ export declare class CesiumMapToolbar {
109
118
  * 按钮鼠标离开时关闭菜单
110
119
  */
111
120
  private closeMenuOnButtonLeave;
121
+ /**
122
+ * 关闭搜索框
123
+ */
124
+ private closeSearchContainer;
112
125
  /**
113
126
  * 处理按钮点击
114
127
  */
@@ -153,6 +166,16 @@ export declare class CesiumMapToolbar {
153
166
  * 复位到初始位置
154
167
  */
155
168
  private resetLocation;
169
+ /**
170
+ * 获取当前地图层级
171
+ * @returns 当前层级(1-18)
172
+ */
173
+ private getCurrentZoomLevel;
174
+ /**
175
+ * 设置地图层级
176
+ * @param zoomLevel 目标层级(1-18)
177
+ */
178
+ private setZoomLevel;
156
179
  /**
157
180
  * 放大
158
181
  */
@@ -173,6 +196,27 @@ export declare class CesiumMapToolbar {
173
196
  * 退出全屏
174
197
  */
175
198
  private exitFullscreen;
199
+ /**
200
+ * 加载并显示机场禁飞区
201
+ */
202
+ showNoFlyZones(): Promise<void>;
203
+ /**
204
+ * 隐藏机场禁飞区
205
+ */
206
+ hideNoFlyZones(): void;
207
+ /**
208
+ * 切换机场禁飞区显示状态
209
+ */
210
+ toggleNoFlyZones(): Promise<void>;
211
+ /**
212
+ * 获取禁飞区显示状态
213
+ */
214
+ getNoFlyZoneVisible(): boolean;
215
+ /**
216
+ * 自动加载禁飞区(如果默认勾选)
217
+ * 在创建 toolbar 后自动调用
218
+ */
219
+ private autoLoadNoFlyZones;
176
220
  /**
177
221
  * 销毁工具栏
178
222
  */
package/dist/package.json CHANGED
@@ -10,7 +10,8 @@
10
10
  "index.js",
11
11
  "index.d.ts",
12
12
  "style.css",
13
- "README.md"
13
+ "README.md",
14
+ "geojson"
14
15
  ],
15
16
  "exports": {
16
17
  ".": {
@@ -1 +1,13 @@
1
1
  export declare function getViteTdToken(): any;
2
+ /**
3
+ * 将相机高度转换为地图层级
4
+ * @param height 相机高度(米)
5
+ * @returns 地图层级(1-18)
6
+ */
7
+ export declare function heightToZoomLevel(height: number): number;
8
+ /**
9
+ * 将地图层级转换为相机高度
10
+ * @param zoomLevel 地图层级(1-18)
11
+ * @returns 相机高度(米)
12
+ */
13
+ export declare function zoomLevelToHeight(zoomLevel: number): number;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * GeoJSON 类型定义
3
+ */
4
+ export interface GeoJSONPoint {
5
+ type: 'Point';
6
+ coordinates: [number, number];
7
+ }
8
+ export interface GeoJSONPolygon {
9
+ type: 'Polygon';
10
+ coordinates: number[][][];
11
+ }
12
+ export interface GeoJSONFeature<T = GeoJSONPolygon> {
13
+ type: 'Feature';
14
+ geometry: T;
15
+ properties?: Record<string, any>;
16
+ }
17
+ export interface GeoJSONFeatureCollection<T = GeoJSONPolygon> {
18
+ type: 'FeatureCollection';
19
+ features: GeoJSONFeature<T>[];
20
+ name?: string;
21
+ }
22
+ /**
23
+ * 机场禁飞区数据接口
24
+ */
25
+ export interface AirportNoFlyZone {
26
+ name: string;
27
+ feature: GeoJSONFeature<GeoJSONPolygon>;
28
+ fileName: string;
29
+ }
30
+ /**
31
+ * GeoJSON 加载配置
32
+ */
33
+ export interface GeoJSONLoaderConfig {
34
+ /**
35
+ * GeoJSON 文件的基础路径
36
+ * 开发环境: '/geojson' (指向 public/geojson)
37
+ * 生产环境: 可以是 '/geojson' 或用户自定义路径
38
+ * @default '/geojson'
39
+ */
40
+ basePath?: string;
41
+ /**
42
+ * 是否在加载失败时静默处理(不抛出错误)
43
+ * @default false
44
+ */
45
+ silent?: boolean;
46
+ }
47
+ /**
48
+ * 读取所有机场禁飞区 GeoJSON 文件
49
+ *
50
+ * 注意:由于无法直接获取目录文件列表,需要提供文件列表
51
+ * 可以通过以下方式之一:
52
+ * 1. 提供 fileList 参数
53
+ * 2. 在 public/geojson 目录下放置 file-list.json 文件
54
+ * 3. 使用 getAllAirportNoFlyZonesWithList 方法
55
+ *
56
+ * @param fileList 可选的文件名列表(不含扩展名)
57
+ * @param config 加载配置
58
+ * @returns Promise<AirportNoFlyZone[]> 机场禁飞区数据数组
59
+ */
60
+ export declare function loadAllAirportNoFlyZones(fileList?: string[], config?: GeoJSONLoaderConfig): Promise<AirportNoFlyZone[]>;
61
+ /**
62
+ * 读取单个机场禁飞区 GeoJSON 文件
63
+ * @param fileName 文件名(不含扩展名,如 '珠海_金湾机场')
64
+ * @param config 加载配置
65
+ * @returns Promise<AirportNoFlyZone | null> 机场禁飞区数据或 null
66
+ */
67
+ export declare function loadAirportNoFlyZone(fileName: string, config?: GeoJSONLoaderConfig): Promise<AirportNoFlyZone | null>;
68
+ /**
69
+ * 将 GeoJSON 坐标转换为 Cesium Cartesian3 数组
70
+ * @param coordinates GeoJSON 多边形坐标数组
71
+ * @param height 高度偏移(米),默认为 0
72
+ * @returns 包含 longitude, latitude, height 的对象数组
73
+ */
74
+ export declare function geojsonCoordinatesToCartesian3(coordinates: number[][], height?: number): Array<{
75
+ longitude: number;
76
+ latitude: number;
77
+ height: number;
78
+ }>;
79
+ /**
80
+ * 从文件名列表生成 file-list.json
81
+ * 这个函数可以在构建时使用,生成文件列表
82
+ *
83
+ * @param fileNames 文件名列表(不含扩展名)
84
+ * @returns JSON 字符串
85
+ */
86
+ export declare function generateFileListJson(fileNames: string[]): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingm/vmap-cesium-toolbar",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.1-beta.9",
4
4
  "description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,6 +25,7 @@
25
25
  "build": "vite build && vite build --mode lib",
26
26
  "build:lib": "vite build --mode lib",
27
27
  "build:plugin": "node scripts/build-plugin.js",
28
+ "generate:file-list": "node scripts/generate-file-list.js",
28
29
  "preview": "vite preview",
29
30
  "type-check": "vue-tsc --noEmit"
30
31
  },