@hzab/map-combine 0.4.2-alpha.7 → 0.4.2-alpha.8
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 +77 -75
- package/README.md +83 -83
- package/package.json +3 -4
- package/src/amap/AMapEvent.ts +55 -0
- package/src/amap/AMapPoint.ts +3 -0
- package/src/amap/AMapPolygon.ts +29 -11
- package/src/amap/AMapPolyline.ts +16 -3
- package/src/amap/loader.ts +58 -58
- package/src/basic/MapCombine.ts +102 -102
- package/src/basic/ReactPoint.tsx +363 -363
- package/src/cesium/CesiumMap.ts +17 -0
- package/src/cesium/CesiumTile3D.ts +225 -225
- package/src/mine/MineEvent.ts +16 -1
- package/src/mine/MineMap.ts +125 -125
- package/src/mine/MinePoint.ts +6 -0
- package/src/mine/MinePolygon.ts +4 -0
- package/src/mine/MinePolyline.ts +4 -0
- package/src/utils/color.ts +49 -0
package/src/basic/MapCombine.ts
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { ContextMenu } from "./ContextMenu";
|
|
2
|
-
import { MapElement } from "./MapElement";
|
|
3
|
-
import { MapEvent } from "./MapEvent";
|
|
4
|
-
import { Point, PointOption } from "./Point";
|
|
5
|
-
import { PointAggregation, PointAggregationOption } from "./PointAggregation";
|
|
6
|
-
import { Polygon, PolygonOption } from "./Polygon";
|
|
7
|
-
import { Polyline, PolylineOption } from "./Polyline";
|
|
8
|
-
import { ReactPoint, ReactPointOption, drawReactPoint } from "./ReactPoint";
|
|
9
|
-
import { Tile3D, Tile3DOption } from "./Tile3D";
|
|
10
|
-
import { BasicModel, BasicModelOption } from "./BasicModel";
|
|
11
|
-
import { type BasicBusiness, type BasicBusinessOption } from "./BasicBusiness";
|
|
12
|
-
|
|
13
|
-
import { getBounds } from "../utils/points-viewer";
|
|
14
|
-
|
|
15
|
-
export abstract class MapCombine {
|
|
16
|
-
/* 用于挂载html元素的根节点 */
|
|
17
|
-
readonly htmllayer = document.createElement("div");
|
|
18
|
-
readonly elements = new Map<string, MapElement>();
|
|
19
|
-
readonly event = new MapEvent();
|
|
20
|
-
readonly menu: ContextMenu;
|
|
21
|
-
abstract get cursor(): string;
|
|
22
|
-
abstract set cursor(val: string);
|
|
23
|
-
|
|
24
|
-
abstract get moveable(): boolean;
|
|
25
|
-
abstract set moveable(val: boolean);
|
|
26
|
-
|
|
27
|
-
abstract get center(): number[];
|
|
28
|
-
abstract set center(val);
|
|
29
|
-
|
|
30
|
-
abstract get zoom(): number;
|
|
31
|
-
abstract set zoom(val);
|
|
32
|
-
|
|
33
|
-
loadPromise: Promise<this> = Promise.resolve(this);
|
|
34
|
-
|
|
35
|
-
bussinesses = new Map<string, BasicBusiness<BasicBusinessOption>>();
|
|
36
|
-
|
|
37
|
-
/** 地图是否存在 */
|
|
38
|
-
isAlive = true;
|
|
39
|
-
constructor() {
|
|
40
|
-
const { htmllayer } = this;
|
|
41
|
-
htmllayer.style.zIndex = "1000";
|
|
42
|
-
htmllayer.style.position = "absolute";
|
|
43
|
-
htmllayer.style.width = "0";
|
|
44
|
-
htmllayer.style.height = "0";
|
|
45
|
-
htmllayer.style.left = "0";
|
|
46
|
-
htmllayer.style.top = "0";
|
|
47
|
-
this.menu = new ContextMenu(this);
|
|
48
|
-
(window as any).map = this;
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
this.bussinesses.forEach((e) => e.show && e.onMapLoaded?.());
|
|
51
|
-
}, 100);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
createReactPoint<K>(option?: Partial<ReactPointOption<K>>): ReactPoint<K> {
|
|
55
|
-
const e = new ReactPoint(this, option);
|
|
56
|
-
drawReactPoint(this, e);
|
|
57
|
-
return e;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 设置地图视图
|
|
62
|
-
* @param option 视图参数
|
|
63
|
-
* @param time 设置时间会动画形式调整视图
|
|
64
|
-
*/
|
|
65
|
-
abstract createPoint<K>(option?: Partial<PointOption<K>>): Point<K>;
|
|
66
|
-
|
|
67
|
-
/** 聚合点 */
|
|
68
|
-
abstract createPointAggregation(option?: PointAggregationOption): PointAggregation;
|
|
69
|
-
|
|
70
|
-
abstract createPolyline<K>(option?: Partial<PolylineOption<K>>): Polyline<K>;
|
|
71
|
-
|
|
72
|
-
abstract createPolygon<K>(option?: Partial<PolygonOption<K>>): Polygon<K>;
|
|
73
|
-
|
|
74
|
-
abstract createTile3D(option?: Partial<Tile3DOption>): Tile3D;
|
|
75
|
-
|
|
76
|
-
/** 创建模型 */
|
|
77
|
-
createModel?(option?: Partial<BasicModelOption>): BasicModel;
|
|
78
|
-
|
|
79
|
-
abstract canvasTgeography(p: number[]): number[];
|
|
80
|
-
|
|
81
|
-
abstract geographyTcanvas(p: number[]): number[];
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 所有点位移动至视口,调整位置及层级
|
|
85
|
-
* @param points
|
|
86
|
-
*/
|
|
87
|
-
abstract flyToViewer(points: number[][], opt?: Object): void;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 移动点位到中心点
|
|
91
|
-
* @param points
|
|
92
|
-
*/
|
|
93
|
-
abstract flyTo(point: number[], opt?: Object): void;
|
|
94
|
-
|
|
95
|
-
getBounds = getBounds;
|
|
96
|
-
|
|
97
|
-
destroy() {
|
|
98
|
-
this.isAlive = false;
|
|
99
|
-
this.htmllayer.remove();
|
|
100
|
-
this.event.trigger("destroy");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
1
|
+
import { ContextMenu } from "./ContextMenu";
|
|
2
|
+
import { MapElement } from "./MapElement";
|
|
3
|
+
import { MapEvent } from "./MapEvent";
|
|
4
|
+
import { Point, PointOption } from "./Point";
|
|
5
|
+
import { PointAggregation, PointAggregationOption } from "./PointAggregation";
|
|
6
|
+
import { Polygon, PolygonOption } from "./Polygon";
|
|
7
|
+
import { Polyline, PolylineOption } from "./Polyline";
|
|
8
|
+
import { ReactPoint, ReactPointOption, drawReactPoint } from "./ReactPoint";
|
|
9
|
+
import { Tile3D, Tile3DOption } from "./Tile3D";
|
|
10
|
+
import { BasicModel, BasicModelOption } from "./BasicModel";
|
|
11
|
+
import { type BasicBusiness, type BasicBusinessOption } from "./BasicBusiness";
|
|
12
|
+
|
|
13
|
+
import { getBounds } from "../utils/points-viewer";
|
|
14
|
+
|
|
15
|
+
export abstract class MapCombine {
|
|
16
|
+
/* 用于挂载html元素的根节点 */
|
|
17
|
+
readonly htmllayer = document.createElement("div");
|
|
18
|
+
readonly elements = new Map<string, MapElement>();
|
|
19
|
+
readonly event = new MapEvent();
|
|
20
|
+
readonly menu: ContextMenu;
|
|
21
|
+
abstract get cursor(): string;
|
|
22
|
+
abstract set cursor(val: string);
|
|
23
|
+
|
|
24
|
+
abstract get moveable(): boolean;
|
|
25
|
+
abstract set moveable(val: boolean);
|
|
26
|
+
|
|
27
|
+
abstract get center(): number[];
|
|
28
|
+
abstract set center(val);
|
|
29
|
+
|
|
30
|
+
abstract get zoom(): number;
|
|
31
|
+
abstract set zoom(val);
|
|
32
|
+
|
|
33
|
+
loadPromise: Promise<this> = Promise.resolve(this);
|
|
34
|
+
|
|
35
|
+
bussinesses = new Map<string, BasicBusiness<BasicBusinessOption>>();
|
|
36
|
+
|
|
37
|
+
/** 地图是否存在 */
|
|
38
|
+
isAlive = true;
|
|
39
|
+
constructor() {
|
|
40
|
+
const { htmllayer } = this;
|
|
41
|
+
htmllayer.style.zIndex = "1000";
|
|
42
|
+
htmllayer.style.position = "absolute";
|
|
43
|
+
htmllayer.style.width = "0";
|
|
44
|
+
htmllayer.style.height = "0";
|
|
45
|
+
htmllayer.style.left = "0";
|
|
46
|
+
htmllayer.style.top = "0";
|
|
47
|
+
this.menu = new ContextMenu(this);
|
|
48
|
+
(window as any).map = this;
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
this.bussinesses.forEach((e) => e.show && e.onMapLoaded?.());
|
|
51
|
+
}, 100);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createReactPoint<K>(option?: Partial<ReactPointOption<K>>): ReactPoint<K> {
|
|
55
|
+
const e = new ReactPoint(this, option);
|
|
56
|
+
drawReactPoint(this, e);
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 设置地图视图
|
|
62
|
+
* @param option 视图参数
|
|
63
|
+
* @param time 设置时间会动画形式调整视图
|
|
64
|
+
*/
|
|
65
|
+
abstract createPoint<K>(option?: Partial<PointOption<K>>): Point<K>;
|
|
66
|
+
|
|
67
|
+
/** 聚合点 */
|
|
68
|
+
abstract createPointAggregation(option?: PointAggregationOption): PointAggregation;
|
|
69
|
+
|
|
70
|
+
abstract createPolyline<K>(option?: Partial<PolylineOption<K>>): Polyline<K>;
|
|
71
|
+
|
|
72
|
+
abstract createPolygon<K>(option?: Partial<PolygonOption<K>>): Polygon<K>;
|
|
73
|
+
|
|
74
|
+
abstract createTile3D(option?: Partial<Tile3DOption>): Tile3D;
|
|
75
|
+
|
|
76
|
+
/** 创建模型 */
|
|
77
|
+
createModel?(option?: Partial<BasicModelOption>): BasicModel;
|
|
78
|
+
|
|
79
|
+
abstract canvasTgeography(p: number[]): number[];
|
|
80
|
+
|
|
81
|
+
abstract geographyTcanvas(p: number[]): number[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 所有点位移动至视口,调整位置及层级
|
|
85
|
+
* @param points
|
|
86
|
+
*/
|
|
87
|
+
abstract flyToViewer(points: number[][], opt?: Object): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 移动点位到中心点
|
|
91
|
+
* @param points
|
|
92
|
+
*/
|
|
93
|
+
abstract flyTo(point: number[], opt?: Object): void;
|
|
94
|
+
|
|
95
|
+
getBounds = getBounds;
|
|
96
|
+
|
|
97
|
+
destroy() {
|
|
98
|
+
this.isAlive = false;
|
|
99
|
+
this.htmllayer.remove();
|
|
100
|
+
this.event.trigger("destroy");
|
|
101
|
+
}
|
|
102
|
+
}
|