@hzab/map-combine 0.0.1 → 0.1.2
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/CHANGELOG.md +5 -0
- package/package.json +2 -2
- package/src/basic/BasicBusiness.ts +72 -0
- package/src/basic/BasicElement.ts +35 -0
- package/src/basic/BasicMarker.ts +45 -0
- package/src/basic/MapCombine.ts +11 -1
- package/src/basic/MapElement.ts +15 -17
- package/src/basic/ReactPopup.tsx +24 -1
- package/src/basic/Tile3D.ts +76 -41
- package/src/cesium/CesiumEvent.ts +18 -29
- package/src/cesium/CesiumMap.ts +148 -53
- package/src/cesium/CesiumTile3D.ts +184 -55
- package/src/cesium/cesium-tile-covert/index.js +48 -0
- package/src/cesium/cesium-tile-covert/modules/index.js +12 -0
- package/src/cesium/cesium-tile-covert/modules/projection/BD09Projection.js +377 -0
- package/src/cesium/cesium-tile-covert/modules/provider/AMapImageryProvider.js +27 -0
- package/src/cesium/cesium-tile-covert/modules/provider/BaiduImageryProvider.js +58 -0
- package/src/cesium/cesium-tile-covert/modules/provider/GeoVisImageryProvider.js +25 -0
- package/src/cesium/cesium-tile-covert/modules/provider/GoogleImageryProvider.js +27 -0
- package/src/cesium/cesium-tile-covert/modules/provider/TdtImageryProvider.js +23 -0
- package/src/cesium/cesium-tile-covert/modules/provider/TencentImageryProvider.js +41 -0
- package/src/cesium/cesium-tile-covert/modules/tiling-scheme/BD09TilingScheme.js +100 -0
- package/src/cesium/cesium-tile-covert/modules/tiling-scheme/CustomGeographicTilingScheme.js +60 -0
- package/src/cesium/cesium-tile-covert/modules/tiling-scheme/CustomMercatorTilingScheme.js +70 -0
- package/src/cesium/cesium-tile-covert/modules/tiling-scheme/GCJ02TilingScheme.js +33 -0
- package/src/cesium/cesium-tile-covert/modules/transform/CoordTransform.js +148 -0
- package/src/openlayer/OpenlayerMap.ts +82 -27
- package/src/openlayer/openlayer-tile-gcj02-wgs84.js +144 -0
- package/src/utils/index.ts +15 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/map-combine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "地图组件",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"axios": "^1.4.0",
|
|
30
30
|
"eslint": "^8.30.0",
|
|
31
31
|
"less": "^4.1.3",
|
|
32
|
+
"lil-gui": "^0.19.2",
|
|
32
33
|
"mobx": "^6.7.0",
|
|
33
34
|
"mobx-react": "^7.6.0",
|
|
34
35
|
"react": "^17.0.2",
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
"lib": "lib"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@dvgis/cesium-map": "^3.1.0",
|
|
45
45
|
"coordtransform": "^2.1.2",
|
|
46
46
|
"lodash": ">=4.17.21",
|
|
47
47
|
"ol": "^7.4.0",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { setValue } from "../utils";
|
|
2
|
+
// import { type BasicElementOption, type BasicElement } from "./BasicElement";
|
|
3
|
+
import { MapCombine } from "./MapCombine";
|
|
4
|
+
|
|
5
|
+
export interface BasicBusinessOption {
|
|
6
|
+
/** 组件名,唯一标识 */
|
|
7
|
+
name: string;
|
|
8
|
+
/** 组件是否显示 */
|
|
9
|
+
show: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export abstract class BasicBusiness<T extends BasicBusinessOption> {
|
|
13
|
+
protected readonly _option: T;
|
|
14
|
+
protected readonly _map: MapCombine;
|
|
15
|
+
protected _elements = [];
|
|
16
|
+
/** 唯一标识 */
|
|
17
|
+
get name() {
|
|
18
|
+
return this._option.name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 是否显示 */
|
|
22
|
+
get show() {
|
|
23
|
+
return this._option.show;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set show(val) {
|
|
27
|
+
setValue(this._option, "show", val, () => {
|
|
28
|
+
this._elements.forEach((e) => {
|
|
29
|
+
e?.update({
|
|
30
|
+
show: val,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
constructor(map: MapCombine, option: T) {
|
|
37
|
+
this._map = map;
|
|
38
|
+
this._option = option;
|
|
39
|
+
// const oldElement = map.bussinesses.get(this.name);
|
|
40
|
+
// if (oldElement) {
|
|
41
|
+
// oldElement.destroy();
|
|
42
|
+
// }
|
|
43
|
+
// map.bussinesses.set(this.name, this);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 地图展示时触发一次 */
|
|
47
|
+
onMapLoaded?(): void;
|
|
48
|
+
/** 每一帧触发一次 */
|
|
49
|
+
onFrame?(): void;
|
|
50
|
+
/** 视图变化先触发一次 */
|
|
51
|
+
onBeforeViewChange?(): void;
|
|
52
|
+
/** 视图变化时连续触发 */
|
|
53
|
+
onViewChange?(): void;
|
|
54
|
+
/** 视图变化后触发一次 */
|
|
55
|
+
onAfterViewChange?(): void;
|
|
56
|
+
/** 鼠标在地图上移动时触发 */
|
|
57
|
+
onMouseMove?(): void;
|
|
58
|
+
/** 鼠标在地图上单击左键 */
|
|
59
|
+
onMouseLClick?(): void;
|
|
60
|
+
/** 鼠标在地图上单击右键 */
|
|
61
|
+
onMouseRClick?(): void;
|
|
62
|
+
|
|
63
|
+
/** 销毁组件 */
|
|
64
|
+
destroy() {
|
|
65
|
+
this._map.bussinesses.delete(this.name);
|
|
66
|
+
if (this._map.isAlive) {
|
|
67
|
+
this._elements.forEach((e) => e?.destroy());
|
|
68
|
+
this.onDestroy?.();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
onDestroy?(): void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface BasicElementOption {
|
|
2
|
+
/** 是否显示 */
|
|
3
|
+
show: boolean
|
|
4
|
+
/** 鼠标样式 */
|
|
5
|
+
cursor: string
|
|
6
|
+
/** 元素是否静默(不触发鼠标事件) */
|
|
7
|
+
silent: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export abstract class BasicElement<T extends BasicElementOption> {
|
|
11
|
+
option: T
|
|
12
|
+
constructor(option: T) {
|
|
13
|
+
this.option = option
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
update(option: Partial<T>) {
|
|
17
|
+
Object.assign(this.option, option)
|
|
18
|
+
this._onUpdate(option)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected abstract _onUpdate(option: Partial<T>): void
|
|
22
|
+
|
|
23
|
+
/** 鼠标进入回调 */
|
|
24
|
+
onMouseIn?(): void
|
|
25
|
+
/** 鼠标离开回调 */
|
|
26
|
+
onMouseOut?(): void
|
|
27
|
+
/** 鼠标移动回调 */
|
|
28
|
+
onMouseMove?(): void
|
|
29
|
+
/** 鼠标点击回调 */
|
|
30
|
+
onClick?(): void
|
|
31
|
+
/** 鼠标右键点击回调 */
|
|
32
|
+
onRClick?(): void
|
|
33
|
+
/** 销毁元素 */
|
|
34
|
+
abstract destroy(): void
|
|
35
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BasicElement, type BasicElementOption } from './BasicElement'
|
|
2
|
+
|
|
3
|
+
export interface BasicMarkerOption extends BasicElementOption {
|
|
4
|
+
/** 经度 */
|
|
5
|
+
lon: number
|
|
6
|
+
/** 纬度 */
|
|
7
|
+
lat: number
|
|
8
|
+
/** 海拔 */
|
|
9
|
+
alt: number
|
|
10
|
+
/** 图标 */
|
|
11
|
+
icon?: string
|
|
12
|
+
/** 宽度 */
|
|
13
|
+
width: number
|
|
14
|
+
/** 高度 */
|
|
15
|
+
height: number
|
|
16
|
+
/** 横向偏移 */
|
|
17
|
+
x: number
|
|
18
|
+
/** 纵向偏移 */
|
|
19
|
+
y: number
|
|
20
|
+
/** 旋转角度 */
|
|
21
|
+
rotation: number
|
|
22
|
+
img?: HTMLCanvasElement | HTMLImageElement
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export abstract class BasicMarker extends BasicElement<BasicMarkerOption> {
|
|
26
|
+
constructor(option: Partial<BasicMarkerOption> = {}) {
|
|
27
|
+
super(Object.assign({
|
|
28
|
+
show: true,
|
|
29
|
+
cursor: 'pointer',
|
|
30
|
+
silent: false,
|
|
31
|
+
lon: 120,
|
|
32
|
+
lat: 30,
|
|
33
|
+
alt: 0,
|
|
34
|
+
width: 64,
|
|
35
|
+
height: 64,
|
|
36
|
+
x: 0,
|
|
37
|
+
y: -32,
|
|
38
|
+
rotation: 0,
|
|
39
|
+
icon: BasicMarker.defualtIcon,
|
|
40
|
+
}, option))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** 默认图标 */
|
|
44
|
+
static defualtIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAA7NJREFUeF7lmwlu3DAMRZ2TtbmNbtHmFr5Nk5O1YCAHiobL5yK5wAwQZPEmPn5+0bLzcjz55+XJ4z+2AWit/TyOg75+DNDp9+vz3n/4oO/nef7ekZylAHrQv3rgkXgIysdKGEsAFATOwXpbAaIUwKLAZxilIMoAtNaoZknu3g/JfPQC9PgSEGkAjqxToG9XdOd5Xqb3FfBglPQ3BGYaQgpAH/AfI2UU9DsXsJXqAYgGIwUhDAAIPjWwEU4vL00VBPjVAsptzwD4K1zwU+qRjFsBGD4TAh4C0Foj2XPGFRqEFfikBrquVHbu67sBKFlwX9wT+LyvkoRXj/pcAP6X4AmG4kEuP/AC4KTvuiAjZ+r7H6ZERB0KBFgFMAAp++d5es5B9XtNaZyHuHt/YVxwUjyD51wfrntnpwift5cDp0zoHBCAbPYVw7KUDgUhlAKkggwAdHDRe4QLDlTPAmTzWBTAg/yR2jdkPy6A0CKJeEMEXovrD/IABHmh2ed8Q+wUFWCmnKNlYCpAGJQJIOobCgQzm1wZWOoJAbBOmnXmaD0L8FRwCICHKQYEMMvflPHletGyE44rB2AGEg1g6hLdAFcBqBqI6RsGAGqZVcVGwCMlUAXAVE62BLr3zONVwSMAZg+AAmmthXqHHgTXPJkKWqWAqAmG+3MO3nEcyDTIgSs3QUoSMhhp5UbMpLbCbNW/pBzrOKQEQi2m0gvQpm8rxcDqryl/of5N4zQBCCdGfUBbv7PuBK/taPAh30ABcPVsloFiaGjwZgaHmcNd/3QsCoDLJKSCBAT4/BmVQgCUeoZUYGSJU0PFeaHS8QBIqWDq8q6XH8aXJT6fG3oXSKN3ndd4YABVKoCLH9xRuHOEsg97gNGiwkYFxgTvFl2rGC/gUoCiApdhwREaO0Y7xhQAqeFAusOqwJVEwNIPeQDg5i73jgLJGl9aAXeWQvXzSbcHTNNZ6mlRRAFC3bulnyoBa1boL0iUv+goTHkpA04pwGhzS/0gs1yuKS0NYIcfVNd9iQnOVIXaTMnTUFi47lcBcK8AWSaovABREry7FQYGLD0JDg14laqWKABoklwQql6CspJWYoKMH6SUsCv48hKYmqTQu4S730FcooChHFwQVk53UiksBaD0CLTpmyfcEfzSEgDa5S8IdwW/BUBXgfZ8QPqHCdesYbn9bSUAKmEe35bgtynACWFb8NsBAOWwNfhbACgQtgd/GwCmT7gl+NsBXGrwPg2KOj533PJGqHKwK8719AD+Aby+uV/6QmnsAAAAAElFTkSuQmCC'
|
|
45
|
+
}
|
package/src/basic/MapCombine.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { Polygon, PolygonOption } from "./Polygon";
|
|
|
6
6
|
import { Polyline, PolylineOption } from "./Polyline";
|
|
7
7
|
import { ReactPoint, ReactPointOption, drawReactPoint } from "./ReactPoint";
|
|
8
8
|
import { Tile3D, Tile3DOption } from "./Tile3D";
|
|
9
|
+
import { type BasicBusiness, type BasicBusinessOption } from "./BasicBusiness";
|
|
10
|
+
|
|
9
11
|
export abstract class MapCombine {
|
|
10
12
|
/* 用于挂载html元素的根节点 */
|
|
11
13
|
readonly htmllayer = document.createElement("div");
|
|
@@ -24,6 +26,10 @@ export abstract class MapCombine {
|
|
|
24
26
|
abstract get zoom(): number
|
|
25
27
|
abstract set zoom(val)
|
|
26
28
|
|
|
29
|
+
bussinesses = new Map<string, BasicBusiness<BasicBusinessOption>>();
|
|
30
|
+
|
|
31
|
+
/** 地图是否存在 */
|
|
32
|
+
isAlive = true;
|
|
27
33
|
constructor() {
|
|
28
34
|
const { htmllayer } = this
|
|
29
35
|
htmllayer.style.zIndex = "1000";
|
|
@@ -33,7 +39,10 @@ export abstract class MapCombine {
|
|
|
33
39
|
htmllayer.style.left = "0";
|
|
34
40
|
htmllayer.style.top = "0";
|
|
35
41
|
this.menu = new ContextMenu(this);
|
|
36
|
-
(window as any).map = this
|
|
42
|
+
(window as any).map = this;
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
this.bussinesses.forEach((e) => e.show && e.onMapLoaded?.());
|
|
45
|
+
}, 100);
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
createReactPoint<K>(option?: Partial<ReactPointOption<K>>): ReactPoint<K> {
|
|
@@ -61,6 +70,7 @@ export abstract class MapCombine {
|
|
|
61
70
|
abstract geographyTcanvas(p: number[]): number[]
|
|
62
71
|
|
|
63
72
|
destroy() {
|
|
73
|
+
this.isAlive = false;
|
|
64
74
|
this.htmllayer.remove()
|
|
65
75
|
this.event.trigger('destroy')
|
|
66
76
|
}
|
package/src/basic/MapElement.ts
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import { MapCombine } from "./MapCombine"
|
|
1
|
+
import { MapCombine } from "./MapCombine";
|
|
2
2
|
|
|
3
3
|
export interface MapElementOption {
|
|
4
|
-
name: string
|
|
4
|
+
name: string;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export abstract class MapElement<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly map: MapCombine
|
|
12
|
-
protected readonly _option: T
|
|
7
|
+
export abstract class MapElement<T extends MapElementOption = MapElementOption> {
|
|
8
|
+
abstract type: string;
|
|
9
|
+
readonly map: MapCombine;
|
|
10
|
+
readonly _option: T;
|
|
13
11
|
get name() {
|
|
14
|
-
return this._option.name
|
|
12
|
+
return this._option.name;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
constructor(map: MapCombine, option: T) {
|
|
18
|
-
this.map = map
|
|
19
|
-
this._option = option
|
|
16
|
+
this.map = map;
|
|
17
|
+
this._option = option;
|
|
20
18
|
if (map.elements.has(option.name)) {
|
|
21
|
-
throw new Error(`已存在同名元素 ${option.name}`)
|
|
19
|
+
throw new Error(`已存在同名元素 ${option.name}`);
|
|
22
20
|
}
|
|
23
|
-
map.elements.set(option.name, this)
|
|
21
|
+
map.elements.set(option.name, this);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
destroy() {
|
|
27
|
-
this.map.elements.delete(this.name)
|
|
28
|
-
this._onDestroy()
|
|
25
|
+
this.map.elements.delete(this.name);
|
|
26
|
+
this._onDestroy();
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
protected abstract _onDestroy(): void
|
|
32
|
-
}
|
|
29
|
+
protected abstract _onDestroy(): void;
|
|
30
|
+
}
|
package/src/basic/ReactPopup.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
|
+
import { MapCombine } from "./MapCombine";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
export interface ReactPopupOption {
|
|
@@ -7,16 +8,22 @@ export interface ReactPopupOption {
|
|
|
7
8
|
element: ReactElement;
|
|
8
9
|
/** 层高 */
|
|
9
10
|
zIndex?: number;
|
|
11
|
+
show?: boolean;
|
|
12
|
+
name?: string
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
export class ReactPopup {
|
|
13
16
|
private dom: HTMLDivElement;
|
|
14
17
|
option: ReactPopupOption;
|
|
15
18
|
node: HTMLDivElement;
|
|
19
|
+
map: MapCombine;
|
|
16
20
|
constructor(map, option: ReactPopupOption = {
|
|
17
21
|
element: <></>,
|
|
18
|
-
zIndex: 10
|
|
22
|
+
zIndex: 10,
|
|
23
|
+
show: true,
|
|
24
|
+
name: "bubble"
|
|
19
25
|
}) {
|
|
26
|
+
this.map = map;
|
|
20
27
|
this.dom = document.createElement("div");
|
|
21
28
|
this.option = option;
|
|
22
29
|
const coordinate = map.geographyTcanvas(map.event.geography)
|
|
@@ -27,6 +34,22 @@ export class ReactPopup {
|
|
|
27
34
|
ReactDOM.render(option.element ?? <></>, this.dom);
|
|
28
35
|
}
|
|
29
36
|
|
|
37
|
+
get show(): boolean {
|
|
38
|
+
return this.option.show;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set show(val: boolean) {
|
|
42
|
+
if (val !== this.show) {
|
|
43
|
+
this.option.show = val;
|
|
44
|
+
this.dom.style.display = val ? "" : "none";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
showAt(lon, lat) {
|
|
48
|
+
const coordinate = this.map.geographyTcanvas([lon, lat, 0])
|
|
49
|
+
this.dom.style.position = "absolute";
|
|
50
|
+
this.dom.style.top = coordinate[1] + "px";
|
|
51
|
+
this.dom.style.left = coordinate[0] + "px";
|
|
52
|
+
}
|
|
30
53
|
destroy() {
|
|
31
54
|
this.dom.remove();
|
|
32
55
|
ReactDOM.unmountComponentAtNode(this.dom);
|
package/src/basic/Tile3D.ts
CHANGED
|
@@ -1,99 +1,134 @@
|
|
|
1
|
-
import Eventful from "zrender/lib/core/Eventful"
|
|
1
|
+
import Eventful from "zrender/lib/core/Eventful";
|
|
2
2
|
|
|
3
|
-
import { MapElement, MapElementOption } from "./MapElement"
|
|
4
|
-
import { MapCombine } from "./MapCombine"
|
|
3
|
+
import { MapElement, MapElementOption } from "./MapElement";
|
|
4
|
+
import { MapCombine } from "./MapCombine";
|
|
5
5
|
|
|
6
6
|
export interface Tile3DOption extends MapElementOption {
|
|
7
|
-
show: boolean
|
|
8
|
-
src: string
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
show: boolean;
|
|
8
|
+
src: string;
|
|
9
|
+
/** 中心点坐标 [lng, lat, height] */
|
|
10
|
+
coordinates?: number[];
|
|
11
|
+
/** 移动 [x, y, z] */
|
|
12
|
+
translates?: number[];
|
|
13
|
+
/** 旋转 [x, y, z] */
|
|
14
|
+
rotates?: number[];
|
|
15
|
+
/** 缩放 [x, y, z] */
|
|
16
|
+
scales?: number[];
|
|
17
|
+
quality: number;
|
|
11
18
|
}
|
|
12
19
|
|
|
13
|
-
export class Tile3D extends MapElement<Tile3DOption>{
|
|
14
|
-
type =
|
|
20
|
+
export class Tile3D extends MapElement<Tile3DOption> {
|
|
21
|
+
type = "Tile3D";
|
|
22
|
+
tileset;
|
|
15
23
|
event = new Eventful<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}>()
|
|
24
|
+
ready: () => void;
|
|
25
|
+
update: (keys: Set<string>) => void;
|
|
26
|
+
destroy: () => void;
|
|
27
|
+
focus: () => void;
|
|
28
|
+
}>();
|
|
21
29
|
|
|
22
30
|
get show() {
|
|
23
|
-
return this._option.show
|
|
31
|
+
return this._option.show;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
set show(val) {
|
|
27
35
|
if (this._option.show != val) {
|
|
28
|
-
this._option.show = val
|
|
29
|
-
this._update(
|
|
36
|
+
this._option.show = val;
|
|
37
|
+
this._update("show");
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
get src() {
|
|
34
|
-
return this._option.src
|
|
42
|
+
return this._option.src;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
set src(val) {
|
|
38
46
|
if (this._option.src != val) {
|
|
39
|
-
this._option.src = val
|
|
40
|
-
this._update(
|
|
47
|
+
this._option.src = val;
|
|
48
|
+
this._update("src");
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
get coordinates() {
|
|
45
|
-
return this._option.coordinates
|
|
53
|
+
return this._option.coordinates;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
set coordinates(val) {
|
|
49
57
|
if (this._option.coordinates != val) {
|
|
50
|
-
this._option.coordinates = val
|
|
51
|
-
this._update(
|
|
58
|
+
this._option.coordinates = val;
|
|
59
|
+
this._update("coordinates");
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
get quality() {
|
|
56
|
-
return this._option.quality
|
|
64
|
+
return this._option.quality;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
set quality(val) {
|
|
60
68
|
if (this._option.quality != val) {
|
|
61
|
-
this._option.quality = val
|
|
62
|
-
this._update(
|
|
69
|
+
this._option.quality = val;
|
|
70
|
+
this._update("quality");
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
68
74
|
constructor(map: MapCombine, option: Partial<Tile3DOption> = {}) {
|
|
69
|
-
super(map, Object.assign({ ...Tile3D.option }, option))
|
|
75
|
+
super(map, Object.assign({ ...Tile3D.option }, option));
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
static option: Tile3DOption = {
|
|
73
|
-
name:
|
|
79
|
+
name: "3D瓦片",
|
|
74
80
|
show: true,
|
|
75
|
-
src:
|
|
76
|
-
quality: 0.5
|
|
77
|
-
}
|
|
81
|
+
src: "",
|
|
82
|
+
quality: 0.5,
|
|
83
|
+
};
|
|
78
84
|
|
|
79
|
-
private _needUpdate?: Set<string
|
|
85
|
+
private _needUpdate?: Set<string>;
|
|
80
86
|
private _update(key: string) {
|
|
81
87
|
if (this._needUpdate) {
|
|
82
|
-
this._needUpdate.add(key)
|
|
88
|
+
this._needUpdate.add(key);
|
|
83
89
|
} else {
|
|
84
|
-
this._needUpdate = new Set([key])
|
|
90
|
+
this._needUpdate = new Set([key]);
|
|
85
91
|
setTimeout(() => {
|
|
86
|
-
this.event.trigger(
|
|
87
|
-
this._needUpdate = undefined
|
|
92
|
+
this.event.trigger("update", this._needUpdate);
|
|
93
|
+
this._needUpdate = undefined;
|
|
88
94
|
});
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
98
|
+
/** 基于本地的 ENU 坐标系的偏移,也就是垂直于地表向上为 Z,东为 X,北为 Y
|
|
99
|
+
* @param dx x轴偏移量。单位:米
|
|
100
|
+
* @param dy y轴偏移量。单位:米
|
|
101
|
+
* @param dz z轴偏移量。单位:米
|
|
102
|
+
* @param tileset Cesium3DTileset
|
|
103
|
+
*/
|
|
104
|
+
translate(dx: number, dy: number, dz: number, tileset: any = this.tileset) {
|
|
105
|
+
console.info("TileD translate");
|
|
106
|
+
}
|
|
107
|
+
/** 基于本地的 ENU 坐标系的旋转,也就是垂直于地表向上为 Z,东为 X,北为 Y
|
|
108
|
+
* https://blog.csdn.net/weixin_70945905/article/details/142419968
|
|
109
|
+
* @param rx 绕X轴旋转的角度。单位:度
|
|
110
|
+
* @param ry 绕Y轴旋转的角度。单位:度
|
|
111
|
+
* @param rz 绕Z轴旋转的角度。单位:度
|
|
112
|
+
* @param tileset Cesium3DTileset
|
|
113
|
+
*/
|
|
114
|
+
rotate(rx: number, ry: number, rz: number, tileset = this.tileset) {
|
|
115
|
+
console.info("TileD rotate");
|
|
116
|
+
}
|
|
117
|
+
/** 基于本地的 ENU 坐标系的缩放,也就是垂直于地表向上为 Z,东为 X,北为 Y
|
|
118
|
+
* @param sx x 轴缩放倍数
|
|
119
|
+
* @param sy y 轴缩放倍数
|
|
120
|
+
* @param sz z 轴缩放倍数
|
|
121
|
+
* @param tileset Cesium3DTileset
|
|
122
|
+
*/
|
|
123
|
+
scale(sx: number, sy: number, sz: number, tileset = this.tileset) {
|
|
124
|
+
console.info("TileD scale");
|
|
125
|
+
}
|
|
126
|
+
|
|
92
127
|
protected _onDestroy(): void {
|
|
93
|
-
this.event.trigger(
|
|
128
|
+
this.event.trigger("destroy");
|
|
94
129
|
}
|
|
95
130
|
|
|
96
131
|
focus() {
|
|
97
|
-
this.event.trigger(
|
|
132
|
+
this.event.trigger("focus");
|
|
98
133
|
}
|
|
99
|
-
}
|
|
134
|
+
}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import { CesiumMap } from "./CesiumMap"
|
|
1
|
+
import { CesiumMap } from "./CesiumMap";
|
|
2
2
|
|
|
3
3
|
export function bindEvent(map: CesiumMap) {
|
|
4
|
-
const { event, viewer, container } = map
|
|
4
|
+
const { event, viewer, container } = map;
|
|
5
5
|
viewer.camera.percentageChanged = 0.0001;
|
|
6
6
|
viewer.camera.changed.addEventListener(() => {
|
|
7
|
-
event.trigger(
|
|
7
|
+
event.trigger("view-change");
|
|
8
8
|
});
|
|
9
9
|
viewer.camera.moveEnd.addEventListener(() => {
|
|
10
|
-
event.trigger(
|
|
10
|
+
event.trigger("view-moveEnd");
|
|
11
11
|
});
|
|
12
12
|
const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
|
|
13
13
|
let target: any;
|
|
14
14
|
handler.setInputAction((e: any) => {
|
|
15
15
|
event.canvas = [e.endPosition.x, e.endPosition.y];
|
|
16
16
|
event.geography = map.canvasTgeography(event.canvas);
|
|
17
|
-
let _target: any = undefined
|
|
17
|
+
let _target: any = undefined;
|
|
18
18
|
const res = viewer.scene.pick(e.endPosition);
|
|
19
|
-
const a = res
|
|
20
|
-
? res.id
|
|
21
|
-
? res.id
|
|
22
|
-
: res.primitive
|
|
23
|
-
? res.primitive
|
|
24
|
-
: undefined
|
|
25
|
-
: undefined;
|
|
19
|
+
const a = res ? (res.id ? res.id : res.primitive ? res.primitive : undefined) : undefined;
|
|
26
20
|
|
|
27
21
|
if (a && !a.silent) {
|
|
28
22
|
_target = a;
|
|
@@ -38,49 +32,44 @@ export function bindEvent(map: CesiumMap) {
|
|
|
38
32
|
} else {
|
|
39
33
|
map.cursor = "";
|
|
40
34
|
}
|
|
41
|
-
event.trigger(
|
|
35
|
+
event.trigger("pointer-move");
|
|
42
36
|
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
43
37
|
|
|
44
38
|
handler.setInputAction(() => {
|
|
45
39
|
if (target) {
|
|
46
40
|
target.onPointerDown?.();
|
|
47
41
|
}
|
|
48
|
-
event.trigger(
|
|
42
|
+
event.trigger("pointer-down");
|
|
49
43
|
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
container.addEventListener('pointerup', () => {
|
|
45
|
+
container.addEventListener("pointerup", () => {
|
|
53
46
|
if (target) {
|
|
54
47
|
target.onPointerUp?.();
|
|
55
48
|
}
|
|
56
|
-
event.trigger(
|
|
57
|
-
})
|
|
58
|
-
|
|
49
|
+
event.trigger("pointer-up");
|
|
50
|
+
});
|
|
59
51
|
|
|
60
52
|
handler.setInputAction((e) => {
|
|
61
|
-
console.log('e', e);
|
|
62
|
-
|
|
63
53
|
if (target) {
|
|
64
54
|
target.onLClick?.();
|
|
65
55
|
}
|
|
66
|
-
event.trigger(
|
|
56
|
+
event.trigger("left-click");
|
|
67
57
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
68
58
|
handler.setInputAction(() => {
|
|
69
59
|
if (target) {
|
|
70
60
|
target.onRClick?.();
|
|
71
61
|
}
|
|
72
|
-
event.trigger(
|
|
62
|
+
event.trigger("right-click");
|
|
73
63
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
74
64
|
|
|
75
65
|
handler.setInputAction(() => {
|
|
76
66
|
if (target) {
|
|
77
67
|
target.onDbClick?.();
|
|
78
68
|
}
|
|
79
|
-
event.trigger(
|
|
69
|
+
event.trigger("double-click");
|
|
80
70
|
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
81
71
|
|
|
82
|
-
event.on(
|
|
83
|
-
viewer.destroy()
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
}
|
|
72
|
+
event.on("destroy", () => {
|
|
73
|
+
viewer.destroy();
|
|
74
|
+
});
|
|
75
|
+
}
|