@xingm/vmap-cesium-toolbar 0.0.2-alpha.17 → 0.0.2-alpha.18
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/hooks/useMapInit.d.ts +14 -0
- package/dist/hooks/useOverlayHelper.d.ts +6 -0
- package/dist/index.d.ts +37 -993
- package/dist/{index.js → index.es.js} +1230 -782
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +8 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/libs/CesiumAutoRecover.d.ts +48 -0
- package/dist/libs/CesiumHeatmapLayer.d.ts +20 -0
- package/dist/libs/CesiumMapLoader.d.ts +3 -0
- package/dist/libs/CesiumOverlayService.d.ts +29 -0
- package/dist/libs/drawHelper/DrawPolgon.d.ts +5 -0
- package/dist/libs/i18n/index.d.ts +1 -0
- package/dist/libs/overlay/primitives/CirclePrimitiveLayerStack.d.ts +5 -5
- package/dist/libs/overlay/primitives/PolygonPrimitiveLayerStack.d.ts +5 -5
- package/dist/libs/toolBar/MapToolBarConfig.d.ts +8 -1
- package/dist/package.json +7 -6
- package/package.json +6 -5
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Viewer } from '../../node_modules/cesium';
|
|
2
|
+
export interface CesiumAutoRecoverOptions {
|
|
3
|
+
/** 是否启用自动恢复(默认 false) */
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
/** 最大恢复次数(默认 3) */
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
/** 两次恢复之间的最小间隔(默认 5000ms) */
|
|
8
|
+
cooldownMs?: number;
|
|
9
|
+
/** 恢复后是否尝试保留相机视角(默认 true) */
|
|
10
|
+
preserveCamera?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 触发恢复的原因与错误信息
|
|
13
|
+
* - reason: renderError/widgetError/watchdog/windowError 等
|
|
14
|
+
*/
|
|
15
|
+
onRecovering?: (ctx: {
|
|
16
|
+
reason: string;
|
|
17
|
+
error?: unknown;
|
|
18
|
+
attempt: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
/** 恢复成功回调:业务侧应在这里替换引用(非常重要) */
|
|
21
|
+
onRecovered?: (ctx: {
|
|
22
|
+
reason: string;
|
|
23
|
+
error?: unknown;
|
|
24
|
+
attempt: number;
|
|
25
|
+
oldViewer: Viewer;
|
|
26
|
+
newViewer: Viewer;
|
|
27
|
+
}) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 渲染“静默停止”监测:有些错误不一定走 renderError,但会导致不再 postRender。
|
|
30
|
+
* 注意:若开启了 requestRenderMode(按需渲染),默认不建议启用 watchdog。
|
|
31
|
+
*/
|
|
32
|
+
watchdog?: {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** 多久没有 postRender 认为卡死(默认 6000ms) */
|
|
35
|
+
staleMs?: number;
|
|
36
|
+
/** 检查间隔(默认 2000ms) */
|
|
37
|
+
checkIntervalMs?: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
type CreateViewer = () => Promise<Viewer>;
|
|
41
|
+
/**
|
|
42
|
+
* 为已有 Viewer 安装自动恢复:遇到“Rendering has stopped”/NaN render error 等,自动重建 Viewer。
|
|
43
|
+
* 重要:重建会产生新的 Viewer 实例,业务侧必须在 onRecovered 里替换引用。
|
|
44
|
+
*/
|
|
45
|
+
export declare function enableCesiumAutoRecover(viewer: Viewer, createViewer: CreateViewer, options: CesiumAutoRecoverOptions): {
|
|
46
|
+
dispose: () => void;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
@@ -18,6 +18,8 @@ export interface HeatmapOptions {
|
|
|
18
18
|
/** Canvas 分辨率,越大越清晰但开销越大 */
|
|
19
19
|
width?: number;
|
|
20
20
|
height?: number;
|
|
21
|
+
/** 渲染模式:heat 为热力渐变(默认);discrete 为严格分段纯色 */
|
|
22
|
+
mode?: "heat" | "discrete";
|
|
21
23
|
/** 单个点的影响半径(像素) */
|
|
22
24
|
radius?: number;
|
|
23
25
|
/** 低强度提升(伽马矫正),< 1 可增强边缘,默认 0.7 */
|
|
@@ -31,6 +33,20 @@ export interface HeatmapOptions {
|
|
|
31
33
|
opacity?: number;
|
|
32
34
|
/** 颜色梯度 */
|
|
33
35
|
gradient?: HeatmapGradient;
|
|
36
|
+
/**
|
|
37
|
+
* 严格分段(仅 mode=discrete 生效):
|
|
38
|
+
* thresholds.length + 1 必须等于 colors.length。
|
|
39
|
+
* 例如 thresholds=[40,60,90,110] colors=[蓝,青,绿,黄,红]
|
|
40
|
+
* - value < 40 -> colors[0]
|
|
41
|
+
* - 40 <= value < 60 -> colors[1]
|
|
42
|
+
* - 60 <= value < 90 -> colors[2]
|
|
43
|
+
* - 90 <= value < 110 -> colors[3]
|
|
44
|
+
* - value >= 110 -> colors[4]
|
|
45
|
+
*/
|
|
46
|
+
discreteThresholds?: number[];
|
|
47
|
+
discreteColors?: string[];
|
|
48
|
+
/** 重叠像素的决策:max=取更高分段(默认);last=后绘制覆盖 */
|
|
49
|
+
discreteOverlap?: "max" | "last";
|
|
34
50
|
}
|
|
35
51
|
export interface HeatmapAutoUpdateOptions {
|
|
36
52
|
/** 是否启用随视角变化自动重绘(默认 true) */
|
|
@@ -64,7 +80,11 @@ export default class CesiumHeatmapLayer {
|
|
|
64
80
|
private workerReady;
|
|
65
81
|
private pendingUpdate;
|
|
66
82
|
private lastUpdateKey;
|
|
83
|
+
private handleWorkerFault;
|
|
67
84
|
constructor(viewer: Cesium.Viewer, options?: HeatmapOptions);
|
|
85
|
+
private parseColorToRGBA;
|
|
86
|
+
private getDiscreteBucketIndex;
|
|
87
|
+
private renderDiscrete;
|
|
68
88
|
/**
|
|
69
89
|
* 设置/替换热力图数据(度为单位)
|
|
70
90
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Viewer as CesiumViewer, Terrain, TerrainProvider } from '../../node_modules/cesium';
|
|
2
|
+
import { CesiumAutoRecoverOptions } from './CesiumAutoRecover';
|
|
2
3
|
import * as Cesium from 'cesium';
|
|
3
4
|
interface InitOptions {
|
|
4
5
|
orderIndependentTranslucency?: boolean;
|
|
@@ -50,6 +51,8 @@ interface InitOptions {
|
|
|
50
51
|
success?: () => void;
|
|
51
52
|
cancel?: () => void;
|
|
52
53
|
mapCenter?: MapCenter;
|
|
54
|
+
/** 渲染异常自动恢复(可选):会重建 Viewer,需在回调里替换引用 */
|
|
55
|
+
autoRecover?: CesiumAutoRecoverOptions;
|
|
53
56
|
}
|
|
54
57
|
interface MapCenter {
|
|
55
58
|
latitude: number;
|
|
@@ -22,8 +22,37 @@ export declare class CesiumOverlayService {
|
|
|
22
22
|
private lastHoverTargets;
|
|
23
23
|
private hoverPickRAF;
|
|
24
24
|
private hoverPickPos;
|
|
25
|
+
private overlayMutationRevision;
|
|
26
|
+
private hoverSuspendUntil;
|
|
27
|
+
private lastHoverPickTime;
|
|
28
|
+
private lastHoverPickPos;
|
|
29
|
+
private bulkUpdateDepth;
|
|
25
30
|
private static readonly DEFAULT_HIGHLIGHT_COLOR;
|
|
26
31
|
private static readonly DEFAULT_HIGHLIGHT_FILL_ALPHA;
|
|
32
|
+
private static readonly HOVER_PICK_MIN_INTERVAL_MS;
|
|
33
|
+
private static readonly HOVER_PICK_MIN_MOVE_PX;
|
|
34
|
+
private static readonly HOVER_SUSPEND_AFTER_MUTATION_MS;
|
|
35
|
+
private markOverlayMutated;
|
|
36
|
+
/**
|
|
37
|
+
* 显式开始一次批量更新:在 begin/end 期间暂停 hover pick。
|
|
38
|
+
* 建议 websocket 批量 add/remove 覆盖物时包裹使用,降低 Cesium GroundPrimitive 异步重建窗口期的 pick/update 压力。
|
|
39
|
+
*/
|
|
40
|
+
beginBulkUpdate(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 结束一次批量更新。
|
|
43
|
+
*/
|
|
44
|
+
endBulkUpdate(): void;
|
|
45
|
+
/**
|
|
46
|
+
* 批量更新包裹器(自动 begin/end)。
|
|
47
|
+
*/
|
|
48
|
+
bulkUpdate<T>(fn: () => T): T;
|
|
49
|
+
/**
|
|
50
|
+
* Primitive 模式下,GeometryInstance.id 会是字符串(structured-cloneable),
|
|
51
|
+
* 需要映射回 overlayMap 内的根覆盖物 id。
|
|
52
|
+
*/
|
|
53
|
+
private normalizeOverlayPickId;
|
|
54
|
+
private resolveOverlayByPickId;
|
|
55
|
+
private resolvePickedOverlayEntity;
|
|
27
56
|
readonly marker: MapMarker;
|
|
28
57
|
readonly label: MapLabel;
|
|
29
58
|
readonly icon: MapIcon;
|
|
@@ -6,6 +6,11 @@ import { BaseDraw, DrawResult, DrawOptions } from './BaseDraw';
|
|
|
6
6
|
export declare class DrawPolygon extends BaseDraw {
|
|
7
7
|
private currentPolygonEntity;
|
|
8
8
|
private currentBorderEntity;
|
|
9
|
+
/**
|
|
10
|
+
* 结束绘制但未生成最终结果(例如点数不足/自相交被拦截)时的统一清理。
|
|
11
|
+
* 目标:不留下临时实体/状态副作用(尤其是 depthTestAgainstTerrain)。
|
|
12
|
+
*/
|
|
13
|
+
private abortFinishCleanup;
|
|
9
14
|
/**
|
|
10
15
|
* 开始绘制
|
|
11
16
|
*/
|
|
@@ -8,6 +8,7 @@ interface I18nLike {
|
|
|
8
8
|
t(key: string, params?: Record<string, any>, localeOverride?: Locale): string;
|
|
9
9
|
onLocaleChange(cb: (locale: Locale) => void): () => void;
|
|
10
10
|
bindElement(el: HTMLElement, key: string, attr?: "text" | "title" | "placeholder", params?: Record<string, any>): void;
|
|
11
|
+
updateElement(el: HTMLElement): void;
|
|
11
12
|
updateTree(root: HTMLElement): void;
|
|
12
13
|
addMessages?(locale: Locale, dict: I18nDict, options?: {
|
|
13
14
|
merge?: boolean;
|
|
@@ -5,13 +5,13 @@ export interface CirclePrimitiveLayerCollections {
|
|
|
5
5
|
ringCollection: Cesium.PrimitiveCollection;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 为 Circle(圆)Primitive 渲染维护一个稳定的有序图层栈。
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
10
|
+
* 渲染顺序:
|
|
11
|
+
* - 所有填充图层(从下到上)
|
|
12
|
+
* - 所有外环图层(从下到上)
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* 这样可以确保在存在多个半透明填充重叠时,外环边界仍然清晰可见。
|
|
15
15
|
*/
|
|
16
16
|
export declare class CirclePrimitiveLayerStack {
|
|
17
17
|
private viewer;
|
|
@@ -5,13 +5,13 @@ export interface PolygonPrimitiveLayerCollections {
|
|
|
5
5
|
borderCollection: Cesium.PrimitiveCollection;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 为 Polygon(多边形)Primitive 渲染维护一个稳定的有序图层栈。
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
10
|
+
* 渲染顺序:
|
|
11
|
+
* - 所有填充图层(从下到上)
|
|
12
|
+
* - 所有边框图层(从下到上)
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* 这样可以确保在存在多个半透明填充重叠时,边框仍然清晰可见。
|
|
15
15
|
*/
|
|
16
16
|
export declare class PolygonPrimitiveLayerStack {
|
|
17
17
|
private viewer;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { ButtonConfig } from '../CesiumMapModel';
|
|
1
|
+
import { ButtonConfig, ToolbarConfig } from '../CesiumMapModel';
|
|
2
2
|
export declare const defaultButtonSorts: Record<string, number>;
|
|
3
3
|
export declare const defaultButtons: ButtonConfig[];
|
|
4
|
+
export declare const defaultMeasureItems: {
|
|
5
|
+
id: string;
|
|
6
|
+
text: string;
|
|
7
|
+
textKey: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const defaultToolBarStyle: ToolbarConfig;
|
package/dist/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xingm/vmap-cesium-toolbar",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.18",
|
|
4
4
|
"description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"module": "index.js",
|
|
6
|
+
"main": "index.es.js",
|
|
7
|
+
"module": "index.es.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"index.js",
|
|
10
|
+
"index.es.js",
|
|
11
|
+
"index.umd.js",
|
|
11
12
|
"index.d.ts",
|
|
12
13
|
"style.css",
|
|
13
14
|
"README.md",
|
|
@@ -15,8 +16,8 @@
|
|
|
15
16
|
],
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
|
-
"import": "./index.js",
|
|
19
|
-
"
|
|
19
|
+
"import": "./index.es.js",
|
|
20
|
+
"default": "./index.es.js"
|
|
20
21
|
},
|
|
21
22
|
"./style": "./style.css"
|
|
22
23
|
},
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xingm/vmap-cesium-toolbar",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.18",
|
|
4
4
|
"description": "A powerful Cesium map toolbar plugin with drawing, measurement, and interaction features",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
6
|
+
"main": "dist/index.es.js",
|
|
7
|
+
"module": "dist/index.es.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"import": "./dist/index.js",
|
|
19
|
-
"
|
|
18
|
+
"import": "./dist/index.es.js",
|
|
19
|
+
"default": "./dist/index.es.js"
|
|
20
20
|
},
|
|
21
21
|
"./style": "./dist/style.css"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"dev": "vite --force",
|
|
25
25
|
"build": "vite build --mode lib",
|
|
26
|
+
"dist": "vite build",
|
|
26
27
|
"build:dts": "vue-tsc -p tsconfig.dts.json",
|
|
27
28
|
"build:plugin": "node scripts/build-plugin.js",
|
|
28
29
|
"docs:dev": "vitepress dev doc",
|