@xingm/vmap-cesium-toolbar 0.0.2 → 0.0.3

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,1014 +1,42 @@
1
- // VMap Cesium Toolbar Plugin Type Definitions
2
-
3
- import type * as Cesium from 'cesium';
4
- import type { Viewer, Cartesian3, Entity, Color } from 'cesium';
5
-
6
- export type Locale = 'zh-CN' | 'en-US' | (string & {});
7
-
8
- export interface I18nLike {
9
- getLocale(): Locale;
10
- setLocale(locale: Locale, options?: { persist?: boolean }): void;
11
- t(key: string, params?: Record<string, any>, localeOverride?: Locale): string;
12
- onLocaleChange(cb: (locale: Locale) => void): () => void;
13
- bindElement(el: HTMLElement, key: string, attr?: 'text' | 'title' | 'placeholder', params?: Record<string, any>): void;
14
- updateTree(root: HTMLElement): void;
15
- addMessages?(locale: Locale, dict: Record<string, any>, options?: { merge?: boolean }): void;
16
- setFallbackLocale?(locale: Locale): void;
17
- configure?(options: { persist?: boolean; useStoredLocale?: boolean; fallbackLocale?: Locale; locale?: Locale }): void;
18
- }
19
-
20
- // 工具栏配置接口(与 CesiumMapModel.ts 保持一致)
21
- export interface ToolbarConfig {
22
- position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
23
- buttonSize?: number;
24
- buttonSpacing?: number;
25
- backgroundColor?: string;
26
- borderColor?: string;
27
- borderRadius?: number;
28
- borderWidth?: number;
29
- boxShadow?: string;
30
- zIndex?: number;
31
- buttons?: CustomButtonConfig[];
32
- useI18n?: boolean;
33
- i18n?: I18nLike;
34
- }
35
-
36
- // 按钮配置接口(内部默认按钮配置使用)
37
- export interface ButtonConfig {
38
- sort?: number;
39
- id: string;
40
- icon: string;
41
- title: string;
42
- titleKey?: string;
43
- size?: number;
44
- color?: string;
45
- borderColor?: string;
46
- borderWidth?: number;
47
- borderStyle?: string;
48
- hoverColor?: string;
49
- activeColor?: string;
50
- backgroundColor?: string;
51
- callback?: () => void;
52
- activeIcon?: string | HTMLElement;
53
- }
54
-
55
- // 自定义按钮配置接口(对外主要使用)
56
- export interface CustomButtonConfig {
57
- id: string;
58
- icon: string | HTMLElement | false;
59
- title: string;
60
- titleKey?: string;
61
- enabled?: boolean;
62
- visible?: boolean;
63
- size?: number;
64
- color?: string;
65
- borderColor?: string;
66
- borderWidth?: number;
67
- borderStyle?: string;
68
- padding?: string;
69
- hoverColor?: string;
70
- activeColor?: string;
71
- backgroundColor?: string;
72
- sort?: number;
73
- activeIcon?: string | HTMLElement | false;
74
- callback?: () => void;
75
- onClick?: (buttonId: string, buttonElement: HTMLElement) => void;
76
- }
77
-
78
- // 搜索回调接口
79
- export interface SearchCallback {
80
- onSearch?: (query: string) => Promise<SearchResult[]>;
81
- onSelect?: (result: SearchResult) => void;
82
- onSearchInput?: (query: string, container: HTMLElement) => void;
83
- onSearchResults?: (results: SearchResult[], container: HTMLElement) => void;
84
- }
85
-
86
- // 搜索结果接口
87
- export interface SearchResult {
88
- name: string;
89
- address: string;
90
- longitude: number;
91
- latitude: number;
92
- height?: number;
93
- }
94
-
95
- // 测量回调接口
96
- export interface MeasurementCallback {
97
- onMeasurementStart?: (positions?: Cartesian3[]) => void;
98
- onDistanceComplete?: (positions: Cartesian3[], distance: number) => void;
99
- onAreaComplete?: (positions: Cartesian3[], area: number) => void;
100
- onClear?: () => void;
101
- }
102
-
103
- // 缩放回调接口
104
- export interface ZoomCallback {
105
- onZoomIn?: (beforeHeight: number, afterHeight: number, currentLevel: number) => void;
106
- onZoomOut?: (beforeHeight: number, afterHeight: number, currentLevel: number) => void;
107
- }
108
-
109
- // 地图类型接口
110
- export interface MapType {
111
- id: string;
112
- name: string;
113
- nameKey?: string;
114
- thumbnail: string;
115
- provider: (token: string) => Cesium.ImageryProvider[];
116
- terrainProvider?: (token: string) => Cesium.TerrainProvider | null;
117
- geoWTFS?: (token: string, viewer: Cesium.Viewer) => any | null;
118
- }
119
-
120
- export const i18n: I18nLike;
121
-
122
- // 视锥体选项接口
123
- export interface FrustumOptions {
124
- position?: Cartesian3;
125
- orientation?: any; // Cesium.Quaternion
126
- fov?: number;
127
- aspectRatio?: number;
128
- near?: number;
129
- far?: number;
130
- fillColor?: any; // Cesium.Color
131
- outlineColor?: any; // Cesium.Color
132
- onRightClick?: (position: Cartesian3) => void;
133
- }
134
-
135
- // 覆盖物选项接口
136
- // 覆盖物选项(与 CesiumMapModel.ts 保持一致)
137
- export interface OverlayOptions {
138
- position: Cartesian3;
139
- type: 'point' | 'label' | 'billboard' | 'model' | 'cylinder';
140
- point?: {
141
- pixelSize?: number;
142
- color?: Color;
143
- outlineColor?: Color;
144
- outlineWidth?: number;
145
- };
146
- label?: {
147
- text: string;
148
- font?: string;
149
- fillColor?: Color;
150
- outlineColor?: Color;
151
- outlineWidth?: number;
152
- };
153
- billboard?: {
154
- image: string;
155
- scale?: number;
156
- };
157
- model?: {
158
- uri: string;
159
- scale?: number;
160
- };
161
- cylinder?: {
162
- length: number;
163
- topRadius: number;
164
- bottomRadius: number;
165
- material?: Color;
166
- };
167
- }
168
-
169
- // 地图中心点接口
170
- export interface MapCenter {
171
- latitude: number;
172
- longitude: number;
173
- height: number;
174
- pitch?: number;
175
- heading?: number;
176
- }
177
-
178
- // 初始化选项接口
179
- export interface InitOptions {
180
- terrain?: Cesium.Terrain;
181
- terrainProvider?: Cesium.TerrainProvider;
182
- mapType?: string;
183
- imageryProvider?: Cesium.UrlTemplateImageryProvider;
184
- imageryLayers?: Cesium.ImageryLayerCollection;
185
- terrainShadows?: Cesium.ShadowMode;
186
- contextOptions?: Cesium.ContextOptions;
187
- scene3DOnly?: boolean;
188
- selectionIndicator?: boolean;
189
- navigationHelpButton?: boolean;
190
- fullscreenButton?: boolean;
191
- geocoder?: boolean;
192
- homeButton?: boolean;
193
- infoBox?: boolean;
194
- vrButton?: boolean;
195
- sceneModePicker?: boolean;
196
- timeline?: boolean;
197
- animation?: boolean;
198
- isFly?: boolean;
199
- flyDuration?: number;
200
- baseLayerPicker?: boolean;
201
- navigationInstructionsInitiallyVisible?: boolean;
202
- clock?: Cesium.Clock;
203
- sceneMode?: Cesium.SceneMode;
204
- screenSpaceEventHandler?: Cesium.ScreenSpaceEventHandler;
205
- useDefaultRenderLoop?: boolean;
206
- targetFrameRate?: number;
207
- showRenderLoopErrors?: boolean;
208
- automaticallyTrackDataSourceClocks?: boolean;
209
- dataSources?: Cesium.DataSourceCollection;
210
- creationTime?: number;
211
- useBrowserRecommendedResolution?: boolean;
212
- resolutionScale?: number;
213
- orderIndependentTransparency?: boolean;
214
- shadows?: boolean;
215
- depthTestAgainstTerrain?: boolean;
216
- terrainExaggeration?: number;
217
- maximumScreenSpaceError?: number;
218
- maximumNumberOfLoadedTiles?: number;
219
- requestRenderMode?: boolean;
220
- token?: string;
221
- cesiumToken?: string;
222
- maximumRenderTimeChange?: number; // 最大渲染时间变化
223
- orderIndependentTranslucency?: boolean; // 无序半透明度,
224
- fxaa?: boolean; // 启用FXAA后处理抗锯齿
225
- msaaSamples?: number; // MSAA采样数(推荐4或8)
226
- success?: () => void;
227
- cancel?: () => void;
228
- mapCenter?: MapCenter;
229
-
230
- /** 渲染异常自动恢复:遇到 NaN/renderError 等会重建 Viewer,需在回调里替换引用 */
231
- autoRecover?: {
232
- enabled?: boolean;
233
- maxRetries?: number;
234
- cooldownMs?: number;
235
- preserveCamera?: boolean;
236
- onRecovering?: (ctx: { reason: string; error?: unknown; attempt: number }) => void;
237
- onRecovered?: (ctx: {
238
- reason: string;
239
- error?: unknown;
240
- attempt: number;
241
- oldViewer: Viewer;
242
- newViewer: Viewer;
243
- }) => void;
244
- watchdog?: {
245
- enabled?: boolean;
246
- staleMs?: number;
247
- checkIntervalMs?: number;
248
- };
249
- };
250
- }
251
-
252
- // 主要类声明
253
- export declare class CesiumMapToolbar {
254
- constructor(
255
- viewer: Viewer,
256
- container: HTMLElement,
257
- config?: ToolbarConfig,
258
- callbacks?: {
259
- search?: SearchCallback;
260
- measurement?: MeasurementCallback;
261
- zoom?: ZoomCallback;
262
- fullscreen?: (isFullscreen: boolean) => void;
263
- resetLocation?: () => void;
264
- },
265
- initialCenter?: { longitude: number; latitude: number; height: number }
266
- );
267
-
268
- /** 天地图 Token(可直接修改或配合 setTDToken) */
269
- TD_Token: string;
270
-
271
- /** 当前可用的底图类型列表 */
272
- mapTypes: MapType[];
273
-
274
- /** 获取内部搜索服务实例 */
275
- getSearchService(): SearchService;
276
-
277
- /** 获取内部禁飞区服务实例 */
278
- getNotFlyZonesService(): NotFlyZonesService;
279
-
280
- /** 获取内部测量服务实例 */
281
- getMeasurementService(): any; // MeasurementService (内部未在 d.ts 中单独暴露)
282
-
283
- /** 获取内部地图控制器实例 */
284
- getCesiumMapCtrl(): CesiumMapController;
285
-
286
- /** 获取内部图层服务实例 */
287
- getMapLayersService(): MapLayersService;
288
-
289
- setMapTypes(mapTypes: MapType[]): void;
290
- setTDToken(TD_Token: string): void;
291
- setInitialCenter(center: { longitude: number; latitude: number; height: number }): void;
292
- getInitialCenter(): { longitude: number; latitude: number; height: number } | undefined;
293
- resetToInitialLocation(): void;
294
- /** 当前测量模式:none / distance / area */
295
- readonly measurement: {
296
- getMeasureMode: () => 'none' | 'distance' | 'area';
297
- };
298
- /** 更新内置或自定义按钮配置 */
299
- updateButtonConfig(buttonId: string, config: Partial<CustomButtonConfig>): void;
300
- /** 添加或替换自定义按钮 */
301
- addCustomButton(config: CustomButtonConfig): void;
302
- /** 按 id 移除按钮 */
303
- removeButton(buttonId: string): void;
304
- drawMonitoringCircle(
305
- longitude: number,
306
- latitude: number,
307
- height: number,
308
- radius: number,
309
- options?: {
310
- borderColor?: string;
311
- fillColor?: string;
312
- borderWidth?: number;
313
- name?: string;
314
- }
315
- ): any; // Cesium.Entity
316
- drawVerticalLine(
317
- longitude: number,
318
- latitude: number,
319
- height: number,
320
- options?: {
321
- color?: string;
322
- width?: number;
323
- dashPattern?: number;
324
- name?: string;
325
- groundHeight?: number;
326
- }
327
- ): any; // Cesium.Entity
328
- destroy(): void;
329
- }
330
-
331
- // 覆盖物服务:对外暴露的简化类型声明
332
- // 覆盖物位置类型(与 overlay/types.ts 保持一致)
333
- export type OverlayPosition = Cartesian3 | [number, number] | [number, number, number];
334
-
335
- // 覆盖物扩展实体类型(与 libs/overlay/types.ts 保持一致)
336
- export interface OverlayEntity extends Entity {
337
- _onClick?: (entity: Entity) => void;
338
- _clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
339
- _hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
340
- _highlightEntities?: Entity[];
341
- _isHighlighted?: boolean;
342
- _highlightState?: { click?: boolean; hover?: boolean };
343
- _overlayType?: string;
344
- _infoWindow?: HTMLElement;
345
- _borderEntity?: Entity;
346
- _innerEntity?: Entity;
347
- _isThickOutline?: boolean;
348
- _outlineWidth?: number;
349
- _isRing?: boolean;
350
- _ringThickness?: number;
351
- _ringSegments?: number;
352
- _ringGlowPower?: number;
353
- _ringLineColor?: Color | string;
354
- _ringLineStyle?: 'solid' | 'dashed';
355
- _ringLineMaterialMode?: 'stripe' | 'dash';
356
- _ringStripeRepeat?: number;
357
- _ringDashLength?: number;
358
- _ringDashPattern?: number;
359
- _ringGapColor?: Color | string;
360
- _ringShowInnerLine?: boolean;
361
- _fillMaterial?: Cesium.MaterialProperty | Color | string;
362
- _ringHeightEpsilon?: number;
363
- _centerCartographic?: Cesium.Cartographic;
364
- _outerRadius?: number;
365
- _innerRadius?: number;
366
- _outerRectangle?: Cesium.Rectangle;
367
-
368
- /** primitive layer key: 用于分层批处理路由 */
369
- _primitiveLayerKey?: string;
370
-
371
- /** primitive circle: 内部使用的纯色缓存(用于高亮恢复) */
372
- _primitiveRingBaseColor?: any;
373
- _primitiveFillBaseColor?: any;
374
-
375
- /** primitive polygon/rectangle: 边框纯色缓存(用于高亮恢复) */
376
- _primitiveBorderBaseColor?: any;
377
- }
378
-
379
- export type PositionOffset =
380
- | 'top'
381
- | 'bottom'
382
- | 'left'
383
- | 'right'
384
- | 'top-left'
385
- | 'top-right'
386
- | 'bottom-left'
387
- | 'bottom-right'
388
- | 'left-top'
389
- | 'left-bottom'
390
- | 'right-top'
391
- | 'right-bottom';
392
-
393
- export interface InfoWindowOptions {
394
- position: OverlayPosition;
395
- content: string | HTMLElement;
396
- width?: number;
397
- height?: number;
398
- pixelOffset?: Cesium.Cartesian2 | { x: number; y: number };
399
- show?: boolean;
400
- id?: string;
401
- closable?: boolean;
402
- onClick?: (entity: any) => void;
403
- onClose?: (entity: any) => void;
404
- backgroundColor?: string;
405
- color?: string;
406
- font?: string;
407
- className?: string;
408
- style?: Partial<CSSStyleDeclaration>;
409
- hideWhenOutOfView?: boolean;
410
- anchorHeight?: number;
411
- anchorPixel?: number;
412
- tailGap?: number;
413
- updateInterval?: number;
414
- showArrow?: boolean;
415
- arrowSize?: number;
416
- positionOffset?: PositionOffset;
417
- }
418
-
419
- // Overlay: 选项类型(与各实现保持一致)
420
- export interface MarkerOptions {
421
- position: OverlayPosition;
422
- pixelSize?: number;
423
- color?: any | string;
424
- outlineColor?: any | string;
425
- outlineWidth?: number;
426
- heightReference?: any;
427
- scaleByDistance?: Cesium.NearFarScalar;
428
- disableDepthTestDistance?: number;
429
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
430
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
431
- onClick?: (entity: Entity) => void;
432
- id?: string;
433
- }
434
-
435
- export interface LabelOptions {
436
- position: OverlayPosition;
437
- text: string;
438
- font?: string;
439
- fillColor?: any | string;
440
- outlineColor?: any | string;
441
- outlineWidth?: number;
442
- style?: any;
443
- pixelOffset?: Cesium.Cartesian2;
444
- eyeOffset?: Cesium.Cartesian3;
445
- horizontalOrigin?: any;
446
- verticalOrigin?: any;
447
- heightReference?: any;
448
- scale?: number;
449
- showBackground?: boolean;
450
- backgroundColor?: any | string;
451
- backgroundPadding?: Cesium.Cartesian2;
452
- disableDepthTestDistance?: number;
453
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
454
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
455
- onClick?: (entity: Entity) => void;
456
- id?: string;
457
- }
458
-
459
- export interface IconOptions {
460
- position: OverlayPosition;
461
- image: string;
462
- width?: number;
463
- height?: number;
464
- scale?: number;
465
- rotation?: number;
466
- pixelOffset?: Cesium.Cartesian2;
467
- eyeOffset?: Cesium.Cartesian3;
468
- horizontalOrigin?: any;
469
- verticalOrigin?: any;
470
- heightReference?: any;
471
- disableDepthTestDistance?: number;
472
- color?: any | string;
473
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
474
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
475
- onClick?: (entity: Entity) => void;
476
- id?: string;
477
- }
478
-
479
- export interface SvgOptions {
480
- position: OverlayPosition;
481
- svg: string;
482
- width?: number;
483
- height?: number;
484
- scale?: number;
485
- rotation?: number;
486
- pixelOffset?: Cesium.Cartesian2;
487
- eyeOffset?: Cesium.Cartesian3;
488
- horizontalOrigin?: any;
489
- verticalOrigin?: any;
490
- heightReference?: any;
491
- disableDepthTestDistance?: number;
492
- color?: any | string;
493
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
494
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
495
- onClick?: (entity: Entity) => void;
496
- id?: string;
497
- }
498
-
499
- export interface PolylineOptions {
500
- positions: OverlayPosition[];
501
- width?: number;
502
- material?: Cesium.MaterialProperty | any | string;
503
- clampToGround?: boolean;
504
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
505
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
506
- onClick?: (entity: Entity) => void;
507
- id?: string;
508
- }
509
-
510
- export interface PolygonOptions {
511
- positions: OverlayPosition[];
512
- /** 渲染模式:auto(默认) / entity / primitive(贴地粗边框纯色场景支持) */
513
- renderMode?: 'auto' | 'entity' | 'primitive';
514
- material?: Cesium.MaterialProperty | any | string;
515
- outline?: boolean;
516
- outlineColor?: any | string;
517
- outlineWidth?: number;
518
- clampToGround?: boolean;
519
- heightReference?: any;
520
- extrudedHeight?: number;
521
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
522
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
523
- onClick?: (entity: Entity) => void;
524
- /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
525
- layerKey?: string;
526
- id?: string;
527
- }
528
-
529
- export interface RectangleOptions {
530
- coordinates: Cesium.Rectangle;
531
- renderMode?: 'auto' | 'entity' | 'primitive';
532
- material?: Cesium.MaterialProperty | any | string;
533
- outline?: boolean;
534
- outlineColor?: any | string;
535
- outlineWidth?: number;
536
- clampToGround?: boolean;
537
- height?: number;
538
- heightReference?: any;
539
- extrudedHeight?: number;
540
- heightEpsilon?: number;
541
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
542
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
543
- onClick?: (entity: Entity) => void;
544
- /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
545
- layerKey?: string;
546
- id?: string;
547
- }
548
-
549
- export interface CircleOptions {
550
- position: OverlayPosition;
551
- radius: number;
552
- /** 渲染模式:auto(默认) / entity / primitive(预留) */
553
- renderMode?: 'auto' | 'entity' | 'primitive';
554
- material?: Cesium.MaterialProperty | any | string;
555
- outline?: boolean;
556
- outlineColor?: any | string;
557
- outlineWidth?: number;
558
- segments?: number;
559
- clampToGround?: boolean;
560
- heightReference?: any;
561
- extrudedHeight?: number;
562
- heightEpsilon?: number; // 高度容差,用于环形方案
563
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
564
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
565
- onClick?: (entity: Entity) => void;
566
- /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
567
- layerKey?: string;
568
- id?: string;
569
- }
570
-
571
- export interface RingOptions {
572
- /** 中心点(经纬度/高度 或 Cartesian3) */
573
- position: OverlayPosition;
574
- /** 半径(米) */
575
- radius: number;
576
- /** 边缘发光颜色 */
577
- color?: any | string;
578
- /** 是否绘制内层线(默认 true)。关闭可去掉“白色芯子” */
579
- showInnerLine?: boolean;
580
- /** 内层线颜色 */
581
- lineColor?: any | string;
582
- /** 内层线型:实线/虚线(默认 solid) */
583
- lineStyle?: 'solid' | 'dashed';
584
- /** 虚线材质方案:stripe(默认) / dash */
585
- lineMaterialMode?: 'stripe' | 'dash';
586
- /** stripe 模式:条纹重复次数(默认 32) */
587
- stripeRepeat?: number;
588
- /** 虚线长度(像素,默认 16) */
589
- dashLength?: number;
590
- /** 虚线模式(16bit pattern,可选) */
591
- dashPattern?: number;
592
- /** 虚线间隙颜色(默认透明) */
593
- gapColor?: any | string;
594
- /** 线宽(像素) */
595
- width?: number;
596
- /** 外层发光线宽(像素)。优先于 width */
597
- glowWidth?: number;
598
- /** 内层线宽(像素)。不传则使用自动计算 */
599
- lineWidth?: number;
600
- /** 发光强度(0-1),越大越“亮/粗” */
601
- glowPower?: number;
602
- /** 是否贴地(默认 true) */
603
- clampToGround?: boolean;
604
- /** 圆环分段数(默认 128),越大越圆滑 */
605
- segments?: number;
606
- clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
607
- hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
608
- /** 覆盖物点击回调 */
609
- onClick?: (entity: Entity) => void;
610
- id?: string;
611
- }
612
-
613
- export declare class CesiumOverlayService {
614
- constructor(viewer: Viewer);
615
- toggleOverlayHighlight(entity: any, reason?: 'click' | 'hover'): void;
616
- addMarker(options: MarkerOptions): any; // 返回 Cesium.Entity
617
- addLabel(options: LabelOptions): any; // 返回 Cesium.Entity
618
- addIcon(options: IconOptions): any; // 返回 Cesium.Entity
619
- addSvg(options: SvgOptions): any; // 返回 Cesium.Entity
620
- addInfoWindow(options: InfoWindowOptions): any; // 返回 Cesium.Entity
621
- addPolyline(options: PolylineOptions): any; // 返回 Cesium.Entity
622
- addPolygon(options: PolygonOptions): any; // 返回 Cesium.Entity
623
- addRectangle(options: RectangleOptions): any; // 返回 Cesium.Entity
624
- addCircle(options: CircleOptions): any; // 返回 Cesium.Entity
625
- addRing(options: RingOptions): any; // 返回 Cesium.Entity
626
- getOverlay(id: string): any | undefined; // 返回 Cesium.Entity | undefined
627
- removeOverlay(id: string): boolean;
628
- removeAllOverlays(): void;
629
- updateOverlayPosition(id: string, position: Cartesian3 | [number, number, number?]): boolean;
630
- setOverlayVisible(id: string, visible: boolean): boolean;
631
- setOverlayHighlight(entityOrId: any | string, enabled: boolean, reason?: 'click' | 'hover'): boolean;
632
- getAllOverlayIds(): string[];
633
- getAllOverlays(): any[]; // Cesium.Entity[]
634
- destroy(): void;
635
- }
636
-
637
- // 单个信息窗口工具类(与 libs/overlay/MapInfoWindow.ts 保持一致)
638
- export declare class MapInfoWindow {
639
- constructor(viewer: Viewer, container: HTMLElement);
640
- setDefaultUpdateInterval(ms: number): void;
641
- forceUpdateAll(): void;
642
- add(options: InfoWindowOptions): Entity;
643
- update(options: Partial<InfoWindowOptions> & { id: string }): void;
644
- updatePosition(entity: Entity, position: OverlayPosition): void;
645
- setVisible(entity: Entity, visible: boolean): void;
646
- remove(entity: Entity): void;
647
- removeAll(): void;
648
- destroy(): void;
649
- }
650
-
651
- // Overlay: 工具类声明(只暴露主要方法)
652
- export declare class MapMarker {
653
- constructor(viewer: Viewer);
654
- add(options: MarkerOptions): Entity;
655
- updatePosition(entity: Entity, position: OverlayPosition): void;
656
- updateStyle(entity: Entity, options: Partial<Pick<MarkerOptions, 'color' | 'outlineColor' | 'outlineWidth' | 'pixelSize'>>): void;
657
- }
658
-
659
- export declare class MapLabel {
660
- constructor(viewer: Viewer);
661
- add(options: LabelOptions): Entity;
662
- updatePosition(entity: Entity, position: OverlayPosition): void;
663
- }
664
-
665
- export declare class MapIcon {
666
- constructor(viewer: Viewer);
667
- add(options: IconOptions): Entity;
668
- updatePosition(entity: Entity, position: OverlayPosition): void;
669
- updateImage(entity: Entity, image: string): void;
670
- }
671
-
672
- export declare class MapSVG {
673
- constructor(viewer: Viewer);
674
- add(options: SvgOptions): Entity;
675
- updatePosition(entity: Entity, position: OverlayPosition): void;
676
- }
677
-
678
- export declare class MapPolyline {
679
- constructor(viewer: Viewer);
680
- add(options: PolylineOptions): Entity;
681
- updatePositions(entity: Entity, positions: OverlayPosition[]): void;
682
- updateStyle(entity: Entity, options: Partial<Pick<PolylineOptions, 'width' | 'material'>>): void;
683
- }
684
-
685
- export declare class MapPolygon {
686
- constructor(viewer: Viewer);
687
- add(options: PolygonOptions): Entity;
688
- updatePositions(entity: Entity, positions: OverlayPosition[]): void;
689
- updateStyle(entity: Entity, options: Partial<Pick<PolygonOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
690
- remove(entityOrId: Entity | string): boolean;
691
- }
692
-
693
- export declare class MapRectangle {
694
- constructor(viewer: Viewer);
695
- add(options: RectangleOptions): Entity;
696
- updateCoordinates(entity: Entity, coordinates: Cesium.Rectangle): void;
697
- updateStyle(entity: Entity, options: Partial<Pick<RectangleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
698
- remove(entityOrId: Entity | string): boolean;
699
- }
700
-
701
- export declare class MapCircle {
702
- constructor(viewer: Viewer);
703
- add(options: CircleOptions): Entity;
704
- updatePosition(entity: Entity, position: OverlayPosition): void;
705
- updateRadius(entity: Entity, radius: number): void;
706
- updateStyle(entity: Entity, options: Partial<Pick<CircleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
707
- }
708
-
709
- export declare class MapRing {
710
- constructor(viewer: Viewer);
711
- add(options: RingOptions): Entity;
712
- updatePosition(entity: Entity, position: OverlayPosition): void;
713
- updateRadius(entity: Entity, radius: number): void;
714
- updateStyle(
715
- entity: Entity,
716
- options: Partial<
717
- Pick<
718
- RingOptions,
719
- | 'color'
720
- | 'showInnerLine'
721
- | 'lineColor'
722
- | 'lineStyle'
723
- | 'lineMaterialMode'
724
- | 'stripeRepeat'
725
- | 'dashLength'
726
- | 'dashPattern'
727
- | 'gapColor'
728
- | 'width'
729
- | 'glowWidth'
730
- | 'lineWidth'
731
- | 'glowPower'
732
- | 'clampToGround'
733
- | 'segments'
734
- >
735
- >
736
- ): void;
737
- setVisible(entity: Entity, visible: boolean): void;
738
- remove(entityOrId: Entity | string): boolean;
739
- }
740
-
741
- // toolbar: 相机控制器及服务(与工具栏相关类保持一致)
742
- export interface MapInitialCenter {
743
- longitude: number;
744
- latitude: number;
745
- height: number;
746
- }
747
-
748
- export interface CesiumMapControllerOptions {
749
- initialCenter?: MapInitialCenter;
750
- getMapTypes?: () => MapType[];
751
- getCurrentMapTypeId?: () => string;
752
- getToken?: () => string;
753
- zoomCallback?: ZoomCallback;
754
- onSceneModeChanged?: () => void;
755
- /** 全屏切换回调 */
756
- fullscreenCallback?: (isFullscreen: boolean) => void;
757
- /** 复位位置回调 */
758
- resetLocationCallback?: () => void;
759
- }
760
-
761
- export declare class CesiumMapController {
762
- constructor(viewer: Viewer, options?: CesiumMapControllerOptions);
763
- setupCameraZoomLimitListener(): void;
764
- getCurrentZoomLevel(): number;
765
- setZoomLevel(zoomLevel: number): void;
766
- zoomIn(): void;
767
- zoomOut(): void;
768
- toggle2D3D(buttonElement: HTMLElement): void;
769
- resetLocation(): void;
770
- setInitialCenter(center: MapInitialCenter): void;
771
- getInitialCenter(): MapInitialCenter | undefined;
772
- toggleFullscreen(): void;
773
- isFullscreen(): boolean;
774
- enterFullscreen(): void;
775
- exitFullscreen(): void;
776
- }
777
-
778
- export interface MapLayersServiceConfig {
779
- mapTypes: MapType[];
780
- currentMapType: string;
781
- token: string;
782
- isNoFlyZoneChecked: boolean;
783
- isNoFlyZoneVisible: boolean;
784
- onMapTypeChange?: (mapTypeId: string) => void;
785
- onNoFlyZoneToggle?: (isChecked: boolean) => void;
786
- onShowNoFlyZones?: () => Promise<void> | void;
787
- }
788
-
789
- export declare class MapLayersService {
790
- constructor(viewer: Viewer, toolbarElement: HTMLElement, config: MapLayersServiceConfig);
791
- updateConfig(config: Partial<MapLayersServiceConfig>): void;
792
- toggleLayers(buttonElement: HTMLElement): void;
793
- switchMapType(mapTypeId: string): void;
794
- getCurrentMapType(): string;
795
- closeLayersMenu(): void;
796
- destroy(): void;
797
- }
798
-
799
- export declare class SearchService {
800
- constructor(viewer: Viewer, toolbarElement: HTMLElement, searchCallback?: SearchCallback);
801
- setSearchCallback(callback: SearchCallback): void;
802
- toggleSearch(buttonElement: HTMLElement): void;
803
- displaySearchResults(results: SearchResult[], container: HTMLElement): void;
804
- selectSearchResult(result: SearchResult): void;
805
- closeSearchContainer(): void;
806
- destroy(): void;
807
- }
808
-
809
- export interface NotFlyZonesServiceConfig {
810
- extrudedHeight?: number;
811
- autoLoad?: boolean;
812
- }
813
-
814
- export declare class NotFlyZonesService {
815
- constructor(viewer: Viewer, config?: NotFlyZonesServiceConfig);
816
- showNoFlyZones(): Promise<void>;
817
- hideNoFlyZones(): void;
818
- toggleNoFlyZones(): Promise<void>;
819
- getNoFlyZoneVisible(): boolean;
820
- destroy(): void;
821
- }
822
-
823
- // 工具栏按钮默认配置与排序(来自 MapToolBarConfig.ts)
824
- export declare const defaultButtonSorts: Record<string, number>;
825
- export declare const defaultButtons: ButtonConfig[];
826
-
827
- // 绘制相关类型(与内部实现保持一致)
828
- // 绘制底层工具类型(与 drawHelper/BaseDraw.ts 保持一致)
829
- export interface DrawResult {
830
- entity: Entity | null;
831
- type: 'line' | 'polygon' | 'rectangle' | 'circle';
832
- positions: Cartesian3[];
833
- distance?: number;
834
- areaKm2?: number;
835
- }
836
-
837
- export interface DrawCallbacks {
838
- onDrawStart?: () => void;
839
- onDrawEnd?: (entity: Entity | null, result: DrawResult) => void;
840
- onEntityRemoved?: (entity: Entity) => void;
841
- onMeasureComplete?: (result: DrawResult) => void;
842
- }
843
-
844
- export interface DrawOptions {
845
- strokeColor?: Cesium.Color | string;
846
- strokeWidth?: number;
847
- fillColor?: Cesium.Color | string;
848
- outlineColor?: Cesium.Color | string;
849
- outlineWidth?: number;
850
- heightEpsilon?: number;
851
- selected?: {
852
- color?: Cesium.Color | string;
853
- width?: number;
854
- outlineColor?: Cesium.Color | string;
855
- outlineWidth?: number;
856
- };
857
- /**
858
- * 是否显示面积标签(适用于 polygon/rectangle/circle)。
859
- * 默认 true;设为 false 可禁用绘制完成后自动创建的面积标签。
860
- */
861
- showAreaLabel?: boolean;
862
-
863
- /**
864
- * 是否启用多边形自相交校验。
865
- * - false/未设置:默认允许交叉(不做校验)
866
- * - true:启用自相交校验(结合 selfIntersectionAllowTouch/AllowContinue 控制行为)
867
- */
868
- selfIntersectionEnabled?: boolean;
869
-
870
- /**
871
- * 多边形自相交校验:是否允许“擦边/顶点落在旧边上”等仅接触(touch)情况。
872
- * - false/未设置:touch 也视为不合法
873
- * - true:允许 touch,但仍不允许重叠(overlap)与真正穿越(cross)
874
- */
875
- selfIntersectionAllowTouch?: boolean;
876
-
877
- /**
878
- * 多边形自相交校验:当即将产生自相交时,是否仍允许继续绘制/完成绘制。
879
- * - false/未设置:检测到自相交则阻止落点/阻止完成
880
- * - true:检测到自相交不拦截(由业务自行承担后续面积/中心等偏差风险)
881
- */
882
- selfIntersectionAllowContinue?: boolean;
883
- onClick?: (entity: Entity, type?: 'line' | 'polygon' | 'rectangle' | 'circle', positions?: Cartesian3[]) => void;
884
- }
885
-
886
- /**
887
- * 绘制模块扩展实体类型(用于在 Entity 上挂载绘图相关元数据)
888
- */
889
- export interface DrawEntity extends Entity {
890
- _drawType?: 'line' | 'polygon' | 'rectangle' | 'circle';
891
- _drawOptions?: DrawOptions;
892
- _groundPositions?: Cartesian3[];
893
- _groundPosition?: Cartesian3;
894
- _groundRectangle?: Cesium.Rectangle;
895
- _radius?: number;
896
- _borderEntity?: Entity;
897
- /** 关联的测量/提示标签实体(例如面积标签) */
898
- _labelEntities?: Entity[];
899
- _onClick?: (entity: Entity, ...args: any[]) => void;
900
- }
901
-
902
- export declare class DrawHelper {
903
- constructor(viewer: Viewer);
904
- // 开始绘制(可选样式参数)
905
- startDrawingLine(options?: DrawOptions): void;
906
- startDrawingPolygon(options?: DrawOptions): void;
907
- startDrawingRectangle(options?: DrawOptions): void;
908
- startDrawingCircle(options?: DrawOptions): void;
909
- // 控制绘制流程
910
- endDrawing(): void;
911
- // 清理与管理
912
- clearAll(): void;
913
- clearAllEntities(): void;
914
- clearAllPoints(): void;
915
- removeEntity(entity: Entity): void;
916
- getFinishedEntities(): Entity[];
917
- /** 获取绘制实体关联的标签实体(例如面积标签) */
918
- getEntityLabelEntities(entity: Entity): Entity[];
919
- // 事件回调注册
920
- onMeasureComplete(callback: (result: DrawResult) => void): void;
921
- onDrawStart(callback: () => void): void;
922
- onDrawEnd(callback: (entity: Entity | null) => void): void;
923
- onEntityRemoved(callback: (entity: Entity) => void): void;
924
- // 场景模式切换适配
925
- handleSceneModeChanged(): void;
926
- // 资源释放
927
- destroy(): void;
928
- }
929
-
930
- // 底层抽象绘制类及具体实现(通过 `export * from './libs/drawHelper/index'` 暴露)
931
- export declare abstract class BaseDraw {
932
- protected viewer: Viewer;
933
- protected scene: Cesium.Scene;
934
- protected entities: Cesium.EntityCollection;
935
- protected offsetHeight: number;
936
- protected originalDepthTestAgainstTerrain: boolean | null;
937
- protected originalRequestRenderMode: boolean | null;
938
- protected callbacks: DrawCallbacks;
939
- protected tempPositions: Cartesian3[];
940
- protected tempEntities: Entity[];
941
- protected tempLabelEntities: Entity[];
942
- protected finishedPointEntities: Entity[];
943
- protected drawOptions?: DrawOptions;
944
- protected resolveColor(input?: Cesium.Color | string): Cesium.Color;
945
- protected applySelectedStyleToEntity(entity: Entity): void;
946
- protected restoreOriginalStyleForEntity(entity: Entity): void;
947
- protected updateOffsetHeight(): void;
948
- protected pickGlobePosition(windowPosition: Cesium.Cartesian2): Cartesian3 | null;
949
- protected rememberOriginalRequestRenderModeIfNeeded(): void;
950
- protected restoreRequestRenderModeIfNeeded(): void;
951
- abstract updateDrawingEntity(previewPoint?: Cartesian3): void;
952
- abstract startDrawing(options?: DrawOptions): void;
953
- abstract finishDrawing(): DrawResult | null;
954
- abstract getDrawType(): 'line' | 'polygon' | 'rectangle' | 'circle';
955
- }
956
-
957
- export declare class DrawLine extends BaseDraw {
958
- updateDrawingEntity(previewPoint?: Cartesian3): void;
959
- startDrawing(options?: DrawOptions): void;
960
- finishDrawing(): DrawResult | null;
961
- getDrawType(): 'line';
962
- }
963
-
964
- export declare class DrawPolygon extends BaseDraw {
965
- updateDrawingEntity(previewPoint?: Cartesian3): void;
966
- startDrawing(options?: DrawOptions): void;
967
- finishDrawing(): DrawResult | null;
968
- getDrawType(): 'polygon';
969
- }
970
-
971
- export declare class DrawRectangle extends BaseDraw {
972
- updateDrawingEntity(previewPoint?: Cartesian3): void;
973
- startDrawing(options?: DrawOptions): void;
974
- finishDrawing(): DrawResult | null;
975
- getDrawType(): 'rectangle';
976
- }
977
-
978
- export declare class DrawCircle extends BaseDraw {
979
- updateDrawingEntity(previewPoint?: Cartesian3): void;
980
- startDrawing(options?: DrawOptions): void;
981
- finishDrawing(): DrawResult | null;
982
- getDrawType(): 'circle';
983
- }
984
-
985
- export declare function initCesium(
986
- containerId: string,
987
- options: InitOptions,
988
- mapCenterOrCesiumToken?: MapCenter | string,
989
- cesiumToken?: String
990
- ): Promise<{ viewer: Viewer; initialCenter: MapCenter }>;
991
-
992
- // 默认导出
993
- declare const _default: {
994
- CesiumMapToolbar: typeof CesiumMapToolbar;
995
- DrawHelper: typeof DrawHelper;
996
- CesiumOverlayService: typeof CesiumOverlayService;
997
- initCesium: typeof initCesium;
998
- initCesiumMap: typeof initCesium;
999
- };
1000
-
1001
- export default _default;
1002
-
1003
- // Heatmap-related types
1004
- export interface HeatmapOptions {
1005
- intensity?: number;
1006
- radius?: number;
1007
- gradient?: Record<number, string>;
1008
- }
1009
-
1010
- export interface HeatmapLayer {
1011
- addData(data: { x: number; y: number; value: number }[]): void;
1012
- setOptions(options: HeatmapOptions): void;
1013
- clear(): void;
1014
- }
1
+ import { CesiumMapToolbar } from './libs/CesiumMapToolbar';
2
+ import { default as DrawHelper } from './libs/CesiumMapDraw';
3
+ import { initCesium } from './libs/CesiumMapLoader';
4
+ import { CesiumOverlayService } from './libs/CesiumOverlayService';
5
+ import { default as CesiumHeatmapLayer } from './libs/CesiumHeatmapLayer';
6
+ import { default as CesiumPointClusterLayer } from './libs/CesiumPointClusterLayer';
7
+ export { CesiumMapToolbar } from './libs/CesiumMapToolbar';
8
+ export { default as DrawHelper } from './libs/CesiumMapDraw';
9
+ export { initCesium } from './libs/CesiumMapLoader';
10
+ export { i18n } from './libs/i18n';
11
+ export type { I18nLike } from './libs/i18n';
12
+ export type { OverlayOptions, ToolbarConfig, ButtonConfig, CustomButtonConfig, SearchCallback, SearchResult, MeasurementCallback, ZoomCallback, MapType, } from './libs/CesiumMapModel';
13
+ export * from './libs/overlay/index';
14
+ export type * from './libs/overlay/index';
15
+ export * from './libs/drawHelper/index';
16
+ export type * from './libs/drawHelper/index';
17
+ export { CesiumOverlayService } from './libs/CesiumOverlayService';
18
+ export type * from './libs/CesiumOverlayService';
19
+ export * from './libs/toolBar/CesiumMapController';
20
+ export type * from './libs/toolBar/CesiumMapController';
21
+ export * from './libs/toolBar/MapLayersService';
22
+ export type * from './libs/toolBar/MapLayersService';
23
+ export * from './libs/toolBar/MapSearchService';
24
+ export type * from './libs/toolBar/MapSearchService';
25
+ export * from './libs/toolBar/MapToolBarConfig';
26
+ export type * from './libs/toolBar/MapToolBarConfig';
27
+ export * from './libs/toolBar/NotFlyZonesService';
28
+ export type * from './libs/toolBar/NotFlyZonesService';
29
+ export { CesiumHeatmapLayer as HeatmapLayer };
30
+ export type { HeatmapOptions } from './libs/CesiumHeatmapLayer';
31
+ export { CesiumPointClusterLayer as PointClusterLayer };
32
+ export type { ClusterPoint, PointClusterLayerOptions, ClusterStyleStep } from './libs/CesiumPointClusterLayer';
33
+ declare const _default: {
34
+ CesiumMapToolbar: typeof CesiumMapToolbar;
35
+ DrawHelper: typeof DrawHelper;
36
+ CesiumOverlayService: typeof CesiumOverlayService;
37
+ initCesium: typeof initCesium;
38
+ initCesiumMap: typeof initCesium;
39
+ HeatmapLayer: typeof CesiumHeatmapLayer;
40
+ PointClusterLayer: typeof CesiumPointClusterLayer;
41
+ };
42
+ export default _default;