@hzab/map-combine 0.4.2-alpha.1 → 0.4.2-alpha.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 +1 -0
- package/package.json +1 -1
- package/src/amap/AMapPoint.ts +149 -143
- package/src/amap/AMapPolygon.ts +196 -195
- package/src/amap/AMapPolyline.ts +186 -185
- package/src/basic/PointAggregation.tsx +22 -11
- package/src/mine/MinePoint.ts +1 -1
- package/src/mine/MinePolygon.ts +2 -1
- package/src/mine/MinePolyline.ts +2 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/amap/AMapPoint.ts
CHANGED
|
@@ -1,143 +1,149 @@
|
|
|
1
|
-
import { Point } from "../basic/Point";
|
|
2
|
-
import { AMap } from "./AMap";
|
|
3
|
-
|
|
4
|
-
const RD = 0.017453292519943295;
|
|
5
|
-
|
|
6
|
-
export function drawPoint(map: AMap, point: Point<unknown>) {
|
|
7
|
-
const { viewer, event, LbsAMap } = map;
|
|
8
|
-
let status = 0;
|
|
9
|
-
let marker = null;
|
|
10
|
-
const _event = {
|
|
11
|
-
onPointerIn() {
|
|
12
|
-
point.event.trigger("pointer-in");
|
|
13
|
-
},
|
|
14
|
-
onPointerOut() {
|
|
15
|
-
point.event.trigger("pointer-out");
|
|
16
|
-
},
|
|
17
|
-
onLClick() {
|
|
18
|
-
point.event.trigger("left-click");
|
|
19
|
-
},
|
|
20
|
-
onRClick(e) {
|
|
21
|
-
event.canvas = [e.pixel.x, e.pixel.y];
|
|
22
|
-
point.event.trigger("right-click");
|
|
23
|
-
},
|
|
24
|
-
onPointerDown() {
|
|
25
|
-
if (point.editable && status == 2) {
|
|
26
|
-
status = 3;
|
|
27
|
-
map.moveable = false;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
onPointerUp() {
|
|
31
|
-
if (point.editable && status == 3) {
|
|
32
|
-
status = 2;
|
|
33
|
-
map.moveable = true;
|
|
34
|
-
point.coordinates = [event.geography[0], event.geography[1], point.height];
|
|
35
|
-
point.event.trigger("data-update");
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const bindEvent = (graphical) => {
|
|
41
|
-
graphical.on("click", _event.onLClick);
|
|
42
|
-
graphical.on("rightclick", _event.onRClick);
|
|
43
|
-
graphical.on("mouseover", _event.onPointerIn);
|
|
44
|
-
graphical.on("mouseout", _event.onPointerOut);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const darwMarker = (opt) => {
|
|
48
|
-
marker = new LbsAMap.Marker({
|
|
49
|
-
...opt,
|
|
50
|
-
title: point._option.name,
|
|
51
|
-
icon: new LbsAMap.Icon({
|
|
52
|
-
image: point.src,
|
|
53
|
-
size: point.size,
|
|
54
|
-
imageSize: point.size,
|
|
55
|
-
}),
|
|
56
|
-
angle: point.rotation * RD,
|
|
57
|
-
anchor: point.center,
|
|
58
|
-
draggable: point.editable,
|
|
59
|
-
extData: {
|
|
60
|
-
cursor: point.cursor,
|
|
61
|
-
silent: point.silent,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
bindEvent(marker);
|
|
65
|
-
viewer.add([marker]);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const eventMarker = (e) => {
|
|
69
|
-
darwMarker({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
break;
|
|
112
|
-
case "
|
|
113
|
-
|
|
114
|
-
break;
|
|
115
|
-
case "
|
|
116
|
-
|
|
117
|
-
break;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
|
|
1
|
+
import { Point } from "../basic/Point";
|
|
2
|
+
import { AMap } from "./AMap";
|
|
3
|
+
|
|
4
|
+
const RD = 0.017453292519943295;
|
|
5
|
+
|
|
6
|
+
export function drawPoint(map: AMap, point: Point<unknown>) {
|
|
7
|
+
const { viewer, event, LbsAMap } = map;
|
|
8
|
+
let status = 0;
|
|
9
|
+
let marker = null;
|
|
10
|
+
const _event = {
|
|
11
|
+
onPointerIn() {
|
|
12
|
+
point.event.trigger("pointer-in");
|
|
13
|
+
},
|
|
14
|
+
onPointerOut() {
|
|
15
|
+
point.event.trigger("pointer-out");
|
|
16
|
+
},
|
|
17
|
+
onLClick() {
|
|
18
|
+
point.event.trigger("left-click");
|
|
19
|
+
},
|
|
20
|
+
onRClick(e) {
|
|
21
|
+
event.canvas = [e.pixel.x, e.pixel.y];
|
|
22
|
+
point.event.trigger("right-click");
|
|
23
|
+
},
|
|
24
|
+
onPointerDown() {
|
|
25
|
+
if (point.editable && status == 2) {
|
|
26
|
+
status = 3;
|
|
27
|
+
map.moveable = false;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
onPointerUp() {
|
|
31
|
+
if (point.editable && status == 3) {
|
|
32
|
+
status = 2;
|
|
33
|
+
map.moveable = true;
|
|
34
|
+
point.coordinates = [event.geography[0], event.geography[1], point.coordinates[2] ?? point.height];
|
|
35
|
+
point.event.trigger("data-update");
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const bindEvent = (graphical) => {
|
|
41
|
+
graphical.on("click", _event.onLClick);
|
|
42
|
+
graphical.on("rightclick", _event.onRClick);
|
|
43
|
+
graphical.on("mouseover", _event.onPointerIn);
|
|
44
|
+
graphical.on("mouseout", _event.onPointerOut);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const darwMarker = (opt) => {
|
|
48
|
+
marker = new LbsAMap.Marker({
|
|
49
|
+
...opt,
|
|
50
|
+
title: point._option.name,
|
|
51
|
+
icon: new LbsAMap.Icon({
|
|
52
|
+
image: point.src,
|
|
53
|
+
size: point.size,
|
|
54
|
+
imageSize: point.size,
|
|
55
|
+
}),
|
|
56
|
+
angle: point.rotation * RD,
|
|
57
|
+
anchor: point.center,
|
|
58
|
+
draggable: point.editable,
|
|
59
|
+
extData: {
|
|
60
|
+
cursor: point.cursor,
|
|
61
|
+
silent: point.silent,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
bindEvent(marker);
|
|
65
|
+
viewer.add([marker]);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const eventMarker = (e) => {
|
|
69
|
+
darwMarker({
|
|
70
|
+
position: new LbsAMap.LngLat(e.lnglat.lng, e.lnglat.lat),
|
|
71
|
+
height: point.coordinates[2] ?? point.height,
|
|
72
|
+
});
|
|
73
|
+
viewer.off("click", eventMarker);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
if (point.coordinates) {
|
|
77
|
+
darwMarker({
|
|
78
|
+
position: new LbsAMap.LngLat(point.coordinates[0], point.coordinates[1]),
|
|
79
|
+
height: point.coordinates[2] ?? point.height,
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
viewer.on("click", eventMarker);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const onUpdate = (e: Set<string>) => {
|
|
86
|
+
const keys = new Set();
|
|
87
|
+
e.forEach((key) => {
|
|
88
|
+
switch (key) {
|
|
89
|
+
case "show":
|
|
90
|
+
if (status) {
|
|
91
|
+
if (point.show) {
|
|
92
|
+
marker.show();
|
|
93
|
+
} else {
|
|
94
|
+
marker.hide();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
case "editable":
|
|
99
|
+
marker.setDraggable(point.editable);
|
|
100
|
+
break;
|
|
101
|
+
case "coordinates":
|
|
102
|
+
if (point.coordinates) {
|
|
103
|
+
marker.setPosition(point.coordinates);
|
|
104
|
+
marker.setzIndex(point.coordinates[2]);
|
|
105
|
+
marker.show();
|
|
106
|
+
status = 2;
|
|
107
|
+
} else {
|
|
108
|
+
marker.hide();
|
|
109
|
+
status = 0;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case "src":
|
|
113
|
+
keys.add("icon");
|
|
114
|
+
break;
|
|
115
|
+
case "size":
|
|
116
|
+
keys.add("icon");
|
|
117
|
+
break;
|
|
118
|
+
case "center":
|
|
119
|
+
marker.setAnchor(point.center);
|
|
120
|
+
break;
|
|
121
|
+
case "rotation":
|
|
122
|
+
marker.setAngle(point.rotation * RD);
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`${key} 还不支持修改`);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
keys.forEach((e) => {
|
|
130
|
+
switch (e) {
|
|
131
|
+
case "icon":
|
|
132
|
+
marker.setIcon(
|
|
133
|
+
new LbsAMap.Icon({
|
|
134
|
+
image: point.src,
|
|
135
|
+
size: point.size,
|
|
136
|
+
imageSize: point.size,
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const onDestroy = () => {
|
|
145
|
+
marker.remove();
|
|
146
|
+
point.event.off("update", onUpdate);
|
|
147
|
+
point.event.off("destroy", onDestroy);
|
|
148
|
+
};
|
|
149
|
+
}
|
package/src/amap/AMapPolygon.ts
CHANGED
|
@@ -1,195 +1,196 @@
|
|
|
1
|
-
import { AMap } from "./AMap";
|
|
2
|
-
import { Polygon } from "../basic/Polygon";
|
|
3
|
-
|
|
4
|
-
export function drawPolygon(map: AMap, polygon: Polygon<unknown>) {
|
|
5
|
-
const { event, viewer, LbsAMap } = map;
|
|
6
|
-
|
|
7
|
-
let status = 0;
|
|
8
|
-
let skip = 0;
|
|
9
|
-
let target = null;
|
|
10
|
-
let aMapPolygonEditor = null;
|
|
11
|
-
|
|
12
|
-
const _event = {
|
|
13
|
-
cursor: polygon.cursor,
|
|
14
|
-
silent: polygon.silent,
|
|
15
|
-
onPointerIn() {
|
|
16
|
-
status == 2 && polygon.event.trigger("pointer-in");
|
|
17
|
-
},
|
|
18
|
-
onPointerOut() {
|
|
19
|
-
status == 2 && polygon.event.trigger("pointer-out");
|
|
20
|
-
},
|
|
21
|
-
onLClick() {
|
|
22
|
-
status == 2 && polygon.event.trigger("left-click");
|
|
23
|
-
},
|
|
24
|
-
onRClick(e) {
|
|
25
|
-
event.canvas = [e.pixel.x, e.pixel.y];
|
|
26
|
-
if (polygon.menu) {
|
|
27
|
-
map.menu.show(polygon.menu);
|
|
28
|
-
}
|
|
29
|
-
status == 2 && polygon.event.trigger("right-click");
|
|
30
|
-
},
|
|
31
|
-
onDbClick() {
|
|
32
|
-
polygon.editable &&
|
|
33
|
-
status == 2 &&
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
aMapPolygonEditor.setTarget(target);
|
|
36
|
-
aMapPolygonEditor.open();
|
|
37
|
-
polygon.event.trigger("start-edit");
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const bindEvent = (graphical) => {
|
|
43
|
-
graphical.on("click", _event.onLClick);
|
|
44
|
-
graphical.on("rightclick", _event.onRClick);
|
|
45
|
-
graphical.on("dblclick", _event.onDbClick);
|
|
46
|
-
graphical.on("mouseover", _event.onPointerIn);
|
|
47
|
-
graphical.on("mouseout", _event.onPointerOut);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
aMapPolygonEditor = new LbsAMap.PolygonEditor(viewer, undefined, {
|
|
51
|
-
createOptions: {
|
|
52
|
-
strokeColor: polygon.stroke,
|
|
53
|
-
strokeWeight: polygon.lineWidth,
|
|
54
|
-
fillOpacity: 0.4,
|
|
55
|
-
fillColor: polygon.fill,
|
|
56
|
-
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
57
|
-
strokeDasharray: [10, 10],
|
|
58
|
-
},
|
|
59
|
-
editOptions: {
|
|
60
|
-
strokeColor: polygon.stroke,
|
|
61
|
-
strokeWeight: polygon.lineWidth,
|
|
62
|
-
fillOpacity: 0.4,
|
|
63
|
-
fillColor: polygon.fill,
|
|
64
|
-
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
65
|
-
strokeDasharray: [10, 10],
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
aMapPolygonEditor.on("add", (e) => {
|
|
70
|
-
status = 3;
|
|
71
|
-
target = e.target;
|
|
72
|
-
bindEvent(target);
|
|
73
|
-
// polygon.event.trigger("data-loaded");
|
|
74
|
-
});
|
|
75
|
-
if (polygon.coordinates) {
|
|
76
|
-
status = 2;
|
|
77
|
-
target = new LbsAMap.Polygon({
|
|
78
|
-
path: polygon.coordinates,
|
|
79
|
-
strokeColor: polygon.stroke,
|
|
80
|
-
strokeWeight: polygon.lineWidth,
|
|
81
|
-
fillOpacity: 0.4,
|
|
82
|
-
fillColor: polygon.fill,
|
|
83
|
-
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
84
|
-
strokeDasharray: [10, 10],
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
aMapPolygonEditor.
|
|
91
|
-
aMapPolygonEditor.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
target.
|
|
114
|
-
target.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
polygon.
|
|
154
|
-
polygon.event.trigger("
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
aMapPolygonEditor.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
aMapPolygonEditor.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
polygon.event.off("
|
|
186
|
-
polygon.event.off("
|
|
187
|
-
polygon.event.off("
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
polygon.event.on("
|
|
193
|
-
polygon.event.on("
|
|
194
|
-
polygon.event.on("
|
|
195
|
-
|
|
1
|
+
import { AMap } from "./AMap";
|
|
2
|
+
import { Polygon } from "../basic/Polygon";
|
|
3
|
+
|
|
4
|
+
export function drawPolygon(map: AMap, polygon: Polygon<unknown>) {
|
|
5
|
+
const { event, viewer, LbsAMap } = map;
|
|
6
|
+
|
|
7
|
+
let status = 0;
|
|
8
|
+
let skip = 0;
|
|
9
|
+
let target = null;
|
|
10
|
+
let aMapPolygonEditor = null;
|
|
11
|
+
|
|
12
|
+
const _event = {
|
|
13
|
+
cursor: polygon.cursor,
|
|
14
|
+
silent: polygon.silent,
|
|
15
|
+
onPointerIn() {
|
|
16
|
+
status == 2 && polygon.event.trigger("pointer-in");
|
|
17
|
+
},
|
|
18
|
+
onPointerOut() {
|
|
19
|
+
status == 2 && polygon.event.trigger("pointer-out");
|
|
20
|
+
},
|
|
21
|
+
onLClick() {
|
|
22
|
+
status == 2 && polygon.event.trigger("left-click");
|
|
23
|
+
},
|
|
24
|
+
onRClick(e) {
|
|
25
|
+
event.canvas = [e.pixel.x, e.pixel.y];
|
|
26
|
+
if (polygon.menu) {
|
|
27
|
+
map.menu.show(polygon.menu);
|
|
28
|
+
}
|
|
29
|
+
status == 2 && polygon.event.trigger("right-click");
|
|
30
|
+
},
|
|
31
|
+
onDbClick() {
|
|
32
|
+
polygon.editable &&
|
|
33
|
+
status == 2 &&
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
aMapPolygonEditor.setTarget(target);
|
|
36
|
+
aMapPolygonEditor.open();
|
|
37
|
+
polygon.event.trigger("start-edit");
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const bindEvent = (graphical) => {
|
|
43
|
+
graphical.on("click", _event.onLClick);
|
|
44
|
+
graphical.on("rightclick", _event.onRClick);
|
|
45
|
+
graphical.on("dblclick", _event.onDbClick);
|
|
46
|
+
graphical.on("mouseover", _event.onPointerIn);
|
|
47
|
+
graphical.on("mouseout", _event.onPointerOut);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
aMapPolygonEditor = new LbsAMap.PolygonEditor(viewer, undefined, {
|
|
51
|
+
createOptions: {
|
|
52
|
+
strokeColor: polygon.stroke,
|
|
53
|
+
strokeWeight: polygon.lineWidth,
|
|
54
|
+
fillOpacity: 0.4,
|
|
55
|
+
fillColor: polygon.fill,
|
|
56
|
+
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
57
|
+
strokeDasharray: [10, 10],
|
|
58
|
+
},
|
|
59
|
+
editOptions: {
|
|
60
|
+
strokeColor: polygon.stroke,
|
|
61
|
+
strokeWeight: polygon.lineWidth,
|
|
62
|
+
fillOpacity: 0.4,
|
|
63
|
+
fillColor: polygon.fill,
|
|
64
|
+
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
65
|
+
strokeDasharray: [10, 10],
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
aMapPolygonEditor.on("add", (e) => {
|
|
70
|
+
status = 3;
|
|
71
|
+
target = e.target;
|
|
72
|
+
bindEvent(target);
|
|
73
|
+
// polygon.event.trigger("data-loaded");
|
|
74
|
+
});
|
|
75
|
+
if (polygon.coordinates) {
|
|
76
|
+
status = 2;
|
|
77
|
+
target = new LbsAMap.Polygon({
|
|
78
|
+
path: polygon.coordinates,
|
|
79
|
+
strokeColor: polygon.stroke,
|
|
80
|
+
strokeWeight: polygon.lineWidth,
|
|
81
|
+
fillOpacity: 0.4,
|
|
82
|
+
fillColor: polygon.fill,
|
|
83
|
+
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
84
|
+
strokeDasharray: [10, 10],
|
|
85
|
+
zIndex: polygon.coordinates[0]?.[2] ?? polygon.height,
|
|
86
|
+
});
|
|
87
|
+
viewer.add(target);
|
|
88
|
+
bindEvent(target);
|
|
89
|
+
} else {
|
|
90
|
+
aMapPolygonEditor.close();
|
|
91
|
+
aMapPolygonEditor.setTarget();
|
|
92
|
+
aMapPolygonEditor.open();
|
|
93
|
+
}
|
|
94
|
+
const onUpdate = (e: Set<string>) => {
|
|
95
|
+
if (skip) {
|
|
96
|
+
skip--;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
e.forEach((key) => {
|
|
101
|
+
switch (key) {
|
|
102
|
+
case "show":
|
|
103
|
+
if (polygon.show) {
|
|
104
|
+
target.show();
|
|
105
|
+
} else {
|
|
106
|
+
target.hide();
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "editable":
|
|
110
|
+
break;
|
|
111
|
+
case "coordinates":
|
|
112
|
+
if (polygon.coordinates) {
|
|
113
|
+
target.setPath(polygon.coordinates);
|
|
114
|
+
target.setzIndex(polygon.coordinates[0]?.[2] ?? polygon.height);
|
|
115
|
+
target.show();
|
|
116
|
+
status = 2;
|
|
117
|
+
} else {
|
|
118
|
+
target.hide();
|
|
119
|
+
status = 0;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case "lineWidth":
|
|
124
|
+
target.setOptions({
|
|
125
|
+
strokeWeight: polygon.lineWidth,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
case "fill":
|
|
129
|
+
target.setOptions({
|
|
130
|
+
fillColor: polygon.fill,
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
case "stroke":
|
|
134
|
+
target.setOptions({
|
|
135
|
+
strokeColor: polygon.stroke,
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
case "dash":
|
|
139
|
+
target.setOptions({
|
|
140
|
+
strokeStyle: polygon.dash ? "dashed" : "solid",
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
throw new Error(`${key} 还不支持修改`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const onDbClick = () => {
|
|
149
|
+
switch (status) {
|
|
150
|
+
case 1:
|
|
151
|
+
status = 2;
|
|
152
|
+
skip++;
|
|
153
|
+
polygon.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
154
|
+
polygon.event.trigger("data-loaded");
|
|
155
|
+
polygon.event.trigger("pointer-in");
|
|
156
|
+
break;
|
|
157
|
+
case 3:
|
|
158
|
+
polygon.event.trigger("stop-edit");
|
|
159
|
+
aMapPolygonEditor.setTarget();
|
|
160
|
+
aMapPolygonEditor.close();
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const onStartEdit = () => {
|
|
165
|
+
switch (status) {
|
|
166
|
+
case 2:
|
|
167
|
+
status = 3;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const onStopEdit = () => {
|
|
173
|
+
if (status == 3) {
|
|
174
|
+
status = 2;
|
|
175
|
+
skip++;
|
|
176
|
+
polygon.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onDestroy = () => {
|
|
181
|
+
viewer.remove(target);
|
|
182
|
+
aMapPolygonEditor.close();
|
|
183
|
+
aMapPolygonEditor.setTarget();
|
|
184
|
+
event.off("double-click", onDbClick);
|
|
185
|
+
polygon.event.off("update", onUpdate);
|
|
186
|
+
polygon.event.off("start-edit", onStartEdit);
|
|
187
|
+
polygon.event.off("stop-edit", onStopEdit);
|
|
188
|
+
polygon.event.off("destroy", onDestroy);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
event.on("double-click", onDbClick);
|
|
192
|
+
polygon.event.on("update", onUpdate);
|
|
193
|
+
polygon.event.on("start-edit", onStartEdit);
|
|
194
|
+
polygon.event.on("stop-edit", onStopEdit);
|
|
195
|
+
polygon.event.on("destroy", onDestroy);
|
|
196
|
+
}
|
package/src/amap/AMapPolyline.ts
CHANGED
|
@@ -1,185 +1,186 @@
|
|
|
1
|
-
import { AMap } from "./AMap";
|
|
2
|
-
import { Polyline } from "../basic/Polyline";
|
|
3
|
-
|
|
4
|
-
export function drawPolyline(map: AMap, polyline: Polyline<unknown>) {
|
|
5
|
-
const { event, viewer, LbsAMap } = map;
|
|
6
|
-
|
|
7
|
-
let status = 0;
|
|
8
|
-
let skip = 0;
|
|
9
|
-
let target = null;
|
|
10
|
-
let aMapPolylineEditor = null;
|
|
11
|
-
|
|
12
|
-
const _event = {
|
|
13
|
-
cursor: polyline.cursor,
|
|
14
|
-
silent: polyline.silent,
|
|
15
|
-
onPointerIn() {
|
|
16
|
-
status == 2 && polyline.event.trigger("pointer-in");
|
|
17
|
-
},
|
|
18
|
-
onPointerOut() {
|
|
19
|
-
status == 2 && polyline.event.trigger("pointer-out");
|
|
20
|
-
},
|
|
21
|
-
onLClick() {
|
|
22
|
-
status == 2 && polyline.event.trigger("left-click");
|
|
23
|
-
},
|
|
24
|
-
onRClick(e) {
|
|
25
|
-
event.canvas = [e.pixel.x, e.pixel.y];
|
|
26
|
-
if (polyline.menu) {
|
|
27
|
-
map.menu.show(polyline.menu);
|
|
28
|
-
}
|
|
29
|
-
status == 2 && polyline.event.trigger("right-click");
|
|
30
|
-
},
|
|
31
|
-
onDbClick() {
|
|
32
|
-
polyline.editable &&
|
|
33
|
-
status == 2 &&
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
aMapPolylineEditor.setTarget(target);
|
|
36
|
-
aMapPolylineEditor.open();
|
|
37
|
-
polyline.event.trigger("start-edit");
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const bindEvent = (graphical) => {
|
|
43
|
-
graphical.on("click", _event.onLClick);
|
|
44
|
-
graphical.on("rightclick", _event.onRClick);
|
|
45
|
-
graphical.on("dblclick", _event.onDbClick);
|
|
46
|
-
graphical.on("mouseover", _event.onPointerIn);
|
|
47
|
-
graphical.on("mouseout", _event.onPointerOut);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
aMapPolylineEditor = new LbsAMap.PolylineEditor(viewer, undefined, {
|
|
51
|
-
createOptions: {
|
|
52
|
-
strokeColor: polyline.stroke,
|
|
53
|
-
strokeWeight: polyline.lineWidth,
|
|
54
|
-
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
55
|
-
strokeDasharray: [10, 10],
|
|
56
|
-
},
|
|
57
|
-
editOptions: {
|
|
58
|
-
strokeColor: polyline.stroke,
|
|
59
|
-
strokeWeight: polyline.lineWidth,
|
|
60
|
-
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
61
|
-
strokeDasharray: [10, 10],
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
aMapPolylineEditor.on("add", (e) => {
|
|
66
|
-
status = 3;
|
|
67
|
-
target = e.target;
|
|
68
|
-
bindEvent(target);
|
|
69
|
-
// polygon.event.trigger("data-loaded");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
if (polyline.coordinates) {
|
|
73
|
-
status = 2;
|
|
74
|
-
target = new LbsAMap.Polyline({
|
|
75
|
-
path: polyline.coordinates,
|
|
76
|
-
strokeColor: polyline.stroke,
|
|
77
|
-
strokeWeight: polyline.lineWidth,
|
|
78
|
-
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
79
|
-
strokeDasharray: [10, 10],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
aMapPolylineEditor.
|
|
86
|
-
aMapPolylineEditor.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
target.
|
|
109
|
-
target.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
polyline.
|
|
144
|
-
polyline.event.trigger("
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
aMapPolylineEditor.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
aMapPolylineEditor.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
polyline.event.off("
|
|
176
|
-
polyline.event.off("
|
|
177
|
-
polyline.event.off("
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
polyline.event.on("
|
|
183
|
-
polyline.event.on("
|
|
184
|
-
polyline.event.on("
|
|
185
|
-
|
|
1
|
+
import { AMap } from "./AMap";
|
|
2
|
+
import { Polyline } from "../basic/Polyline";
|
|
3
|
+
|
|
4
|
+
export function drawPolyline(map: AMap, polyline: Polyline<unknown>) {
|
|
5
|
+
const { event, viewer, LbsAMap } = map;
|
|
6
|
+
|
|
7
|
+
let status = 0;
|
|
8
|
+
let skip = 0;
|
|
9
|
+
let target = null;
|
|
10
|
+
let aMapPolylineEditor = null;
|
|
11
|
+
|
|
12
|
+
const _event = {
|
|
13
|
+
cursor: polyline.cursor,
|
|
14
|
+
silent: polyline.silent,
|
|
15
|
+
onPointerIn() {
|
|
16
|
+
status == 2 && polyline.event.trigger("pointer-in");
|
|
17
|
+
},
|
|
18
|
+
onPointerOut() {
|
|
19
|
+
status == 2 && polyline.event.trigger("pointer-out");
|
|
20
|
+
},
|
|
21
|
+
onLClick() {
|
|
22
|
+
status == 2 && polyline.event.trigger("left-click");
|
|
23
|
+
},
|
|
24
|
+
onRClick(e) {
|
|
25
|
+
event.canvas = [e.pixel.x, e.pixel.y];
|
|
26
|
+
if (polyline.menu) {
|
|
27
|
+
map.menu.show(polyline.menu);
|
|
28
|
+
}
|
|
29
|
+
status == 2 && polyline.event.trigger("right-click");
|
|
30
|
+
},
|
|
31
|
+
onDbClick() {
|
|
32
|
+
polyline.editable &&
|
|
33
|
+
status == 2 &&
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
aMapPolylineEditor.setTarget(target);
|
|
36
|
+
aMapPolylineEditor.open();
|
|
37
|
+
polyline.event.trigger("start-edit");
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const bindEvent = (graphical) => {
|
|
43
|
+
graphical.on("click", _event.onLClick);
|
|
44
|
+
graphical.on("rightclick", _event.onRClick);
|
|
45
|
+
graphical.on("dblclick", _event.onDbClick);
|
|
46
|
+
graphical.on("mouseover", _event.onPointerIn);
|
|
47
|
+
graphical.on("mouseout", _event.onPointerOut);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
aMapPolylineEditor = new LbsAMap.PolylineEditor(viewer, undefined, {
|
|
51
|
+
createOptions: {
|
|
52
|
+
strokeColor: polyline.stroke,
|
|
53
|
+
strokeWeight: polyline.lineWidth,
|
|
54
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
55
|
+
strokeDasharray: [10, 10],
|
|
56
|
+
},
|
|
57
|
+
editOptions: {
|
|
58
|
+
strokeColor: polyline.stroke,
|
|
59
|
+
strokeWeight: polyline.lineWidth,
|
|
60
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
61
|
+
strokeDasharray: [10, 10],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
aMapPolylineEditor.on("add", (e) => {
|
|
66
|
+
status = 3;
|
|
67
|
+
target = e.target;
|
|
68
|
+
bindEvent(target);
|
|
69
|
+
// polygon.event.trigger("data-loaded");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (polyline.coordinates) {
|
|
73
|
+
status = 2;
|
|
74
|
+
target = new LbsAMap.Polyline({
|
|
75
|
+
path: polyline.coordinates,
|
|
76
|
+
strokeColor: polyline.stroke,
|
|
77
|
+
strokeWeight: polyline.lineWidth,
|
|
78
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
79
|
+
strokeDasharray: [10, 10],
|
|
80
|
+
zIndex: polyline.coordinates[0]?.[2] ?? polyline.height,
|
|
81
|
+
});
|
|
82
|
+
viewer.add(target);
|
|
83
|
+
bindEvent(target);
|
|
84
|
+
} else {
|
|
85
|
+
aMapPolylineEditor.close();
|
|
86
|
+
aMapPolylineEditor.setTarget();
|
|
87
|
+
aMapPolylineEditor.open();
|
|
88
|
+
}
|
|
89
|
+
const onUpdate = (e: Set<string>) => {
|
|
90
|
+
if (skip) {
|
|
91
|
+
skip--;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
e.forEach((key) => {
|
|
96
|
+
switch (key) {
|
|
97
|
+
case "show":
|
|
98
|
+
if (polyline.show) {
|
|
99
|
+
target.show();
|
|
100
|
+
} else {
|
|
101
|
+
target.hide();
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case "editable":
|
|
105
|
+
break;
|
|
106
|
+
case "coordinates":
|
|
107
|
+
if (polyline.coordinates) {
|
|
108
|
+
target.setPath(polyline.coordinates);
|
|
109
|
+
target.setzIndex(polyline.coordinates[0]?.[2] ?? polyline.height);
|
|
110
|
+
target.show();
|
|
111
|
+
status = 2;
|
|
112
|
+
} else {
|
|
113
|
+
target.hide();
|
|
114
|
+
status = 0;
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
case "lineWidth":
|
|
119
|
+
target.setOptions({
|
|
120
|
+
strokeWeight: polyline.lineWidth,
|
|
121
|
+
});
|
|
122
|
+
break;
|
|
123
|
+
case "stroke":
|
|
124
|
+
target.setOptions({
|
|
125
|
+
strokeColor: polyline.stroke,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
case "dash":
|
|
129
|
+
target.setOptions({
|
|
130
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(`${key} 还不支持修改`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const onDbClick = () => {
|
|
139
|
+
switch (status) {
|
|
140
|
+
case 1:
|
|
141
|
+
status = 2;
|
|
142
|
+
skip++;
|
|
143
|
+
polyline.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
144
|
+
polyline.event.trigger("data-loaded");
|
|
145
|
+
polyline.event.trigger("pointer-in");
|
|
146
|
+
break;
|
|
147
|
+
case 3:
|
|
148
|
+
polyline.event.trigger("stop-edit");
|
|
149
|
+
aMapPolylineEditor.setTarget();
|
|
150
|
+
aMapPolylineEditor.close();
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const onStartEdit = () => {
|
|
155
|
+
switch (status) {
|
|
156
|
+
case 2:
|
|
157
|
+
status = 3;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const onStopEdit = () => {
|
|
163
|
+
if (status == 3) {
|
|
164
|
+
status = 2;
|
|
165
|
+
skip++;
|
|
166
|
+
polyline.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const onDestroy = () => {
|
|
171
|
+
viewer.remove(target);
|
|
172
|
+
aMapPolylineEditor.close();
|
|
173
|
+
aMapPolylineEditor.setTarget();
|
|
174
|
+
event.off("double-click", onDbClick);
|
|
175
|
+
polyline.event.off("update", onUpdate);
|
|
176
|
+
polyline.event.off("start-edit", onStartEdit);
|
|
177
|
+
polyline.event.off("stop-edit", onStopEdit);
|
|
178
|
+
polyline.event.off("destroy", onDestroy);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
event.on("double-click", onDbClick);
|
|
182
|
+
polyline.event.on("update", onUpdate);
|
|
183
|
+
polyline.event.on("start-edit", onStartEdit);
|
|
184
|
+
polyline.event.on("stop-edit", onStopEdit);
|
|
185
|
+
polyline.event.on("destroy", onDestroy);
|
|
186
|
+
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
import { throttle } from "lodash";
|
|
3
2
|
|
|
4
3
|
import { LATTOONE, LONTOONE } from "../utils/static";
|
|
5
4
|
import { getUUID, setValue } from "../utils";
|
|
6
5
|
import { MapCombine } from "../basic/MapCombine";
|
|
7
6
|
import { ReactPoint } from "./ReactPoint";
|
|
8
7
|
|
|
8
|
+
export interface PointOption {
|
|
9
|
+
coordinates: number[];
|
|
10
|
+
props?: any;
|
|
11
|
+
}
|
|
9
12
|
export interface PointAggregationOption {
|
|
10
13
|
/** 组件名,唯一标识 */
|
|
11
14
|
name: string;
|
|
12
15
|
/** 组件是否显示 */
|
|
13
16
|
show: boolean;
|
|
14
17
|
/** 数据点 */
|
|
15
|
-
datas:
|
|
18
|
+
datas: PointOption[];
|
|
16
19
|
/** 小于该值的等级下会聚合 */
|
|
17
20
|
maxZoomLevel?: number;
|
|
18
21
|
/** 值越大聚合点的间距越小 */
|
|
19
22
|
density?: number;
|
|
20
23
|
/** 点的展示元素 */
|
|
21
|
-
element(datas:
|
|
24
|
+
element(datas: PointOption[], p: number[]): ReactElement;
|
|
22
25
|
/** 坐标处理回调 */
|
|
23
26
|
location(lonlat: number[]): number[];
|
|
24
27
|
}
|
|
@@ -28,10 +31,12 @@ class TileNode {
|
|
|
28
31
|
private _element: any;
|
|
29
32
|
marker: ReactPoint | undefined;
|
|
30
33
|
private _map: MapCombine;
|
|
31
|
-
|
|
34
|
+
option;
|
|
35
|
+
constructor(map: MapCombine, location: number[], element: ReactElement, option = {}) {
|
|
32
36
|
this._map = map;
|
|
33
37
|
this._location = location;
|
|
34
38
|
this._element = element;
|
|
39
|
+
this.option = option;
|
|
35
40
|
}
|
|
36
41
|
test(east: number, south: number, west: number, north: number) {
|
|
37
42
|
if (
|
|
@@ -42,6 +47,7 @@ class TileNode {
|
|
|
42
47
|
) {
|
|
43
48
|
if (!this.marker) {
|
|
44
49
|
const option = {
|
|
50
|
+
...this.option,
|
|
45
51
|
show: true,
|
|
46
52
|
name: getUUID(),
|
|
47
53
|
element: () => this._element,
|
|
@@ -94,6 +100,8 @@ export class PointAggregation {
|
|
|
94
100
|
this._onAfterViewChange = this.onAfterViewChange.bind(this);
|
|
95
101
|
this.onAfterViewChange();
|
|
96
102
|
event.on("view-moveEnd", this._onAfterViewChange);
|
|
103
|
+
// 初始化没有渲染,移动之后才渲染点位
|
|
104
|
+
this._update();
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
private _turnon(zoom: number) {
|
|
@@ -106,10 +114,12 @@ export class PointAggregation {
|
|
|
106
114
|
const grid = new Map();
|
|
107
115
|
const max = Math.pow(2, zoom) * (_option.density ?? 1);
|
|
108
116
|
_option.datas.forEach((data) => {
|
|
109
|
-
const location =
|
|
117
|
+
const location =
|
|
118
|
+
typeof _option.location === "function" ? _option.location(data.coordinates) : data.coordinates;
|
|
110
119
|
const x = Math.floor(LONTOONE.forward(location[0]) * max * 2);
|
|
111
120
|
const y = Math.floor(LATTOONE.forward(location[1]) * max);
|
|
112
121
|
const k = `${x}_${y}`;
|
|
122
|
+
// 对数据进行分组
|
|
113
123
|
const group = grid.get(k);
|
|
114
124
|
if (group) {
|
|
115
125
|
group.push(data);
|
|
@@ -118,10 +128,11 @@ export class PointAggregation {
|
|
|
118
128
|
}
|
|
119
129
|
});
|
|
120
130
|
// 处理聚合点坐标
|
|
121
|
-
grid.forEach((
|
|
122
|
-
const { lon, lat } =
|
|
131
|
+
grid.forEach((group) => {
|
|
132
|
+
const { lon, lat } = group?.reduce(
|
|
123
133
|
(a, b) => {
|
|
124
|
-
const
|
|
134
|
+
const { coordinates } = b;
|
|
135
|
+
const loaction = typeof _option.location === "function" ? _option.location(coordinates) : coordinates;
|
|
125
136
|
a.lon += loaction[0];
|
|
126
137
|
a.lat += loaction[1];
|
|
127
138
|
return a;
|
|
@@ -131,8 +142,8 @@ export class PointAggregation {
|
|
|
131
142
|
cache.push(
|
|
132
143
|
new TileNode(
|
|
133
144
|
this._map,
|
|
134
|
-
[lon /
|
|
135
|
-
_option.element(
|
|
145
|
+
[lon / group.length, lat / group.length],
|
|
146
|
+
_option.element(group, [lon / group.length, lat / group.length]),
|
|
136
147
|
),
|
|
137
148
|
);
|
|
138
149
|
});
|
|
@@ -140,7 +151,7 @@ export class PointAggregation {
|
|
|
140
151
|
} else {
|
|
141
152
|
const cache: TileNode[] = [];
|
|
142
153
|
_option.datas.forEach((e) => {
|
|
143
|
-
const location = _option.location(e);
|
|
154
|
+
const location = _option.location(e.coordinates);
|
|
144
155
|
cache.push(new TileNode(this._map, location, _option.element([e], location)));
|
|
145
156
|
});
|
|
146
157
|
_cache.set(zoom, cache);
|
package/src/mine/MinePoint.ts
CHANGED
|
@@ -69,7 +69,7 @@ export function drawPoint(map: MineMap, point: Point<unknown>) {
|
|
|
69
69
|
break;
|
|
70
70
|
case "coordinates":
|
|
71
71
|
if (point.coordinates) {
|
|
72
|
-
marker.setLngLat(point.coordinates).setAltitude(point.coordinates[2] ??
|
|
72
|
+
marker.setLngLat(point.coordinates).setAltitude(point.coordinates[2] ?? point.height);
|
|
73
73
|
switch (status) {
|
|
74
74
|
case 0:
|
|
75
75
|
point.show && marker.addTo(map.viewer);
|
package/src/mine/MinePolygon.ts
CHANGED
|
@@ -50,6 +50,7 @@ function getPolygonOption(polygon: Polygon<unknown>) {
|
|
|
50
50
|
"fill-color": color,
|
|
51
51
|
"fill-opacity": opacity,
|
|
52
52
|
},
|
|
53
|
+
zIndex: polygon.coordinates[0]?.[2] ?? polygon.height,
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -148,7 +149,7 @@ function main(map: MineMap, polygon: Polygon<unknown>) {
|
|
|
148
149
|
type: "Feature",
|
|
149
150
|
geometry: {
|
|
150
151
|
type: "Polygon",
|
|
151
|
-
coordinates: [[...coordinates, coordinates[0]]],
|
|
152
|
+
coordinates: [[...coordinates, coordinates[0]].map((it) => [it[0], it[1], it[2] ?? polygon.height])],
|
|
152
153
|
},
|
|
153
154
|
properties: {
|
|
154
155
|
id: polygon.name,
|
package/src/mine/MinePolyline.ts
CHANGED
|
@@ -56,6 +56,7 @@ function getLayerOption(polyline: Polyline<unknown>) {
|
|
|
56
56
|
"line-color": polyline.stroke,
|
|
57
57
|
"line-width": polyline.lineWidth,
|
|
58
58
|
},
|
|
59
|
+
zIndex: polyline.coordinates[0]?.[2] ?? polyline.height,
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -130,7 +131,7 @@ function main(map: MineMap, polyline: Polyline<unknown>) {
|
|
|
130
131
|
type: "Feature",
|
|
131
132
|
geometry: {
|
|
132
133
|
type: "LineString",
|
|
133
|
-
coordinates: coordinates,
|
|
134
|
+
coordinates: coordinates?.map((it) => [it[0], it[1], it[2] ?? polyline.height]),
|
|
134
135
|
},
|
|
135
136
|
properties: {
|
|
136
137
|
id: polyline.name,
|