@xingm/vmap-cesium-toolbar 0.0.2-alpha.3 → 0.0.2-alpha.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // VMap Cesium Toolbar Plugin Type Definitions
2
2
 
3
- import type { Viewer, Cartesian3, Cartographic } from 'cesium';
3
+ import type * as Cesium from 'cesium';
4
+ import type { Viewer, Cartesian3, Cartographic, Entity, Cartesian2 } from 'cesium';
4
5
 
5
6
  // 工具栏配置接口
6
7
  export interface ToolbarConfig {
@@ -187,20 +188,294 @@ export declare class CesiumMapToolbar {
187
188
  destroy(): void;
188
189
  }
189
190
 
191
+ // 覆盖物服务:对外暴露的简化类型声明
192
+ // 覆盖物位置类型(与 overlay/types.ts 保持一致)
193
+ export type OverlayPosition = Cartesian3 | [number, number] | [number, number, number];
194
+
195
+ export type PositionOffset =
196
+ | 'top'
197
+ | 'bottom'
198
+ | 'left'
199
+ | 'right'
200
+ | 'top-left'
201
+ | 'top-right'
202
+ | 'bottom-left'
203
+ | 'bottom-right'
204
+ | 'left-top'
205
+ | 'left-bottom'
206
+ | 'right-top'
207
+ | 'right-bottom';
208
+
209
+ export interface InfoWindowOptions {
210
+ position: OverlayPosition;
211
+ content: string | HTMLElement;
212
+ width?: number;
213
+ height?: number;
214
+ pixelOffset?: Cesium.Cartesian2 | { x: number; y: number };
215
+ show?: boolean;
216
+ id?: string;
217
+ closable?: boolean;
218
+ onClick?: (entity: any) => void;
219
+ onClose?: (entity: any) => void;
220
+ backgroundColor?: string;
221
+ color?: string;
222
+ font?: string;
223
+ className?: string;
224
+ style?: Partial<CSSStyleDeclaration>;
225
+ hideWhenOutOfView?: boolean;
226
+ anchorHeight?: number;
227
+ anchorPixel?: number;
228
+ tailGap?: number;
229
+ updateInterval?: number;
230
+ showArrow?: boolean;
231
+ arrowSize?: number;
232
+ positionOffset?: PositionOffset;
233
+ }
234
+
235
+ // Overlay: 选项类型(与各实现保持一致)
236
+ export interface MarkerOptions {
237
+ position: OverlayPosition;
238
+ pixelSize?: number;
239
+ color?: any | string;
240
+ outlineColor?: any | string;
241
+ outlineWidth?: number;
242
+ heightReference?: any;
243
+ scaleByDistance?: Cesium.NearFarScalar;
244
+ disableDepthTestDistance?: number;
245
+ onClick?: (entity: Entity) => void;
246
+ id?: string;
247
+ }
248
+
249
+ export interface LabelOptions {
250
+ position: OverlayPosition;
251
+ text: string;
252
+ font?: string;
253
+ fillColor?: any | string;
254
+ outlineColor?: any | string;
255
+ outlineWidth?: number;
256
+ style?: any;
257
+ pixelOffset?: Cesium.Cartesian2;
258
+ eyeOffset?: Cesium.Cartesian3;
259
+ horizontalOrigin?: any;
260
+ verticalOrigin?: any;
261
+ heightReference?: any;
262
+ scale?: number;
263
+ showBackground?: boolean;
264
+ backgroundColor?: any | string;
265
+ backgroundPadding?: Cesium.Cartesian2;
266
+ disableDepthTestDistance?: number;
267
+ onClick?: (entity: Entity) => void;
268
+ id?: string;
269
+ }
270
+
271
+ export interface IconOptions {
272
+ position: OverlayPosition;
273
+ image: string;
274
+ width?: number;
275
+ height?: number;
276
+ scale?: number;
277
+ rotation?: number;
278
+ pixelOffset?: Cesium.Cartesian2;
279
+ eyeOffset?: Cesium.Cartesian3;
280
+ horizontalOrigin?: any;
281
+ verticalOrigin?: any;
282
+ heightReference?: any;
283
+ disableDepthTestDistance?: number;
284
+ color?: any | string;
285
+ onClick?: (entity: Entity) => void;
286
+ id?: string;
287
+ }
288
+
289
+ export interface SvgOptions {
290
+ position: OverlayPosition;
291
+ svg: string;
292
+ width?: number;
293
+ height?: number;
294
+ scale?: number;
295
+ rotation?: number;
296
+ pixelOffset?: Cesium.Cartesian2;
297
+ eyeOffset?: Cesium.Cartesian3;
298
+ horizontalOrigin?: any;
299
+ verticalOrigin?: any;
300
+ heightReference?: any;
301
+ disableDepthTestDistance?: number;
302
+ color?: any | string;
303
+ onClick?: (entity: Entity) => void;
304
+ id?: string;
305
+ }
306
+
307
+ export interface PolylineOptions {
308
+ positions: OverlayPosition[];
309
+ width?: number;
310
+ material?: Cesium.MaterialProperty | any | string;
311
+ clampToGround?: boolean;
312
+ onClick?: (entity: Entity) => void;
313
+ id?: string;
314
+ }
315
+
316
+ export interface PolygonOptions {
317
+ positions: OverlayPosition[];
318
+ material?: Cesium.MaterialProperty | any | string;
319
+ outline?: boolean;
320
+ outlineColor?: any | string;
321
+ outlineWidth?: number;
322
+ heightReference?: any;
323
+ extrudedHeight?: number;
324
+ onClick?: (entity: Entity) => void;
325
+ id?: string;
326
+ }
327
+
328
+ export interface RectangleOptions {
329
+ coordinates: Cesium.Rectangle;
330
+ material?: Cesium.MaterialProperty | any | string;
331
+ outline?: boolean;
332
+ outlineColor?: any | string;
333
+ outlineWidth?: number;
334
+ heightReference?: any;
335
+ extrudedHeight?: number;
336
+ onClick?: (entity: Entity) => void;
337
+ id?: string;
338
+ }
339
+
340
+ export interface CircleOptions {
341
+ position: OverlayPosition;
342
+ radius: number;
343
+ material?: Cesium.MaterialProperty | any | string;
344
+ outline?: boolean;
345
+ outlineColor?: any | string;
346
+ outlineWidth?: number;
347
+ heightReference?: any;
348
+ extrudedHeight?: number;
349
+ onClick?: (entity: Entity) => void;
350
+ id?: string;
351
+ }
352
+
353
+ export declare class CesiumOverlayService {
354
+ constructor(viewer: Viewer);
355
+ addMarker(options: any): any; // 返回 Cesium.Entity
356
+ addLabel(options: any): any; // 返回 Cesium.Entity
357
+ addIcon(options: any): any; // 返回 Cesium.Entity
358
+ addSvg(options: any): any; // 返回 Cesium.Entity
359
+ addInfoWindow(options: InfoWindowOptions): any; // 返回 Cesium.Entity
360
+ addPolyline(options: any): any; // 返回 Cesium.Entity
361
+ addPolygon(options: any): any; // 返回 Cesium.Entity
362
+ addRectangle(options: any): any; // 返回 Cesium.Entity
363
+ addCircle(options: any): any; // 返回 Cesium.Entity
364
+ getOverlay(id: string): any | undefined; // 返回 Cesium.Entity | undefined
365
+ removeOverlay(id: string): boolean;
366
+ removeAllOverlays(): void;
367
+ updateOverlayPosition(id: string, position: Cartesian3 | [number, number, number?]): boolean;
368
+ setOverlayVisible(id: string, visible: boolean): boolean;
369
+ getAllOverlayIds(): string[];
370
+ getAllOverlays(): any[]; // Cesium.Entity[]
371
+ destroy(): void;
372
+ }
373
+
374
+ // Overlay: 工具类声明(只暴露主要方法)
375
+ export declare class MapMarker {
376
+ constructor(viewer: Viewer);
377
+ add(options: MarkerOptions): Entity;
378
+ updatePosition(entity: Entity, position: OverlayPosition): void;
379
+ updateStyle(entity: Entity, options: Partial<Pick<MarkerOptions, 'color' | 'outlineColor' | 'outlineWidth' | 'pixelSize'>>): void;
380
+ }
381
+
382
+ export declare class MapLabel {
383
+ constructor(viewer: Viewer);
384
+ add(options: LabelOptions): Entity;
385
+ updatePosition(entity: Entity, position: OverlayPosition): void;
386
+ }
387
+
388
+ export declare class MapIcon {
389
+ constructor(viewer: Viewer);
390
+ add(options: IconOptions): Entity;
391
+ updatePosition(entity: Entity, position: OverlayPosition): void;
392
+ updateImage(entity: Entity, image: string): void;
393
+ }
394
+
395
+ export declare class MapSVG {
396
+ constructor(viewer: Viewer);
397
+ add(options: SvgOptions): Entity;
398
+ updatePosition(entity: Entity, position: OverlayPosition): void;
399
+ }
400
+
401
+ export declare class MapPolyline {
402
+ constructor(viewer: Viewer);
403
+ add(options: PolylineOptions): Entity;
404
+ updatePositions(entity: Entity, positions: OverlayPosition[]): void;
405
+ updateStyle(entity: Entity, options: Partial<Pick<PolylineOptions, 'width' | 'material'>>): void;
406
+ }
407
+
408
+ export declare class MapPolygon {
409
+ constructor(viewer: Viewer);
410
+ add(options: PolygonOptions): Entity;
411
+ updatePositions(entity: Entity, positions: OverlayPosition[]): void;
412
+ updateStyle(entity: Entity, options: Partial<Pick<PolygonOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
413
+ remove(entityOrId: Entity | string): boolean;
414
+ }
415
+
416
+ export declare class MapRectangle {
417
+ constructor(viewer: Viewer);
418
+ add(options: RectangleOptions): Entity;
419
+ updateCoordinates(entity: Entity, coordinates: Cesium.Rectangle): void;
420
+ updateStyle(entity: Entity, options: Partial<Pick<RectangleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
421
+ remove(entityOrId: Entity | string): boolean;
422
+ }
423
+
424
+ export declare class MapCircle {
425
+ constructor(viewer: Viewer);
426
+ add(options: CircleOptions): Entity;
427
+ updatePosition(entity: Entity, position: OverlayPosition): void;
428
+ updateRadius(entity: Entity, radius: number): void;
429
+ updateStyle(entity: Entity, options: Partial<Pick<CircleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
430
+ }
431
+
432
+ // 绘制相关类型(与内部实现保持一致)
433
+ export interface DrawOptions {
434
+ strokeColor?: any | string;
435
+ strokeWidth?: number;
436
+ fillColor?: any | string;
437
+ outlineColor?: any | string;
438
+ outlineWidth?: number;
439
+ selected?: {
440
+ color?: any | string;
441
+ width?: number;
442
+ outlineColor?: any | string;
443
+ outlineWidth?: number;
444
+ };
445
+ onClick?: (entity: Entity, type?: 'line' | 'polygon' | 'rectangle' | 'circle', positions?: Cartesian3[]) => void;
446
+ }
447
+
448
+ export interface DrawResult {
449
+ entity: Entity | null;
450
+ type: 'line' | 'polygon' | 'rectangle' | 'circle';
451
+ positions: Cartesian3[];
452
+ distance?: number;
453
+ areaKm2?: number;
454
+ }
455
+
190
456
  export declare class DrawHelper {
191
457
  constructor(viewer: Viewer);
192
- startDrawingLine(): void;
193
- startDrawingPolygon(): void;
194
- startDrawingRectangle(): void;
195
- drawFrustum(options?: FrustumOptions): void;
458
+ // 开始绘制(可选样式参数)
459
+ startDrawingLine(options?: DrawOptions): void;
460
+ startDrawingPolygon(options?: DrawOptions): void;
461
+ startDrawingRectangle(options?: DrawOptions): void;
462
+ startDrawingCircle(options?: DrawOptions): void;
463
+ // 控制绘制流程
196
464
  endDrawing(): void;
465
+ // 清理与管理
197
466
  clearAll(): void;
198
- clearFrustum(): void;
199
- removeEntity(entity: any): void; // Cesium.Entity
200
- getFinishedEntities(): any[]; // Cesium.Entity[]
467
+ clearAllEntities(): void;
468
+ clearAllPoints(): void;
469
+ removeEntity(entity: Entity): void;
470
+ getFinishedEntities(): Entity[];
471
+ // 事件回调注册
472
+ onMeasureComplete(callback: (result: DrawResult) => void): void;
201
473
  onDrawStart(callback: () => void): void;
202
- onDrawEnd(callback: (entity: any) => void): void; // Cesium.Entity | null
203
- onEntityRemoved(callback: (entity: any) => void): void; // Cesium.Entity
474
+ onDrawEnd(callback: (entity: Entity | null) => void): void;
475
+ onEntityRemoved(callback: (entity: Entity) => void): void;
476
+ // 场景模式切换适配
477
+ handleSceneModeChanged(): void;
478
+ // 资源释放
204
479
  destroy(): void;
205
480
  }
206
481
 
@@ -215,7 +490,9 @@ export declare function initCesium(
215
490
  declare const _default: {
216
491
  CesiumMapToolbar: typeof CesiumMapToolbar;
217
492
  DrawHelper: typeof DrawHelper;
493
+ CesiumOverlayService: typeof CesiumOverlayService;
218
494
  initCesium: typeof initCesium;
495
+ initCesiumMap: typeof initCesium;
219
496
  };
220
497
 
221
498
  export default _default;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingm/vmap-cesium-toolbar",
3
- "version": "0.0.2-alpha.2",
3
+ "version": "0.0.2-alpha.4",
4
4
  "description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingm/vmap-cesium-toolbar",
3
- "version": "0.0.2-alpha.3",
3
+ "version": "0.0.2-alpha.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.js",