@xingm/vmap-cesium-toolbar 0.0.2-alpha.5 → 0.0.2-alpha.6

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,9 +1,9 @@
1
1
  // VMap Cesium Toolbar Plugin Type Definitions
2
2
 
3
3
  import type * as Cesium from 'cesium';
4
- import type { Viewer, Cartesian3, Cartographic, Entity, Cartesian2 } from 'cesium';
4
+ import type { Viewer, Cartesian3, Cartographic, Entity, Cartesian2, Color } from 'cesium';
5
5
 
6
- // 工具栏配置接口
6
+ // 工具栏配置接口(与 CesiumMapModel.ts 保持一致)
7
7
  export interface ToolbarConfig {
8
8
  position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
9
9
  buttonSize?: number;
@@ -14,23 +14,55 @@ export interface ToolbarConfig {
14
14
  borderWidth?: number;
15
15
  boxShadow?: string;
16
16
  zIndex?: number;
17
+ buttons?: CustomButtonConfig[];
17
18
  }
18
19
 
19
- // 按钮配置接口
20
+ // 按钮配置接口(内部默认按钮配置使用)
20
21
  export interface ButtonConfig {
22
+ sort?: number;
21
23
  id: string;
22
24
  icon: string;
23
25
  title: string;
24
26
  size?: number;
25
27
  color?: string;
28
+ borderColor?: string;
29
+ borderWidth?: number;
30
+ borderStyle?: string;
31
+ hoverColor?: string;
32
+ activeColor?: string;
33
+ backgroundColor?: string;
34
+ callback?: () => void;
35
+ activeIcon?: string | HTMLElement;
36
+ }
37
+
38
+ // 自定义按钮配置接口(对外主要使用)
39
+ export interface CustomButtonConfig {
40
+ id: string;
41
+ icon: string | HTMLElement | false;
42
+ title: string;
43
+ enabled?: boolean;
44
+ visible?: boolean;
45
+ size?: number;
46
+ color?: string;
47
+ borderColor?: string;
48
+ borderWidth?: number;
49
+ borderStyle?: string;
50
+ padding?: string;
26
51
  hoverColor?: string;
27
52
  activeColor?: string;
53
+ backgroundColor?: string;
54
+ sort?: number;
55
+ activeIcon?: string | HTMLElement | false;
56
+ callback?: () => void;
57
+ onClick?: (buttonId: string, buttonElement: HTMLElement) => void;
28
58
  }
29
59
 
30
60
  // 搜索回调接口
31
61
  export interface SearchCallback {
32
62
  onSearch?: (query: string) => Promise<SearchResult[]>;
33
63
  onSelect?: (result: SearchResult) => void;
64
+ onSearchInput?: (query: string, container: HTMLElement) => void;
65
+ onSearchResults?: (results: SearchResult[], container: HTMLElement) => void;
34
66
  }
35
67
 
36
68
  // 搜索结果接口
@@ -52,8 +84,8 @@ export interface MeasurementCallback {
52
84
 
53
85
  // 缩放回调接口
54
86
  export interface ZoomCallback {
55
- onZoomIn?: (beforeLevel: number, afterLevel: number) => void;
56
- onZoomOut?: (beforeLevel: number, afterLevel: number) => void;
87
+ onZoomIn?: (beforeHeight: number, afterHeight: number, currentLevel: number) => void;
88
+ onZoomOut?: (beforeHeight: number, afterHeight: number, currentLevel: number) => void;
57
89
  }
58
90
 
59
91
  // 地图类型接口
@@ -61,7 +93,9 @@ export interface MapType {
61
93
  id: string;
62
94
  name: string;
63
95
  thumbnail: string;
64
- provider: any; // Cesium.ImageryProvider
96
+ provider: (token: string) => Cesium.ImageryProvider[];
97
+ terrainProvider?: (token: string) => Cesium.TerrainProvider | null;
98
+ geoWTFS?: (token: string, viewer: Cesium.Viewer) => any | null;
65
99
  }
66
100
 
67
101
  // 视锥体选项接口
@@ -78,17 +112,37 @@ export interface FrustumOptions {
78
112
  }
79
113
 
80
114
  // 覆盖物选项接口
115
+ // 覆盖物选项(与 CesiumMapModel.ts 保持一致)
81
116
  export interface OverlayOptions {
82
117
  position: Cartesian3;
83
118
  type: 'point' | 'label' | 'billboard' | 'model' | 'cylinder';
84
- text?: string;
85
- image?: string;
86
- model?: string;
87
- color?: any; // Cesium.Color
88
- scale?: number;
89
- height?: number;
90
- width?: number;
91
- heightReference?: any; // Cesium.HeightReference
119
+ point?: {
120
+ pixelSize?: number;
121
+ color?: Color;
122
+ outlineColor?: Color;
123
+ outlineWidth?: number;
124
+ };
125
+ label?: {
126
+ text: string;
127
+ font?: string;
128
+ fillColor?: Color;
129
+ outlineColor?: Color;
130
+ outlineWidth?: number;
131
+ };
132
+ billboard?: {
133
+ image: string;
134
+ scale?: number;
135
+ };
136
+ model?: {
137
+ uri: string;
138
+ scale?: number;
139
+ };
140
+ cylinder?: {
141
+ length: number;
142
+ topRadius: number;
143
+ bottomRadius: number;
144
+ material?: Color;
145
+ };
92
146
  }
93
147
 
94
148
  // 地图中心点接口
@@ -102,45 +156,50 @@ export interface MapCenter {
102
156
 
103
157
  // 初始化选项接口
104
158
  export interface InitOptions {
105
- token?: string;
106
- cesiumToken?: string;
107
- terrain?: any; // Cesium.Terrain
108
- terrainProvider?: any; // Cesium.TerrainProvider
159
+ terrain?: Cesium.Terrain;
160
+ terrainProvider?: Cesium.TerrainProvider;
109
161
  mapType?: string;
110
- imageryProvider?: any; // Cesium.UrlTemplateImageryProvider
111
- imageryLayers?: any; // Cesium.ImageryLayerCollection
112
- terrainShadows?: any; // Cesium.ShadowMode
113
- contextOptions?: any; // Cesium.ContextOptions
162
+ imageryProvider?: Cesium.UrlTemplateImageryProvider;
163
+ imageryLayers?: Cesium.ImageryLayerCollection;
164
+ terrainShadows?: Cesium.ShadowMode;
165
+ contextOptions?: Cesium.ContextOptions;
114
166
  scene3DOnly?: boolean;
115
- isFlyTo?: boolean;
116
- isFly?: boolean;
117
167
  selectionIndicator?: boolean;
118
168
  navigationHelpButton?: boolean;
119
169
  fullscreenButton?: boolean;
120
170
  geocoder?: boolean;
121
171
  homeButton?: boolean;
122
172
  infoBox?: boolean;
173
+ vrButton?: boolean;
123
174
  sceneModePicker?: boolean;
124
- baseLayerPicker?: boolean;
125
175
  timeline?: boolean;
126
176
  animation?: boolean;
127
- clock?: any; // Cesium.Clock
177
+ isFly?: boolean;
178
+ flyDuration?: number;
179
+ baseLayerPicker?: boolean;
128
180
  navigationInstructionsInitiallyVisible?: boolean;
129
- sceneMode?: any; // Cesium.SceneMode
130
- screenSpaceEventHandler?: any; // Cesium.ScreenSpaceEventHandler
181
+ clock?: Cesium.Clock;
182
+ sceneMode?: Cesium.SceneMode;
183
+ screenSpaceEventHandler?: Cesium.ScreenSpaceEventHandler;
131
184
  useDefaultRenderLoop?: boolean;
132
185
  targetFrameRate?: number;
133
186
  showRenderLoopErrors?: boolean;
134
187
  automaticallyTrackDataSourceClocks?: boolean;
135
- dataSources?: any; // Cesium.DataSourceCollection
188
+ dataSources?: Cesium.DataSourceCollection;
136
189
  creationTime?: number;
137
190
  useBrowserRecommendedResolution?: boolean;
138
191
  resolutionScale?: number;
139
192
  orderIndependentTransparency?: boolean;
140
193
  shadows?: boolean;
194
+ depthTestAgainstTerrain?: boolean;
141
195
  terrainExaggeration?: number;
142
196
  maximumScreenSpaceError?: number;
143
197
  maximumNumberOfLoadedTiles?: number;
198
+ token?: string;
199
+ cesiumToken?: string;
200
+ success?: () => void;
201
+ cancel?: () => void;
202
+ mapCenter?: MapCenter;
144
203
  }
145
204
 
146
205
  // 主要类声明
@@ -161,6 +220,16 @@ export declare class CesiumMapToolbar {
161
220
  setInitialCenter(center: { longitude: number; latitude: number; height: number }): void;
162
221
  getInitialCenter(): { longitude: number; latitude: number; height: number } | undefined;
163
222
  resetToInitialLocation(): void;
223
+ /** 当前测量模式:none / distance / area */
224
+ readonly measurement: {
225
+ getMeasureMode: () => 'none' | 'distance' | 'area';
226
+ };
227
+ /** 更新内置或自定义按钮配置 */
228
+ updateButtonConfig(buttonId: string, config: Partial<CustomButtonConfig>): void;
229
+ /** 添加或替换自定义按钮 */
230
+ addCustomButton(config: CustomButtonConfig): void;
231
+ /** 按 id 移除按钮 */
232
+ removeButton(buttonId: string): void;
164
233
  drawMonitoringCircle(
165
234
  longitude: number,
166
235
  latitude: number,
@@ -346,6 +415,7 @@ export interface CircleOptions {
346
415
  outlineWidth?: number;
347
416
  heightReference?: any;
348
417
  extrudedHeight?: number;
418
+ heightEpsilon?: number; // 高度容差,用于环形方案
349
419
  onClick?: (entity: Entity) => void;
350
420
  id?: string;
351
421
  }
@@ -371,6 +441,20 @@ export declare class CesiumOverlayService {
371
441
  destroy(): void;
372
442
  }
373
443
 
444
+ // 单个信息窗口工具类(与 libs/overlay/MapInfoWindow.ts 保持一致)
445
+ export declare class MapInfoWindow {
446
+ constructor(viewer: Viewer, container: HTMLElement);
447
+ setDefaultUpdateInterval(ms: number): void;
448
+ forceUpdateAll(): void;
449
+ add(options: InfoWindowOptions): Entity;
450
+ update(options: Partial<InfoWindowOptions> & { id: string }): void;
451
+ updatePosition(entity: Entity, position: OverlayPosition): void;
452
+ setVisible(entity: Entity, visible: boolean): void;
453
+ remove(entity: Entity): void;
454
+ removeAll(): void;
455
+ destroy(): void;
456
+ }
457
+
374
458
  // Overlay: 工具类声明(只暴露主要方法)
375
459
  export declare class MapMarker {
376
460
  constructor(viewer: Viewer);
@@ -429,30 +513,121 @@ export declare class MapCircle {
429
513
  updateStyle(entity: Entity, options: Partial<Pick<CircleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
430
514
  }
431
515
 
516
+ // toolbar: 相机控制器及服务(与工具栏相关类保持一致)
517
+ export interface MapInitialCenter {
518
+ longitude: number;
519
+ latitude: number;
520
+ height: number;
521
+ }
522
+
523
+ export interface CesiumMapControllerOptions {
524
+ initialCenter?: MapInitialCenter;
525
+ getMapTypes?: () => MapType[];
526
+ getCurrentMapTypeId?: () => string;
527
+ getToken?: () => string;
528
+ zoomCallback?: ZoomCallback;
529
+ onSceneModeChanged?: () => void;
530
+ }
531
+
532
+ export declare class CesiumMapController {
533
+ constructor(viewer: Viewer, options?: CesiumMapControllerOptions);
534
+ setupCameraZoomLimitListener(): void;
535
+ getCurrentZoomLevel(): number;
536
+ setZoomLevel(zoomLevel: number): void;
537
+ zoomIn(): void;
538
+ zoomOut(): void;
539
+ toggle2D3D(buttonElement: HTMLElement): void;
540
+ resetLocation(): void;
541
+ setInitialCenter(center: MapInitialCenter): void;
542
+ getInitialCenter(): MapInitialCenter | undefined;
543
+ toggleFullscreen(): void;
544
+ isFullscreen(): boolean;
545
+ enterFullscreen(): void;
546
+ exitFullscreen(): void;
547
+ }
548
+
549
+ export interface MapLayersServiceConfig {
550
+ mapTypes: MapType[];
551
+ currentMapType: string;
552
+ token: string;
553
+ isNoFlyZoneChecked: boolean;
554
+ isNoFlyZoneVisible: boolean;
555
+ onMapTypeChange?: (mapTypeId: string) => void;
556
+ onNoFlyZoneToggle?: (isChecked: boolean) => void;
557
+ onShowNoFlyZones?: () => Promise<void> | void;
558
+ }
559
+
560
+ export declare class MapLayersService {
561
+ constructor(viewer: Viewer, toolbarElement: HTMLElement, config: MapLayersServiceConfig);
562
+ updateConfig(config: Partial<MapLayersServiceConfig>): void;
563
+ toggleLayers(buttonElement: HTMLElement): void;
564
+ switchMapType(mapTypeId: string): void;
565
+ getCurrentMapType(): string;
566
+ closeLayersMenu(): void;
567
+ destroy(): void;
568
+ }
569
+
570
+ export declare class SearchService {
571
+ constructor(viewer: Viewer, toolbarElement: HTMLElement, searchCallback?: SearchCallback);
572
+ setSearchCallback(callback: SearchCallback): void;
573
+ toggleSearch(buttonElement: HTMLElement): void;
574
+ displaySearchResults(results: SearchResult[], container: HTMLElement): void;
575
+ selectSearchResult(result: SearchResult): void;
576
+ closeSearchContainer(): void;
577
+ destroy(): void;
578
+ }
579
+
580
+ export interface NotFlyZonesServiceConfig {
581
+ extrudedHeight?: number;
582
+ autoLoad?: boolean;
583
+ }
584
+
585
+ export declare class NotFlyZonesService {
586
+ constructor(viewer: Viewer, config?: NotFlyZonesServiceConfig);
587
+ showNoFlyZones(): Promise<void>;
588
+ hideNoFlyZones(): void;
589
+ toggleNoFlyZones(): Promise<void>;
590
+ getNoFlyZoneVisible(): boolean;
591
+ destroy(): void;
592
+ }
593
+
594
+ // 工具栏按钮默认配置与排序(来自 MapToolBarConfig.ts)
595
+ export declare const defaultButtonSorts: Record<string, number>;
596
+ export declare const defaultButtons: ButtonConfig[];
597
+
432
598
  // 绘制相关类型(与内部实现保持一致)
599
+ // 绘制底层工具类型(与 drawHelper/BaseDraw.ts 保持一致)
600
+ export interface DrawResult {
601
+ entity: Entity | null;
602
+ type: 'line' | 'polygon' | 'rectangle' | 'circle';
603
+ positions: Cartesian3[];
604
+ distance?: number;
605
+ areaKm2?: number;
606
+ }
607
+
608
+ export interface DrawCallbacks {
609
+ onDrawStart?: () => void;
610
+ onDrawEnd?: (entity: Entity | null) => void;
611
+ onEntityRemoved?: (entity: Entity) => void;
612
+ onMeasureComplete?: (result: DrawResult) => void;
613
+ }
614
+
433
615
  export interface DrawOptions {
434
- strokeColor?: any | string;
616
+ strokeColor?: Cesium.Color | string;
435
617
  strokeWidth?: number;
436
- fillColor?: any | string;
437
- outlineColor?: any | string;
618
+ fillColor?: Cesium.Color | string;
619
+ outlineColor?: Cesium.Color | string;
438
620
  outlineWidth?: number;
621
+ heightEpsilon?: number;
439
622
  selected?: {
440
- color?: any | string;
623
+ color?: Cesium.Color | string;
441
624
  width?: number;
442
- outlineColor?: any | string;
625
+ outlineColor?: Cesium.Color | string;
443
626
  outlineWidth?: number;
444
627
  };
445
628
  onClick?: (entity: Entity, type?: 'line' | 'polygon' | 'rectangle' | 'circle', positions?: Cartesian3[]) => void;
446
629
  }
447
630
 
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
-
456
631
  export declare class DrawHelper {
457
632
  constructor(viewer: Viewer);
458
633
  // 开始绘制(可选样式参数)
@@ -479,6 +654,61 @@ export declare class DrawHelper {
479
654
  destroy(): void;
480
655
  }
481
656
 
657
+ // 底层抽象绘制类及具体实现(通过 `export * from './libs/drawHelper/index'` 暴露)
658
+ export declare abstract class BaseDraw {
659
+ protected viewer: Viewer;
660
+ protected scene: Cesium.Scene;
661
+ protected entities: Cesium.EntityCollection;
662
+ protected offsetHeight: number;
663
+ protected originalDepthTestAgainstTerrain: boolean | null;
664
+ protected originalRequestRenderMode: boolean | null;
665
+ protected callbacks: DrawCallbacks;
666
+ protected tempPositions: Cartesian3[];
667
+ protected tempEntities: Entity[];
668
+ protected tempLabelEntities: Entity[];
669
+ protected finishedPointEntities: Entity[];
670
+ protected drawOptions?: DrawOptions;
671
+ protected resolveColor(input?: Cesium.Color | string): Cesium.Color;
672
+ protected applySelectedStyleToEntity(entity: Entity): void;
673
+ protected restoreOriginalStyleForEntity(entity: Entity): void;
674
+ protected updateOffsetHeight(): void;
675
+ protected pickGlobePosition(windowPosition: Cesium.Cartesian2): Cartesian3 | null;
676
+ protected rememberOriginalRequestRenderModeIfNeeded(): void;
677
+ protected restoreRequestRenderModeIfNeeded(): void;
678
+ abstract updateDrawingEntity(previewPoint?: Cartesian3): void;
679
+ abstract startDrawing(options?: DrawOptions): void;
680
+ abstract finishDrawing(): DrawResult | null;
681
+ abstract getDrawType(): 'line' | 'polygon' | 'rectangle' | 'circle';
682
+ }
683
+
684
+ export declare class DrawLine extends BaseDraw {
685
+ updateDrawingEntity(previewPoint?: Cartesian3): void;
686
+ startDrawing(options?: DrawOptions): void;
687
+ finishDrawing(): DrawResult | null;
688
+ getDrawType(): 'line';
689
+ }
690
+
691
+ export declare class DrawPolygon extends BaseDraw {
692
+ updateDrawingEntity(previewPoint?: Cartesian3): void;
693
+ startDrawing(options?: DrawOptions): void;
694
+ finishDrawing(): DrawResult | null;
695
+ getDrawType(): 'polygon';
696
+ }
697
+
698
+ export declare class DrawRectangle extends BaseDraw {
699
+ updateDrawingEntity(previewPoint?: Cartesian3): void;
700
+ startDrawing(options?: DrawOptions): void;
701
+ finishDrawing(): DrawResult | null;
702
+ getDrawType(): 'rectangle';
703
+ }
704
+
705
+ export declare class DrawCircle extends BaseDraw {
706
+ updateDrawingEntity(previewPoint?: Cartesian3): void;
707
+ startDrawing(options?: DrawOptions): void;
708
+ finishDrawing(): DrawResult | null;
709
+ getDrawType(): 'circle';
710
+ }
711
+
482
712
  export declare function initCesium(
483
713
  containerId: string,
484
714
  options: InitOptions,