@xingm/vmap-cesium-toolbar 0.0.2-alpha.15 → 0.0.2-alpha.16

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/README.md CHANGED
@@ -28,12 +28,14 @@ import { CesiumMapToolbar, initCesium } from '@xingm/vmap-cesium-toolbar';
28
28
  import '@xingm/vmap-cesium-toolbar/style';
29
29
 
30
30
  // 初始化Cesium
31
- const viewer = initCesium('cesiumContainer', {
32
- terrainProvider: Cesium.createWorldTerrain()
33
- });
31
+ (async () => {
32
+ const { viewer } = await initCesium('cesiumContainer', {
33
+ terrainProvider: Cesium.createWorldTerrain(),
34
+ });
34
35
 
35
- // 创建工具栏
36
- const toolbar = new CesiumMapToolbar(viewer, document.getElementById('toolbar'));
36
+ // 创建工具栏
37
+ const toolbar = new CesiumMapToolbar(viewer, document.getElementById('toolbar'));
38
+ })();
37
39
  ```
38
40
 
39
41
  ### Vue 3 项目中使用
@@ -52,11 +54,12 @@ import '@xingm/vmap-cesium-toolbar/style';
52
54
  let viewer;
53
55
  let toolbar;
54
56
 
55
- onMounted(() => {
57
+ onMounted(async () => {
56
58
  // 初始化Cesium
57
- viewer = initCesium('cesiumContainer', {
58
- terrainProvider: Cesium.createWorldTerrain()
59
+ const result = await initCesium('cesiumContainer', {
60
+ terrainProvider: Cesium.createWorldTerrain(),
59
61
  });
62
+ viewer = result.viewer;
60
63
 
61
64
  // 创建工具栏
62
65
  toolbar = new CesiumMapToolbar(viewer, document.getElementById('toolbar'));
@@ -80,30 +83,26 @@ const toolbar = new CesiumMapToolbar(
80
83
  );
81
84
  ```
82
85
 
83
- ### CesiumMapHelper
86
+ ### DrawHelper
84
87
 
85
- 地图辅助工具类,提供绘制和测量功能。
88
+ 绘制工具类(包的默认导出),提供线/面/矩形/圆等交互绘制能力。
86
89
 
87
90
  ```typescript
88
- import { CesiumMapHelper } from '@xingm/vmap-cesium-toolbar';
91
+ import DrawHelper from '@xingm/vmap-cesium-toolbar';
89
92
 
90
- const helper = new CesiumMapHelper(viewer);
91
- helper.startDrawing('line'); // 开始绘制线条
92
- helper.startMeasurement('distance'); // 开始距离测量
93
+ const drawHelper = new DrawHelper(viewer);
94
+ drawHelper.startDrawingPolygon();
93
95
  ```
94
96
 
95
- ### CesiumMapLoader
97
+ ### initCesium
96
98
 
97
- Cesium初始化工具,简化Cesium的配置和初始化。
99
+ Cesium 初始化函数,简化 Viewer 创建、底图/地形与初始视角配置。
98
100
 
99
101
  ```typescript
100
- import { CesiumMapLoader } from '@xingm/vmap-cesium-toolbar';
102
+ import { initCesium } from '@xingm/vmap-cesium-toolbar';
101
103
 
102
- const viewer = CesiumMapLoader.init('container', {
103
- terrainProvider: Cesium.createWorldTerrain(),
104
- imageryProvider: new Cesium.OpenStreetMapImageryProvider({
105
- url: 'https://a.tile.openstreetmap.org/'
106
- })
104
+ const { viewer } = await initCesium('cesiumContainer', {
105
+ cesiumToken: 'your_cesium_ion_token',
107
106
  });
108
107
  ```
109
108
 
@@ -231,6 +230,7 @@ npm run dev
231
230
  - [CesiumMapToolbar API](./doc/CesiumMapToolbar_API.md)
232
231
  - [CesiumMapHelper API](./doc/CesiumMapHelper_API.md)
233
232
  - [CesiumMapLoader API](./doc/CesiumMapLoader_API.md)
233
+ - [CesiumOverlayService API](./doc/CesiumOverlayService_API.md)
234
234
 
235
235
  ## 依赖要求
236
236
 
package/dist/index.d.ts CHANGED
@@ -216,9 +216,33 @@ export declare class CesiumMapToolbar {
216
216
  search?: SearchCallback;
217
217
  measurement?: MeasurementCallback;
218
218
  zoom?: ZoomCallback;
219
+ fullscreen?: (isFullscreen: boolean) => void;
220
+ resetLocation?: () => void;
219
221
  },
220
222
  initialCenter?: { longitude: number; latitude: number; height: number }
221
223
  );
224
+
225
+ /** 天地图 Token(可直接修改或配合 setTDToken) */
226
+ TD_Token: string;
227
+
228
+ /** 当前可用的底图类型列表 */
229
+ mapTypes: MapType[];
230
+
231
+ /** 获取内部搜索服务实例 */
232
+ getSearchService(): SearchService;
233
+
234
+ /** 获取内部禁飞区服务实例 */
235
+ getNotFlyZonesService(): NotFlyZonesService;
236
+
237
+ /** 获取内部测量服务实例 */
238
+ getMeasurementService(): any; // MeasurementService (内部未在 d.ts 中单独暴露)
239
+
240
+ /** 获取内部地图控制器实例 */
241
+ getCesiumMapCtrl(): CesiumMapController;
242
+
243
+ /** 获取内部图层服务实例 */
244
+ getMapLayersService(): MapLayersService;
245
+
222
246
  setMapTypes(mapTypes: MapType[]): void;
223
247
  setTDToken(TD_Token: string): void;
224
248
  setInitialCenter(center: { longitude: number; latitude: number; height: number }): void;
@@ -298,6 +322,9 @@ export interface OverlayEntity extends Entity {
298
322
  _innerRadius?: number;
299
323
  _outerRectangle?: Cesium.Rectangle;
300
324
 
325
+ /** primitive layer key: 用于分层批处理路由 */
326
+ _primitiveLayerKey?: string;
327
+
301
328
  /** primitive circle: 内部使用的纯色缓存(用于高亮恢复) */
302
329
  _primitiveRingBaseColor?: any;
303
330
  _primitiveFillBaseColor?: any;
@@ -451,6 +478,8 @@ export interface PolygonOptions {
451
478
  clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
452
479
  hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
453
480
  onClick?: (entity: Entity) => void;
481
+ /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
482
+ layerKey?: string;
454
483
  id?: string;
455
484
  }
456
485
 
@@ -469,6 +498,8 @@ export interface RectangleOptions {
469
498
  clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
470
499
  hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
471
500
  onClick?: (entity: Entity) => void;
501
+ /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
502
+ layerKey?: string;
472
503
  id?: string;
473
504
  }
474
505
 
@@ -489,6 +520,8 @@ export interface CircleOptions {
489
520
  clickHighlight?: boolean | { color?: any | string; fillAlpha?: number };
490
521
  hoverHighlight?: boolean | { color?: any | string; fillAlpha?: number };
491
522
  onClick?: (entity: Entity) => void;
523
+ /** primitive 分层渲染 key(不同 key 会进入不同批次并按创建顺序确定上下层) */
524
+ layerKey?: string;
492
525
  id?: string;
493
526
  }
494
527
 
@@ -676,6 +709,10 @@ export interface CesiumMapControllerOptions {
676
709
  getToken?: () => string;
677
710
  zoomCallback?: ZoomCallback;
678
711
  onSceneModeChanged?: () => void;
712
+ /** 全屏切换回调 */
713
+ fullscreenCallback?: (isFullscreen: boolean) => void;
714
+ /** 复位位置回调 */
715
+ resetLocationCallback?: () => void;
679
716
  }
680
717
 
681
718
  export declare class CesiumMapController {
@@ -779,6 +816,14 @@ export interface DrawOptions {
779
816
  * 默认 true;设为 false 可禁用绘制完成后自动创建的面积标签。
780
817
  */
781
818
  showAreaLabel?: boolean;
819
+
820
+ /**
821
+ * 是否启用多边形自相交校验。
822
+ * - false/未设置:默认允许交叉(不做校验)
823
+ * - true:启用自相交校验(结合 selfIntersectionAllowTouch/AllowContinue 控制行为)
824
+ */
825
+ selfIntersectionEnabled?: boolean;
826
+
782
827
  /**
783
828
  * 多边形自相交校验:是否允许“擦边/顶点落在旧边上”等仅接触(touch)情况。
784
829
  * - false/未设置:touch 也视为不合法