@xingm/vmap-cesium-toolbar 0.0.2-alpha.2 → 0.0.2-alpha.4

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.
@@ -8,10 +8,10 @@ import * as Cesium from "cesium";
8
8
  export declare function useDrawHelper(viewer: Ref<Cesium.Viewer | undefined>, message: Ref<string>): {
9
9
  drawHelper: Ref<{
10
10
  handleSceneModeChanged: () => void;
11
- startDrawingLine: (options?: import('../libs/drawHelper').DrawOptions) => void;
12
- startDrawingPolygon: (options?: import('../libs/drawHelper').DrawOptions) => void;
13
- startDrawingRectangle: (options?: import('../libs/drawHelper').DrawOptions) => void;
14
- startDrawingCircle: (options?: import('../libs/drawHelper').DrawOptions) => void;
11
+ startDrawingLine: (options?: import('..').DrawOptions) => void;
12
+ startDrawingPolygon: (options?: import('..').DrawOptions) => void;
13
+ startDrawingRectangle: (options?: import('..').DrawOptions) => void;
14
+ startDrawingCircle: (options?: import('..').DrawOptions) => void;
15
15
  endDrawing: () => void;
16
16
  clearAll: () => void;
17
17
  clearAllEntities: () => void;
@@ -30,10 +30,10 @@ export declare function useDrawHelper(viewer: Ref<Cesium.Viewer | undefined>, me
30
30
  destroy: () => void;
31
31
  } | null, DrawHelper | {
32
32
  handleSceneModeChanged: () => void;
33
- startDrawingLine: (options?: import('../libs/drawHelper').DrawOptions) => void;
34
- startDrawingPolygon: (options?: import('../libs/drawHelper').DrawOptions) => void;
35
- startDrawingRectangle: (options?: import('../libs/drawHelper').DrawOptions) => void;
36
- startDrawingCircle: (options?: import('../libs/drawHelper').DrawOptions) => void;
33
+ startDrawingLine: (options?: import('..').DrawOptions) => void;
34
+ startDrawingPolygon: (options?: import('..').DrawOptions) => void;
35
+ startDrawingRectangle: (options?: import('..').DrawOptions) => void;
36
+ startDrawingCircle: (options?: import('..').DrawOptions) => void;
37
37
  endDrawing: () => void;
38
38
  clearAll: () => void;
39
39
  clearAllEntities: () => void;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // VMap Cesium Toolbar Plugin Type Definitions
2
2
 
3
- import type { Viewer, Cartesian3, Cartographic } from 'cesium';
3
+ import type { Viewer, Cartesian3, Cartographic, Entity } from 'cesium';
4
4
 
5
5
  // 工具栏配置接口
6
6
  export interface ToolbarConfig {
@@ -187,20 +187,115 @@ export declare class CesiumMapToolbar {
187
187
  destroy(): void;
188
188
  }
189
189
 
190
+ // 覆盖物服务:对外暴露的简化类型声明
191
+ export type PositionOffset =
192
+ | 'top'
193
+ | 'bottom'
194
+ | 'left'
195
+ | 'right'
196
+ | 'top-left'
197
+ | 'top-right'
198
+ | 'bottom-left'
199
+ | 'bottom-right'
200
+ | 'left-top'
201
+ | 'left-bottom'
202
+ | 'right-top'
203
+ | 'right-bottom';
204
+
205
+ export interface InfoWindowOptions {
206
+ position: Cartesian3 | [number, number, number?];
207
+ content: string | HTMLElement;
208
+ width?: number;
209
+ height?: number;
210
+ pixelOffset?: { x: number; y: number };
211
+ show?: boolean;
212
+ id?: string;
213
+ closable?: boolean;
214
+ onClick?: (entity: any) => void;
215
+ onClose?: (entity: any) => void;
216
+ backgroundColor?: string;
217
+ color?: string;
218
+ font?: string;
219
+ className?: string;
220
+ style?: Partial<CSSStyleDeclaration>;
221
+ hideWhenOutOfView?: boolean;
222
+ anchorHeight?: number;
223
+ anchorPixel?: number;
224
+ tailGap?: number;
225
+ updateInterval?: number;
226
+ showArrow?: boolean;
227
+ arrowSize?: number;
228
+ positionOffset?: PositionOffset;
229
+ }
230
+
231
+ export declare class CesiumOverlayService {
232
+ constructor(viewer: Viewer);
233
+ addMarker(options: any): any; // 返回 Cesium.Entity
234
+ addLabel(options: any): any; // 返回 Cesium.Entity
235
+ addIcon(options: any): any; // 返回 Cesium.Entity
236
+ addSvg(options: any): any; // 返回 Cesium.Entity
237
+ addInfoWindow(options: InfoWindowOptions): any; // 返回 Cesium.Entity
238
+ addPolyline(options: any): any; // 返回 Cesium.Entity
239
+ addPolygon(options: any): any; // 返回 Cesium.Entity
240
+ addRectangle(options: any): any; // 返回 Cesium.Entity
241
+ addCircle(options: any): any; // 返回 Cesium.Entity
242
+ getOverlay(id: string): any | undefined; // 返回 Cesium.Entity | undefined
243
+ removeOverlay(id: string): boolean;
244
+ removeAllOverlays(): void;
245
+ updateOverlayPosition(id: string, position: Cartesian3 | [number, number, number?]): boolean;
246
+ setOverlayVisible(id: string, visible: boolean): boolean;
247
+ getAllOverlayIds(): string[];
248
+ getAllOverlays(): any[]; // Cesium.Entity[]
249
+ destroy(): void;
250
+ }
251
+
252
+ // 绘制相关类型(与内部实现保持一致)
253
+ export interface DrawOptions {
254
+ strokeColor?: any | string;
255
+ strokeWidth?: number;
256
+ fillColor?: any | string;
257
+ outlineColor?: any | string;
258
+ outlineWidth?: number;
259
+ selected?: {
260
+ color?: any | string;
261
+ width?: number;
262
+ outlineColor?: any | string;
263
+ outlineWidth?: number;
264
+ };
265
+ onClick?: (entity: Entity, type?: 'line' | 'polygon' | 'rectangle' | 'circle', positions?: Cartesian3[]) => void;
266
+ }
267
+
268
+ export interface DrawResult {
269
+ entity: Entity | null;
270
+ type: 'line' | 'polygon' | 'rectangle' | 'circle';
271
+ positions: Cartesian3[];
272
+ distance?: number;
273
+ areaKm2?: number;
274
+ }
275
+
190
276
  export declare class DrawHelper {
191
277
  constructor(viewer: Viewer);
192
- startDrawingLine(): void;
193
- startDrawingPolygon(): void;
194
- startDrawingRectangle(): void;
195
- drawFrustum(options?: FrustumOptions): void;
278
+ // 开始绘制(可选样式参数)
279
+ startDrawingLine(options?: DrawOptions): void;
280
+ startDrawingPolygon(options?: DrawOptions): void;
281
+ startDrawingRectangle(options?: DrawOptions): void;
282
+ startDrawingCircle(options?: DrawOptions): void;
283
+ // 控制绘制流程
196
284
  endDrawing(): void;
285
+ // 清理与管理
197
286
  clearAll(): void;
198
- clearFrustum(): void;
199
- removeEntity(entity: any): void; // Cesium.Entity
200
- getFinishedEntities(): any[]; // Cesium.Entity[]
287
+ clearAllEntities(): void;
288
+ clearAllPoints(): void;
289
+ removeEntity(entity: Entity): void;
290
+ getFinishedEntities(): Entity[];
291
+ // 事件回调注册
292
+ onMeasureComplete(callback: (result: DrawResult) => void): void;
201
293
  onDrawStart(callback: () => void): void;
202
- onDrawEnd(callback: (entity: any) => void): void; // Cesium.Entity | null
203
- onEntityRemoved(callback: (entity: any) => void): void; // Cesium.Entity
294
+ onDrawEnd(callback: (entity: Entity | null) => void): void;
295
+ onEntityRemoved(callback: (entity: Entity) => void): void;
296
+ // 场景模式切换适配
297
+ handleSceneModeChanged(): void;
298
+ // 资源释放
204
299
  destroy(): void;
205
300
  }
206
301
 
@@ -215,7 +310,9 @@ export declare function initCesium(
215
310
  declare const _default: {
216
311
  CesiumMapToolbar: typeof CesiumMapToolbar;
217
312
  DrawHelper: typeof DrawHelper;
313
+ CesiumOverlayService: typeof CesiumOverlayService;
218
314
  initCesium: typeof initCesium;
315
+ initCesiumMap: typeof initCesium;
219
316
  };
220
317
 
221
318
  export default _default;