@hzab/map-combine 0.2.7 → 0.3.0-alpha.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/CHANGELOG.md +55 -44
- package/README.md +83 -67
- package/package.json +14 -3
- package/src/amap/AMap.ts +254 -0
- package/src/amap/AMapEvent.ts +49 -0
- package/src/amap/AMapPoint.ts +143 -0
- package/src/amap/AMapPolygon.ts +195 -0
- package/src/amap/AMapPolyline.ts +185 -0
- package/src/amap/loader.ts +58 -0
- package/src/basic/MapCombine.ts +2 -0
- package/src/basic/Point.ts +173 -176
- package/src/basic/ReactPoint.tsx +8 -2
- package/src/cesium/CesiumEvent.ts +4 -0
- package/src/cesium/CesiumMap.ts +0 -1
- package/src/cesium/CesiumPolyline.ts +369 -369
- package/src/cesium/CesiumTile3D.ts +2 -6
- package/src/mine/MineEvent.ts +38 -25
- package/src/mine/MineMap.ts +119 -119
- package/src/openlayer/OpenlayerMap.ts +273 -273
- package/src/openlayer/OpenlayerPoint.ts +176 -176
- package/src/openlayer/OpenlayerPolygon.ts +298 -298
- package/src/openlayer/OpenlayerPolyline.ts +288 -288
package/src/basic/Point.ts
CHANGED
|
@@ -1,176 +1,173 @@
|
|
|
1
|
-
import Eventful from "zrender/lib/core/Eventful"
|
|
2
|
-
|
|
3
|
-
import { MapElement, MapElementOption } from "./MapElement"
|
|
4
|
-
import { MapCombine } from "./MapCombine"
|
|
5
|
-
|
|
6
|
-
export interface PointOption<K> extends MapElementOption {
|
|
7
|
-
show: boolean
|
|
8
|
-
cursor: string
|
|
9
|
-
coordinates?: number[]
|
|
10
|
-
src: string
|
|
11
|
-
center: number[]
|
|
12
|
-
size: number[]
|
|
13
|
-
rotation: number
|
|
14
|
-
editable: boolean
|
|
15
|
-
userdata: K
|
|
16
|
-
silent: boolean
|
|
17
|
-
height: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class Point<K = undefined> extends MapElement<PointOption<K>> {
|
|
21
|
-
type =
|
|
22
|
-
event = new Eventful<{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}>()
|
|
32
|
-
|
|
33
|
-
get userdata() {
|
|
34
|
-
return this._option.userdata
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.event.trigger('destroy')
|
|
175
|
-
}
|
|
176
|
-
}
|
|
1
|
+
import Eventful from "zrender/lib/core/Eventful";
|
|
2
|
+
|
|
3
|
+
import { MapElement, MapElementOption } from "./MapElement";
|
|
4
|
+
import { MapCombine } from "./MapCombine";
|
|
5
|
+
|
|
6
|
+
export interface PointOption<K> extends MapElementOption {
|
|
7
|
+
show: boolean;
|
|
8
|
+
cursor: string;
|
|
9
|
+
coordinates?: number[];
|
|
10
|
+
src: string;
|
|
11
|
+
center: number[];
|
|
12
|
+
size: number[];
|
|
13
|
+
rotation: number;
|
|
14
|
+
editable: boolean;
|
|
15
|
+
userdata: K;
|
|
16
|
+
silent: boolean;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class Point<K = undefined> extends MapElement<PointOption<K>> {
|
|
21
|
+
type = "Point";
|
|
22
|
+
event = new Eventful<{
|
|
23
|
+
"data-loaded": () => void;
|
|
24
|
+
"data-update": () => void;
|
|
25
|
+
"pointer-in": () => void;
|
|
26
|
+
"pointer-out": () => void;
|
|
27
|
+
"left-click": () => void;
|
|
28
|
+
"right-click": () => void;
|
|
29
|
+
update: (keys: Set<string>) => void;
|
|
30
|
+
destroy: () => void;
|
|
31
|
+
}>();
|
|
32
|
+
|
|
33
|
+
get userdata() {
|
|
34
|
+
return this._option.userdata;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get cursor() {
|
|
38
|
+
return this._option.cursor;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get show() {
|
|
42
|
+
return this._option.show;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set show(val) {
|
|
46
|
+
if (this._option.show != val) {
|
|
47
|
+
this._option.show = val;
|
|
48
|
+
this._update("show");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get silent() {
|
|
53
|
+
return this._option.silent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
set silent(val) {
|
|
57
|
+
if (this._option.silent != val) {
|
|
58
|
+
this._option.silent = val;
|
|
59
|
+
this._update("silent");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get editable() {
|
|
64
|
+
return this._option.editable;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set editable(val) {
|
|
68
|
+
if (this._option.editable != val) {
|
|
69
|
+
this._option.editable = val;
|
|
70
|
+
this._update("editable");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get coordinates() {
|
|
75
|
+
return this._option.coordinates;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
set coordinates(val) {
|
|
79
|
+
if (this._option.coordinates != val) {
|
|
80
|
+
this._option.coordinates = val;
|
|
81
|
+
this._update("coordinates");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get src() {
|
|
86
|
+
return this._option.src;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
set src(val) {
|
|
90
|
+
if (this._option.src != val) {
|
|
91
|
+
this._option.src = val;
|
|
92
|
+
this._update("src");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get size() {
|
|
97
|
+
return this._option.size;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
set size(val) {
|
|
101
|
+
if (this._option.size != val) {
|
|
102
|
+
this._option.size = val;
|
|
103
|
+
this._update("size");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get center() {
|
|
107
|
+
return this._option.center;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set center(val) {
|
|
111
|
+
if (this._option.center != val) {
|
|
112
|
+
this._option.center = val;
|
|
113
|
+
this._update("center");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get height() {
|
|
118
|
+
return this._option.height;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
set height(val) {
|
|
122
|
+
if (this._option.height != val) {
|
|
123
|
+
this._option.height = val;
|
|
124
|
+
this._update("height");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get rotation() {
|
|
129
|
+
return this._option.rotation;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
set rotation(val) {
|
|
133
|
+
if (this._option.rotation != val) {
|
|
134
|
+
this._option.rotation = val;
|
|
135
|
+
this._update("rotation");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
constructor(map: MapCombine, option: Partial<PointOption<K>> = {}) {
|
|
140
|
+
super(map, Object.assign({ ...Point.option }, option));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static option: PointOption<undefined> = {
|
|
144
|
+
name: "点",
|
|
145
|
+
show: true,
|
|
146
|
+
src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAIxJREFUOE+tU4ENgCAM6y5TL1MuEy+bmQjChAjIEkKAretIS1DBwAy3pnuXDAvgIGDT+RRfsEtYdZI6mxgoAFQWe6wAcgE0FicgHoA/aJeeF+rs/rBgYI9+u5WIFQa99K9mQwB+j1AjntLfGBlBZCssmoMAGiOkDjWmUvbcK0WVN1PGlS87i63JWTvECRNBLcaa3Jq0AAAAAElFTkSuQmCC",
|
|
147
|
+
center: [0.5, 0.5],
|
|
148
|
+
editable: false,
|
|
149
|
+
size: [16, 16],
|
|
150
|
+
rotation: 0,
|
|
151
|
+
cursor: "pointer",
|
|
152
|
+
userdata: undefined,
|
|
153
|
+
silent: false,
|
|
154
|
+
height: 0,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
private _needUpdate?: Set<string>;
|
|
158
|
+
private _update(key: string) {
|
|
159
|
+
if (this._needUpdate) {
|
|
160
|
+
this._needUpdate.add(key);
|
|
161
|
+
} else {
|
|
162
|
+
this._needUpdate = new Set([key]);
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
this.event.trigger("update", this._needUpdate);
|
|
165
|
+
this._needUpdate = undefined;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
protected _onDestroy(): void {
|
|
171
|
+
this.event.trigger("destroy");
|
|
172
|
+
}
|
|
173
|
+
}
|
package/src/basic/ReactPoint.tsx
CHANGED
|
@@ -20,6 +20,8 @@ export interface ReactPointOption<K> extends MapElementOption {
|
|
|
20
20
|
export class ReactPoint<K = undefined> extends MapElement<ReactPointOption<K>> {
|
|
21
21
|
type: "ReactPoint";
|
|
22
22
|
event = new Eventful<{
|
|
23
|
+
"data-loaded": () => void;
|
|
24
|
+
"data-update": () => void;
|
|
23
25
|
"pointer-in": () => void;
|
|
24
26
|
"pointer-out": () => void;
|
|
25
27
|
"left-click": () => void;
|
|
@@ -167,6 +169,7 @@ export class ReactPoint<K = undefined> extends MapElement<ReactPointOption<K>> {
|
|
|
167
169
|
|
|
168
170
|
export function drawReactPoint(map: MapCombine, point: ReactPoint<unknown>) {
|
|
169
171
|
const { event, htmllayer } = map;
|
|
172
|
+
/** 当前点位的状态 0:初始态 1:编辑态 2:显示态 3:拖动态 */
|
|
170
173
|
let status = 0;
|
|
171
174
|
let skip = 0;
|
|
172
175
|
|
|
@@ -197,7 +200,6 @@ export function drawReactPoint(map: MapCombine, point: ReactPoint<unknown>) {
|
|
|
197
200
|
status == 2 && point.event.trigger("right-click");
|
|
198
201
|
});
|
|
199
202
|
ReactDOM.render(point.element(point.props), root);
|
|
200
|
-
|
|
201
203
|
let delay = 0;
|
|
202
204
|
|
|
203
205
|
root.addEventListener("pointerdown", () => {
|
|
@@ -210,13 +212,15 @@ export function drawReactPoint(map: MapCombine, point: ReactPoint<unknown>) {
|
|
|
210
212
|
}, 300);
|
|
211
213
|
}
|
|
212
214
|
});
|
|
213
|
-
|
|
214
215
|
if (point.coordinates) {
|
|
215
216
|
status = 2;
|
|
216
217
|
const p = map.geographyTcanvas(point.coordinates);
|
|
217
218
|
root.style.left = `${p[0]}px`;
|
|
218
219
|
root.style.top = `${p[1]}px`;
|
|
219
220
|
htmllayer.appendChild(root);
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
point.event.trigger("data-loaded");
|
|
223
|
+
});
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
const onViewChange = () => {
|
|
@@ -320,6 +324,7 @@ export function drawReactPoint(map: MapCombine, point: ReactPoint<unknown>) {
|
|
|
320
324
|
status = 2;
|
|
321
325
|
skip++;
|
|
322
326
|
point.coordinates = event.geography;
|
|
327
|
+
point.event.trigger("data-loaded");
|
|
323
328
|
}
|
|
324
329
|
};
|
|
325
330
|
|
|
@@ -334,6 +339,7 @@ export function drawReactPoint(map: MapCombine, point: ReactPoint<unknown>) {
|
|
|
334
339
|
root.style.pointerEvents = point.silent ? "none" : "all";
|
|
335
340
|
skip++;
|
|
336
341
|
point.coordinates = event.geography;
|
|
342
|
+
point.event.trigger("data-update");
|
|
337
343
|
}
|
|
338
344
|
};
|
|
339
345
|
|
|
@@ -47,6 +47,10 @@ export function bindEvent(map: CesiumMap) {
|
|
|
47
47
|
event.trigger("pointer-down");
|
|
48
48
|
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
|
|
49
49
|
|
|
50
|
+
// 解决 ReactPoint 点击事件无法触发的问题
|
|
51
|
+
container.addEventListener("click", () => {
|
|
52
|
+
event.trigger("left-click");
|
|
53
|
+
});
|
|
50
54
|
container.addEventListener("pointerup", () => {
|
|
51
55
|
if (target) {
|
|
52
56
|
target.onPointerUp?.();
|
package/src/cesium/CesiumMap.ts
CHANGED