@yituengine/keymap 1.0.0
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/LICENSE +201 -0
- package/README.md +148 -0
- package/dist/engine.js +1 -0
- package/dist/types/core/Assets.d.ts +11 -0
- package/dist/types/core/Classification.d.ts +17 -0
- package/dist/types/core/Flatten.d.ts +74 -0
- package/dist/types/core/Status.d.ts +3 -0
- package/dist/types/core/pathAnim.d.ts +27 -0
- package/dist/types/core/transformFun.d.ts +16 -0
- package/dist/types/draw/baseDraw.d.ts +74 -0
- package/dist/types/draw/drawCircle.d.ts +44 -0
- package/dist/types/draw/drawPoint.d.ts +30 -0
- package/dist/types/draw/drawPolygon.d.ts +35 -0
- package/dist/types/draw/drawPolyline.d.ts +35 -0
- package/dist/types/draw/index.d.ts +17 -0
- package/dist/types/effect/cloud.d.ts +34 -0
- package/dist/types/effect/fog.d.ts +44 -0
- package/dist/types/effect/fogPro.d.ts +46 -0
- package/dist/types/effect/index.d.ts +32 -0
- package/dist/types/effect/lensflare.d.ts +38 -0
- package/dist/types/effect/rainy.d.ts +47 -0
- package/dist/types/effect/snowCover.d.ts +50 -0
- package/dist/types/effect/snowFall.d.ts +38 -0
- package/dist/types/event/index.d.ts +12 -0
- package/dist/types/event/menu.d.ts +110 -0
- package/dist/types/event/mousePick.d.ts +57 -0
- package/dist/types/graphic/baseGraphic.d.ts +131 -0
- package/dist/types/graphic/billboardGraphic.d.ts +75 -0
- package/dist/types/graphic/circleGraphic.d.ts +103 -0
- package/dist/types/graphic/customPopupGraphic.d.ts +75 -0
- package/dist/types/graphic/index.d.ts +32 -0
- package/dist/types/graphic/modelGraphic.d.ts +90 -0
- package/dist/types/graphic/polygonGraphic.d.ts +124 -0
- package/dist/types/graphic/polylineGraphic.d.ts +100 -0
- package/dist/types/graphic/popupGraphic.d.ts +85 -0
- package/dist/types/layer/graphicLayer.d.ts +96 -0
- package/dist/types/layer/heatmapLayer/heatmapRenderer.d.ts +39 -0
- package/dist/types/layer/heatmapLayer.d.ts +113 -0
- package/dist/types/layer/index.d.ts +14 -0
- package/dist/types/layer/tilesetLayer.d.ts +107 -0
- package/dist/types/main.d.ts +68 -0
- package/dist/types/map/defaultInteractions.d.ts +26 -0
- package/dist/types/map/index.d.ts +254 -0
- package/dist/types/material/LightingFlow.d.ts +63 -0
- package/dist/types/material/PolylineDashed.d.ts +68 -0
- package/dist/types/material/TextureFlow.d.ts +94 -0
- package/dist/types/material/Wave.d.ts +75 -0
- package/dist/types/material/index.d.ts +20 -0
- package/dist/types/measure/baseMeasure.d.ts +93 -0
- package/dist/types/measure/index.d.ts +18 -0
- package/dist/types/measure/measureArea.d.ts +46 -0
- package/dist/types/measure/measureCutFill.d.ts +69 -0
- package/dist/types/measure/measureDistance.d.ts +50 -0
- package/dist/types/measure/measureHeight.d.ts +47 -0
- package/dist/types/primitive/ClassificationPrimitive.d.ts +72 -0
- package/dist/types/primitive/Tube.d.ts +38 -0
- package/dist/types/primitive/Wall.d.ts +47 -0
- package/dist/types/primitive/basePrimitive.d.ts +42 -0
- package/dist/types/primitive/index.d.ts +16 -0
- package/dist/types/types/general.d.ts +94 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/public.d.ts +11 -0
- package/dist/types/utils/CoordTransform.d.ts +26 -0
- package/dist/types/utils/controlPoint.d.ts +10 -0
- package/dist/types/utils/cutFillAnalysis.d.ts +38 -0
- package/dist/types/utils/graphic.d.ts +45 -0
- package/dist/types/utils/midPoint.d.ts +11 -0
- package/dist/types/utils/rightMenu.d.ts +1 -0
- package/dist/types/utils/tools.d.ts +38 -0
- package/docs/guide/draw-measure.md +97 -0
- package/docs/guide/graphic.md +136 -0
- package/docs/guide/index.md +29 -0
- package/docs/guide/menu.md +101 -0
- package/docs/guide/quick-start.md +74 -0
- package/package.json +58 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LayerType } from '../layer';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
/** 基础图元配置项。 */
|
|
4
|
+
export interface BasePrimitiveOptions {
|
|
5
|
+
/** 图元唯一标识;未传入时自动生成。 */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** 图元名称;未传入时使用图元类型和唯一标识生成。 */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** 图元的参考位置或锚点坐标。 */
|
|
10
|
+
position?: Cesium.Cartesian3;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Primitive 图元基类。
|
|
14
|
+
*
|
|
15
|
+
* 保存 SDK 图元对象的通用标识、归属图层和 Cesium Primitive 引用,并提供显示、隐藏和销毁的基础生命周期方法。
|
|
16
|
+
*/
|
|
17
|
+
export default class BasePrimitive {
|
|
18
|
+
/** 图元唯一标识。 */
|
|
19
|
+
id: string;
|
|
20
|
+
/** 图元名称。 */
|
|
21
|
+
name: string;
|
|
22
|
+
/** 图元类型,默认取具体子类名称。 */
|
|
23
|
+
readonly type: string;
|
|
24
|
+
/** 图元参考位置;未配置时为 `null`。 */
|
|
25
|
+
position: Cesium.Cartesian3 | null;
|
|
26
|
+
/** 图元所属图层。 */
|
|
27
|
+
layer: LayerType | null;
|
|
28
|
+
/** 当前 SDK 图元对应的 Cesium Primitive 实例。 */
|
|
29
|
+
primitive: Cesium.Primitive | null;
|
|
30
|
+
/**
|
|
31
|
+
* 创建基础图元实例。
|
|
32
|
+
*
|
|
33
|
+
* @param opt - 基础图元配置项。
|
|
34
|
+
*/
|
|
35
|
+
constructor(opt: BasePrimitiveOptions);
|
|
36
|
+
/** 将图元重新注册到地图资源管理器中。 */
|
|
37
|
+
show(): void;
|
|
38
|
+
/** 从地图资源管理器中解绑图元。 */
|
|
39
|
+
hide(): void;
|
|
40
|
+
/** 从场景中移除 Cesium Primitive,并从地图资源管理器中解绑图元。 */
|
|
41
|
+
destroy(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import TubePrimitive from './Tube';
|
|
2
|
+
import WallPrimitive from './Wall';
|
|
3
|
+
import ClassificationPrimitive from './ClassificationPrimitive';
|
|
4
|
+
export { default as TubePrimitive } from './Tube';
|
|
5
|
+
export { default as WallPrimitive } from './Wall';
|
|
6
|
+
export { default as ClassificationPrimitive } from './ClassificationPrimitive';
|
|
7
|
+
export type { BasePrimitiveOptions } from './basePrimitive';
|
|
8
|
+
export type { TubePrimitiveOptions } from './Tube';
|
|
9
|
+
export type { WallPrimitiveOptions } from './Wall';
|
|
10
|
+
/** SDK 内置 Primitive 图元实例类型。 */
|
|
11
|
+
export type PrimitiveType = TubePrimitive | WallPrimitive | ClassificationPrimitive;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
TubePrimitive: typeof TubePrimitive;
|
|
14
|
+
WallPrimitive: typeof WallPrimitive;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { LayerType } from '../layer';
|
|
3
|
+
import { PopupGraphicOptions } from '../graphic/popupGraphic';
|
|
4
|
+
import { CustomPopupGraphicOptions } from '../graphic/customPopupGraphic';
|
|
5
|
+
export type GeojsonCoordinate = [number, number, number?];
|
|
6
|
+
export interface GeojsonLine {
|
|
7
|
+
type: 'Feature';
|
|
8
|
+
properties: {
|
|
9
|
+
color: string;
|
|
10
|
+
directConnected?: boolean;
|
|
11
|
+
};
|
|
12
|
+
geometry: {
|
|
13
|
+
type: 'LineString';
|
|
14
|
+
coordinates: GeojsonCoordinate[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface GeojsonPolygon {
|
|
18
|
+
type: 'Feature';
|
|
19
|
+
properties: {
|
|
20
|
+
color: string;
|
|
21
|
+
};
|
|
22
|
+
geometry: {
|
|
23
|
+
type: 'Polygon';
|
|
24
|
+
coordinates: GeojsonCoordinate[][];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface GeojsonPoint {
|
|
28
|
+
type: 'Feature';
|
|
29
|
+
properties: {
|
|
30
|
+
color: string;
|
|
31
|
+
clampToGround?: boolean;
|
|
32
|
+
};
|
|
33
|
+
geometry: {
|
|
34
|
+
type: 'Point';
|
|
35
|
+
coordinates: GeojsonCoordinate;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface GeojsonCircle {
|
|
39
|
+
type: 'Feature';
|
|
40
|
+
properties: {
|
|
41
|
+
color: string;
|
|
42
|
+
clampToGround?: boolean;
|
|
43
|
+
};
|
|
44
|
+
geometry: {
|
|
45
|
+
type: 'Circle';
|
|
46
|
+
coordinates: GeojsonCoordinate;
|
|
47
|
+
radius: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type GeojsonFeature = GeojsonLine | GeojsonPolygon | GeojsonPoint | GeojsonCircle;
|
|
51
|
+
export interface Asset {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string | null;
|
|
54
|
+
type: string;
|
|
55
|
+
layer?: LayerType | null;
|
|
56
|
+
show?: () => void;
|
|
57
|
+
hide?: () => void;
|
|
58
|
+
destroy?: () => void;
|
|
59
|
+
popup?: PopupGraphicOptions | CustomPopupGraphicOptions | null;
|
|
60
|
+
showHandler?: () => void;
|
|
61
|
+
clearHandler?: () => void;
|
|
62
|
+
}
|
|
63
|
+
export declare enum EMaterialName {
|
|
64
|
+
LightingFlow = "LightingFlowMaterial",
|
|
65
|
+
PolylineDashed = "PolylineDashedMaterial",
|
|
66
|
+
TextureFlow = "TextureFlowMaterial",
|
|
67
|
+
Wave = "WaveMaterial"
|
|
68
|
+
}
|
|
69
|
+
export interface WGS84Pos {
|
|
70
|
+
lng: number;
|
|
71
|
+
lat: number;
|
|
72
|
+
alt: number;
|
|
73
|
+
}
|
|
74
|
+
export type MaterialConstructorWithCache<T = Record<string, unknown>> = typeof Cesium.Material & {
|
|
75
|
+
_materialCache: {
|
|
76
|
+
addMaterial: (type: string, material: {
|
|
77
|
+
fabric: {
|
|
78
|
+
type: string;
|
|
79
|
+
uniforms: T;
|
|
80
|
+
source: string;
|
|
81
|
+
};
|
|
82
|
+
translucent?: boolean | ((material: T) => boolean);
|
|
83
|
+
}) => void;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export interface Rotation {
|
|
87
|
+
heading: number;
|
|
88
|
+
pitch: number;
|
|
89
|
+
roll: number;
|
|
90
|
+
}
|
|
91
|
+
export interface DistanceDisplayCondition {
|
|
92
|
+
min: number;
|
|
93
|
+
max: number;
|
|
94
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { Asset, WGS84Pos } from './general';
|
|
3
|
+
export type { Asset, DistanceDisplayCondition, GeojsonCoordinate, Rotation, WGS84Pos } from './general';
|
|
4
|
+
export type MousePickHandlerArgs = {
|
|
5
|
+
event: Cesium.ScreenSpaceEventHandler.PositionedEvent;
|
|
6
|
+
coordinate: WGS84Pos | null;
|
|
7
|
+
pickedObj: any;
|
|
8
|
+
pickedAsset: Asset | null;
|
|
9
|
+
lastPickedAsset: Asset | null;
|
|
10
|
+
};
|
|
11
|
+
export type MousePickHandler = (args: MousePickHandlerArgs) => any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
type CoordinateValue = number | string;
|
|
3
|
+
type WGS84Input = {
|
|
4
|
+
lng?: number;
|
|
5
|
+
lon?: number;
|
|
6
|
+
lat: number;
|
|
7
|
+
alt?: number;
|
|
8
|
+
};
|
|
9
|
+
type WGS84Output = {
|
|
10
|
+
lng: number;
|
|
11
|
+
lat: number;
|
|
12
|
+
alt: number;
|
|
13
|
+
};
|
|
14
|
+
declare class CoordTransform {
|
|
15
|
+
static BD09ToGCJ02(lng: CoordinateValue, lat: CoordinateValue): number[];
|
|
16
|
+
static GCJ02ToBD09(lng: CoordinateValue, lat: CoordinateValue): number[];
|
|
17
|
+
static WGS84ToGCJ02(lng: CoordinateValue, lat: CoordinateValue): number[];
|
|
18
|
+
static GCJ02ToWGS84(lng: CoordinateValue, lat: CoordinateValue): number[];
|
|
19
|
+
static delta(lng: number, lat: number): number[];
|
|
20
|
+
static transformLng(lng: CoordinateValue, lat: CoordinateValue): number;
|
|
21
|
+
static transformLat(lng: CoordinateValue, lat: CoordinateValue): number;
|
|
22
|
+
static out_of_china(lng: CoordinateValue, lat: CoordinateValue): boolean;
|
|
23
|
+
static transformWGS84ToCartesian(_viewer: Cesium.Viewer, position?: WGS84Input | null, alt?: number): Cesium.Cartesian3;
|
|
24
|
+
static transformCartesianToWGS84(_viewer: Cesium.Viewer, cartesian: Cesium.Cartesian3): WGS84Output;
|
|
25
|
+
}
|
|
26
|
+
export default CoordTransform;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { GraphicType } from '../graphic';
|
|
3
|
+
export declare class ControlPoint extends Cesium.Entity {
|
|
4
|
+
pointIndex: number;
|
|
5
|
+
parentAsset: GraphicType;
|
|
6
|
+
position: Cesium.PositionProperty;
|
|
7
|
+
constructor(pointIndex: number, parentAsset: GraphicType, opt: Partial<Cesium.Entity.ConstructorOptions> & {
|
|
8
|
+
position: Cesium.PositionProperty | Cesium.Cartesian3;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
export interface CutFillAnalysisOptions {
|
|
3
|
+
viewer: Cesium.Viewer;
|
|
4
|
+
positions: Cesium.Cartesian3[];
|
|
5
|
+
height: number;
|
|
6
|
+
precision?: number;
|
|
7
|
+
dataSource: Cesium.CustomDataSource;
|
|
8
|
+
}
|
|
9
|
+
export interface CutFillResult {
|
|
10
|
+
allArea: number;
|
|
11
|
+
cutArea: number;
|
|
12
|
+
cutVolume: number;
|
|
13
|
+
fillArea: number;
|
|
14
|
+
fillVolume: number;
|
|
15
|
+
noArea: number;
|
|
16
|
+
}
|
|
17
|
+
type HeightPosition = {
|
|
18
|
+
heightPos: Cesium.Cartesian3;
|
|
19
|
+
noHeightPos: Cesium.Cartesian3;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
export default class CutFillAnalysis {
|
|
23
|
+
viewer: Cesium.Viewer;
|
|
24
|
+
positions: Cesium.Cartesian3[];
|
|
25
|
+
height: number;
|
|
26
|
+
precision: number;
|
|
27
|
+
dataSource: Cesium.CustomDataSource;
|
|
28
|
+
maxHeigh: number;
|
|
29
|
+
geom: Cesium.Geometry | undefined;
|
|
30
|
+
result: CutFillResult | null;
|
|
31
|
+
constructor(opt: CutFillAnalysisOptions);
|
|
32
|
+
createPolygonGeo(points: Cesium.Cartesian3[]): void;
|
|
33
|
+
VolumeAnalysis(): CutFillResult;
|
|
34
|
+
computeCentroid4Polygon(positions: Cesium.Cartesian3[]): Cesium.Cartesian3;
|
|
35
|
+
computeArea4Triangle(pos1: Cesium.Cartesian3, pos2: Cesium.Cartesian3, pos3: Cesium.Cartesian3): number;
|
|
36
|
+
returnPosition(positions: ArrayLike<number>, index: number): HeightPosition;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
/**
|
|
3
|
+
* 创建模型实体
|
|
4
|
+
* @param {String} opt.url 模型地址
|
|
5
|
+
* @param {Number} opt.scale 缩放
|
|
6
|
+
* @param {Boolean} opt.fixedScale 是否固定大小
|
|
7
|
+
* @param {Number} opt.clampToGround 贴地选项
|
|
8
|
+
*/
|
|
9
|
+
export declare const createModelGraphic: (opt: Cesium.ModelGraphics.ConstructorOptions) => Cesium.ModelGraphics;
|
|
10
|
+
export declare const createPolylineGraphic: (opt: Cesium.PolylineGraphics.ConstructorOptions) => Cesium.PolylineGraphics;
|
|
11
|
+
export declare const createPolygonGraphic: (opt: Cesium.PolygonGraphics.ConstructorOptions) => Cesium.PolygonGraphics;
|
|
12
|
+
export declare const createPolylineVolumeGraphic: (opt: Cesium.PolylineVolumeGraphics.ConstructorOptions) => Cesium.PolylineVolumeGraphics;
|
|
13
|
+
export declare const createWallGraphic: (opt: Cesium.WallGraphics.ConstructorOptions) => Cesium.WallGraphics;
|
|
14
|
+
export declare const createBillboardGraphic: (opt: Cesium.BillboardGraphics.ConstructorOptions) => Cesium.BillboardGraphics;
|
|
15
|
+
/**
|
|
16
|
+
* label标签图形
|
|
17
|
+
* @param {*} opt
|
|
18
|
+
*/
|
|
19
|
+
export declare const createLabelGraphic: (opt: Cesium.LabelGraphics.ConstructorOptions) => Cesium.LabelGraphics;
|
|
20
|
+
/**
|
|
21
|
+
* box盒子图形
|
|
22
|
+
* @param {*} opt
|
|
23
|
+
*/
|
|
24
|
+
export declare const createBoxGraphic: (opt: Cesium.BoxGraphics.ConstructorOptions) => Cesium.BoxGraphics;
|
|
25
|
+
/**
|
|
26
|
+
* point点图形
|
|
27
|
+
* @param {*} opt
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare const createPointGraphic: (opt: Cesium.PointGraphics.ConstructorOptions) => Cesium.PointGraphics;
|
|
31
|
+
/**
|
|
32
|
+
* plane平面图形
|
|
33
|
+
* @param {*} opt
|
|
34
|
+
*/
|
|
35
|
+
export declare const createPlaneGraphic: (opt: Cesium.PlaneGraphics.ConstructorOptions) => Cesium.PlaneGraphics;
|
|
36
|
+
/**
|
|
37
|
+
* CylinderGraphic平面图形
|
|
38
|
+
* @param {*} opt
|
|
39
|
+
*/
|
|
40
|
+
export declare const createCylinderGraphic: (opt: Cesium.CylinderGraphics.ConstructorOptions) => Cesium.CylinderGraphics;
|
|
41
|
+
/**
|
|
42
|
+
* EllipseGraphic平面图形
|
|
43
|
+
* @param {*} opt
|
|
44
|
+
*/
|
|
45
|
+
export declare const createEllipseGraphic: (opt: Cesium.EllipseGraphics.ConstructorOptions) => Cesium.EllipseGraphics;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GraphicType } from '../graphic';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
export declare class MidPoint extends Cesium.Entity {
|
|
4
|
+
pointIndex: number;
|
|
5
|
+
parentAsset: GraphicType;
|
|
6
|
+
position: Cesium.PositionProperty;
|
|
7
|
+
constructor(pointIndex: number, parentAsset: GraphicType, opt: Partial<Cesium.Entity.ConstructorOptions> & {
|
|
8
|
+
position: Cesium.PositionProperty | Cesium.Cartesian3;
|
|
9
|
+
});
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function createMenuDiv(): HTMLElement;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WGS84Pos } from '../types';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
export declare function generateUniqueId(): string;
|
|
4
|
+
/**
|
|
5
|
+
* 经纬高转笛卡尔三坐标系
|
|
6
|
+
* @param {WGS84Pos} pos
|
|
7
|
+
*/
|
|
8
|
+
export declare function wgs84Tocar3(pos: WGS84Pos): Cesium.Cartesian3;
|
|
9
|
+
/**
|
|
10
|
+
* 笛卡尔三坐标系转经纬高
|
|
11
|
+
* @param {Cesium.Cartesian3} car3
|
|
12
|
+
*/
|
|
13
|
+
export declare function car3Towgs84(car3: Cesium.Cartesian3): {
|
|
14
|
+
lng: number;
|
|
15
|
+
lat: number;
|
|
16
|
+
alt: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function wgs84ArrToCar3Arr(posArr: WGS84Pos[]): Cesium.Cartesian3[];
|
|
19
|
+
export declare function car3ArrTowgs84Arr(posArr: Cesium.Cartesian3[]): WGS84Pos[];
|
|
20
|
+
export declare function calcDistance(posArr: Cesium.Cartesian3[]): 0 | {
|
|
21
|
+
distance: string;
|
|
22
|
+
allDistance: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 传入屏幕坐标,输出对应的Cartesian3坐标
|
|
26
|
+
* @param {Cesium.Cartesian2} car2
|
|
27
|
+
* @returns {Cesium.Cartesian3 | undefined} 对应的Cartesian3坐标
|
|
28
|
+
*/
|
|
29
|
+
export declare function pickPosition(car2: Cesium.Cartesian2, viewer: Cesium.Viewer): Cesium.Cartesian3 | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 用圆心经纬度和半径生成近似圆的点列表
|
|
32
|
+
* @param center 圆心经纬度坐标
|
|
33
|
+
* @param radius 半径(单位:米)
|
|
34
|
+
* @param angle 角度间隔(默认:5°)
|
|
35
|
+
* @returns 圆的点列表(包含闭合点)
|
|
36
|
+
*/
|
|
37
|
+
export declare function generateCirclePoints(center: Cesium.Cartesian3, radius: number, angle?: number): Cesium.Cartesian3[];
|
|
38
|
+
export declare function calcPolygonCenter(posArr: Cesium.Cartesian3[]): Cesium.Cartesian3 | undefined;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# 绘制与测量
|
|
2
|
+
|
|
3
|
+
绘制和测量工具都接收当前 `KeyMap` 实例,并通过 `activate()` 开始交互。当前只允许一个绘制或测量实例处于激活状态,启动新的实例会自动移除旧实例。按 `Escape` 可以取消当前实例。
|
|
4
|
+
|
|
5
|
+
## 绘制点线面圆
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { draw } from '@yituengine/keymap';
|
|
9
|
+
|
|
10
|
+
const drawPolyline = new draw.DrawPolyline(map);
|
|
11
|
+
|
|
12
|
+
drawPolyline.setFinishCallback(() => {
|
|
13
|
+
console.log('线绘制完成');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
drawPolyline.activate();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
可用绘制类:
|
|
20
|
+
|
|
21
|
+
| 类 | 说明 |
|
|
22
|
+
| -------------- | ------------ |
|
|
23
|
+
| `DrawPoint` | 绘制点。 |
|
|
24
|
+
| `DrawPolyline` | 绘制折线。 |
|
|
25
|
+
| `DrawPolygon` | 绘制多边形。 |
|
|
26
|
+
| `DrawCircle` | 绘制圆。 |
|
|
27
|
+
|
|
28
|
+
常用控制:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
drawPolyline.deactivate();
|
|
32
|
+
drawPolyline.clear();
|
|
33
|
+
drawPolyline.destroy();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 绘制交互约定
|
|
37
|
+
|
|
38
|
+
- 左键通常用于添加节点或确认关键点。
|
|
39
|
+
- 鼠标移动用于预览当前图形。
|
|
40
|
+
- 右键通常用于撤销上一步或重置当前状态。
|
|
41
|
+
- 中键或点击完成图标用于结束绘制,具体行为以各绘制类为准。
|
|
42
|
+
- `Escape` 会取消当前激活的绘制或测量实例。
|
|
43
|
+
|
|
44
|
+
## 测量
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { measure } from '@yituengine/keymap';
|
|
48
|
+
|
|
49
|
+
const distance = new measure.MeasureDistance(map);
|
|
50
|
+
|
|
51
|
+
distance.setFinishCallback((result) => {
|
|
52
|
+
console.log('距离测量结果', result);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
distance.activate();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
可用测量类:
|
|
59
|
+
|
|
60
|
+
| 类 | 说明 |
|
|
61
|
+
| ----------------- | ------------ |
|
|
62
|
+
| `MeasureDistance` | 距离测量。 |
|
|
63
|
+
| `MeasureArea` | 面积测量。 |
|
|
64
|
+
| `MeasureHeight` | 高度测量。 |
|
|
65
|
+
| `MeasureCutFill` | 挖填方测量。 |
|
|
66
|
+
|
|
67
|
+
常用控制:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
distance.measureEnd();
|
|
71
|
+
distance.clear();
|
|
72
|
+
distance.destroy();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 和业务 UI 配合
|
|
76
|
+
|
|
77
|
+
建议业务按钮只负责创建和激活工具,工具完成或取消后再更新按钮状态:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
let activeTool: { destroy: () => void } | null = null;
|
|
81
|
+
|
|
82
|
+
function startDistanceMeasure() {
|
|
83
|
+
activeTool?.destroy();
|
|
84
|
+
|
|
85
|
+
const tool = new measure.MeasureDistance(map);
|
|
86
|
+
activeTool = tool;
|
|
87
|
+
|
|
88
|
+
tool.setFinishCallback((result) => {
|
|
89
|
+
console.log(result);
|
|
90
|
+
activeTool = null;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
tool.activate();
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
如果同时使用弹窗,可以把 `disablePopup` 与业务的绘制/测量状态绑定,避免绘制过程中误弹出业务弹窗。
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# 图层与图形
|
|
2
|
+
|
|
3
|
+
## 图层
|
|
4
|
+
|
|
5
|
+
`GraphicLayer` 是业务图形的常用容器。图形加入图层后,会同时登记到 `KeyMap.Assets`,便于后续通过 id 查找或删除。
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { layer } from '@yituengine/keymap';
|
|
9
|
+
|
|
10
|
+
const graphicLayer = new layer.GraphicLayer({ name: '标绘图层' });
|
|
11
|
+
map.addLayer(graphicLayer);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
常用操作:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
graphicLayer.show();
|
|
18
|
+
graphicLayer.hide();
|
|
19
|
+
graphicLayer.removeChild('asset-id');
|
|
20
|
+
graphicLayer.removeAll();
|
|
21
|
+
map.removeLayer(graphicLayer);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## HeatmapLayer
|
|
25
|
+
|
|
26
|
+
`HeatmapLayer` 用于展示二维热力图。它会把经纬度权重点绘制到 canvas,再作为 Cesium rectangle 图片材质贴到固定地理范围上,适合校园人流密度、区域热度等平面覆盖场景。
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import * as Cesium from 'cesium';
|
|
30
|
+
import { layer } from '@yituengine/keymap';
|
|
31
|
+
|
|
32
|
+
const heatmapLayer = new layer.HeatmapLayer({
|
|
33
|
+
name: '校园人流密度',
|
|
34
|
+
rectangle: Cesium.Rectangle.fromDegrees(113.26, 23.12, 113.29, 23.15),
|
|
35
|
+
min: 0,
|
|
36
|
+
max: 100,
|
|
37
|
+
radius: 36,
|
|
38
|
+
points: [
|
|
39
|
+
{ lng: 113.2644, lat: 23.1291, value: 80 },
|
|
40
|
+
{ lng: 113.276, lat: 23.136, value: 45 },
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
map.addLayer(heatmapLayer);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
实时更新数据时优先保持 `rectangle`、`min`、`max` 固定,避免热力颜色语义随数据批次漂移。
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
heatmapLayer.setData([
|
|
51
|
+
{ lng: 113.2644, lat: 23.1291, value: 60 },
|
|
52
|
+
{ lng: 113.271, lat: 23.134, value: 95 },
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
heatmapLayer.hide();
|
|
56
|
+
heatmapLayer.show();
|
|
57
|
+
map.removeLayer(heatmapLayer);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## BillboardGraphic
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import * as Cesium from 'cesium';
|
|
64
|
+
import { graphic } from '@yituengine/keymap';
|
|
65
|
+
|
|
66
|
+
const billboard = new graphic.BillboardGraphic({
|
|
67
|
+
id: 'project-point',
|
|
68
|
+
name: '项目点位',
|
|
69
|
+
position: Cesium.Cartesian3.fromDegrees(113.2644, 23.1291, 20),
|
|
70
|
+
image: '/icons/location.svg',
|
|
71
|
+
width: 32,
|
|
72
|
+
height: 32,
|
|
73
|
+
onChanged(position) {
|
|
74
|
+
console.log('点位移动后的位置', position);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
graphicLayer.addGraphic(billboard);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
进入编辑模式后,点位会显示一个控制点,拖拽结束时触发 `onChanged`。
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
billboard.showHandler();
|
|
85
|
+
billboard.clearHandler();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## PolylineGraphic
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const polyline = new graphic.PolylineGraphic({
|
|
92
|
+
name: '线路',
|
|
93
|
+
positions: [Cesium.Cartesian3.fromDegrees(113.26, 23.12, 0), Cesium.Cartesian3.fromDegrees(113.27, 23.13, 0), Cesium.Cartesian3.fromDegrees(113.28, 23.14, 0)],
|
|
94
|
+
width: 4,
|
|
95
|
+
material: Cesium.Color.CYAN,
|
|
96
|
+
clampToGround: true,
|
|
97
|
+
onChanged(positions) {
|
|
98
|
+
console.log('线更新后的节点', positions);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
graphicLayer.addGraphic(polyline);
|
|
103
|
+
polyline.showHandler();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
折线编辑模式下会显示控制点和中点。拖拽控制点会移动节点,拖拽中点会转换为新的控制点。右键控制点可以通过默认菜单删除节点,删除后至少保留 2 个节点。
|
|
107
|
+
|
|
108
|
+
## PolygonGraphic
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
const polygon = new graphic.PolygonGraphic({
|
|
112
|
+
name: '范围面',
|
|
113
|
+
positions: [Cesium.Cartesian3.fromDegrees(113.26, 23.12, 0), Cesium.Cartesian3.fromDegrees(113.29, 23.12, 0), Cesium.Cartesian3.fromDegrees(113.29, 23.15, 0), Cesium.Cartesian3.fromDegrees(113.26, 23.15, 0)],
|
|
114
|
+
material: Cesium.Color.BLUE.withAlpha(0.35),
|
|
115
|
+
outlineMaterial: Cesium.Color.WHITE,
|
|
116
|
+
outlineWidth: 3,
|
|
117
|
+
onChanged(positions) {
|
|
118
|
+
console.log('面更新后的节点', positions);
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
graphicLayer.addGraphic(polygon);
|
|
123
|
+
polygon.showHandler();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
多边形支持拖拽控制点、中点补点、右键删除控制点和悬停白色描边。`outlineMaterial` 优先级高于 `outlineColor`,适合使用自定义线材质。
|
|
127
|
+
|
|
128
|
+
## 清理图形
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
polyline.clearHandler();
|
|
132
|
+
polyline.destroy();
|
|
133
|
+
graphicLayer.removeAll();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
业务侧只需要销毁图形或图层,不需要直接操作 Cesium `EntityCollection`。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 指南首页
|
|
2
|
+
|
|
3
|
+
这组文档面向业务项目接入易图引擎,重点说明常见组合用法。完整 API 以 `npm run doc` 生成的 TypeDoc 文档为准。
|
|
4
|
+
|
|
5
|
+
## 推荐阅读顺序
|
|
6
|
+
|
|
7
|
+
1. [快速开始](quick-start.md)
|
|
8
|
+
2. [图层与图形](graphic.md)
|
|
9
|
+
3. [右键菜单](menu.md)
|
|
10
|
+
4. [绘制与测量](draw-measure.md)
|
|
11
|
+
|
|
12
|
+
## 基础约定
|
|
13
|
+
|
|
14
|
+
- 地图容器必须是页面中已存在的 `HTMLDivElement`,并且建议由业务页面控制宽高。
|
|
15
|
+
- SDK 基于 `cesium@1.106`,业务项目需要处理 Cesium 静态资源、token、地形和影像资源部署。
|
|
16
|
+
- 经纬度示例使用 `[lng, lat, alt?]`,与 Cesium 的 `Cartesian3.fromDegrees` 参数顺序一致。
|
|
17
|
+
- 图形资产通常先添加到 `GraphicLayer`,再由 `KeyMap.Assets` 统一索引。
|
|
18
|
+
- 进入编辑模式使用 `showHandler()`,退出编辑模式使用 `clearHandler()`。
|
|
19
|
+
|
|
20
|
+
## 默认交互
|
|
21
|
+
|
|
22
|
+
`KeyMap` 初始化时会自动注册一组默认交互,包括:
|
|
23
|
+
|
|
24
|
+
- 鼠标悬停图形高亮。
|
|
25
|
+
- 图形点击弹窗和自定义弹窗。
|
|
26
|
+
- 控制点和中点拖拽编辑。
|
|
27
|
+
- 控制点右键删除。
|
|
28
|
+
- 全局右键菜单。
|
|
29
|
+
- 当前绘制或测量实例的互斥和 `Escape` 取消。
|