hn-map 1.0.10 → 1.1.1
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/README.md +5 -22
- package/dist/index.js +2313 -610
- package/package.json +11 -8
- package/src/base/gaode_entity.ts +61 -0
- package/src/base/mars3d_entity.ts +64 -0
- package/src/base/siji_entity.ts +118 -0
- package/src/graphic/circle.ts +218 -0
- package/src/graphic/divPoint.ts +133 -0
- package/src/graphic/imagePoint.ts +237 -0
- package/src/graphic/label.ts +330 -0
- package/src/graphic/line.ts +345 -0
- package/src/graphic/numPoint.ts +290 -0
- package/src/graphic/point.ts +234 -0
- package/src/graphic/polygon.ts +188 -0
- package/src/graphic/rectangle.ts +202 -0
- package/src/index.ts +213 -0
- package/src/layer/cluster.ts +276 -0
- package/src/layer/geoJson.ts +174 -0
- package/src/layer/heatMap.ts +163 -0
- package/src/layer/layer.ts +464 -0
- package/src/layer/pointCloud.ts +78 -0
- package/src/map.ts +433 -0
- package/src/other/route.ts +457 -0
- package/src/types/globals.d.ts +5 -0
- package/src/util.ts +216 -0
- package/src/base/gaode_entity.js +0 -59
- package/src/base/mars3d_entity.js +0 -50
- package/src/graphic/circle.js +0 -159
- package/src/graphic/divPoint.js +0 -86
- package/src/graphic/imagePoint.js +0 -163
- package/src/graphic/label.js +0 -176
- package/src/graphic/line.js +0 -203
- package/src/graphic/numPoint.js +0 -119
- package/src/graphic/point.js +0 -144
- package/src/graphic/polygon.js +0 -111
- package/src/graphic/rectangle.js +0 -115
- package/src/index.js +0 -105
- package/src/layer/cluster.js +0 -277
- package/src/layer/geoJson.js +0 -174
- package/src/layer/heatMap.js +0 -163
- package/src/layer/layer.js +0 -311
- package/src/layer/pointCloud.js +0 -78
- package/src/map.js +0 -303
- package/src/other/route.js +0 -217
- package/src/util.js +0 -103
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hn-map",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "hn-map集成mars3d、高德、思极",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "庞大仙",
|
|
@@ -12,24 +12,27 @@
|
|
|
12
12
|
"admin-template",
|
|
13
13
|
"management-system"
|
|
14
14
|
],
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
17
|
-
"@rollup/plugin-alias": "^5.1.1",
|
|
18
|
-
"rollup-plugin-copy": "^3.5.0"
|
|
19
|
-
},
|
|
15
|
+
"dependencies": {},
|
|
20
16
|
"devDependencies": {
|
|
21
17
|
"@babel/core": "^7.15.0",
|
|
18
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
22
19
|
"@babel/preset-env": "^7.15.0",
|
|
20
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
21
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
23
22
|
"@rollup/plugin-babel": "^5.3.0",
|
|
24
23
|
"@rollup/plugin-commonjs": "^13.0.0",
|
|
25
24
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
26
25
|
"jest": "^27.0.6",
|
|
27
26
|
"rollup": "^2.56.2",
|
|
28
|
-
"rollup-plugin-
|
|
27
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
28
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
29
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
30
|
+
"typescript": "^5.8.3"
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
33
|
"dist",
|
|
32
|
-
"src"
|
|
34
|
+
"src",
|
|
35
|
+
"lib.zip"
|
|
33
36
|
],
|
|
34
37
|
"engines": {
|
|
35
38
|
"node": ">=8.9",
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default class gaode_entity {
|
|
2
|
+
infoWindow: any = null
|
|
3
|
+
hnMap: any = null
|
|
4
|
+
config: any = null
|
|
5
|
+
graphic: any = null
|
|
6
|
+
|
|
7
|
+
constructor(hnMap: any) {
|
|
8
|
+
this.hnMap = hnMap
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 添加属性弹窗
|
|
12
|
+
addPopupByAttr() {
|
|
13
|
+
this.infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
|
|
14
|
+
|
|
15
|
+
const handleClick = (e: any) => {
|
|
16
|
+
const data = this.config.extData.data
|
|
17
|
+
let content = ''
|
|
18
|
+
for (const key in data) {
|
|
19
|
+
content += `<div>${key}: ${data[key]}</div>`
|
|
20
|
+
}
|
|
21
|
+
this.infoWindow.setContent(content);
|
|
22
|
+
this.infoWindow.open(this.hnMap.map.map, e.lnglat);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.graphic.on('click', handleClick)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 添加自定义dom弹窗
|
|
29
|
+
addCustomPopup(getCustomDom: any) {
|
|
30
|
+
this.infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
|
|
31
|
+
|
|
32
|
+
const handleClick = (e:any ) => {
|
|
33
|
+
const data = this.config.extData.data
|
|
34
|
+
const dom = getCustomDom(data)
|
|
35
|
+
this.infoWindow.setContent(dom);
|
|
36
|
+
this.infoWindow.open(this.hnMap.map.map, e.lnglat);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.graphic.on('click', handleClick)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
flyTo() {
|
|
43
|
+
|
|
44
|
+
if (this.graphic.getCenter) {
|
|
45
|
+
this.hnMap.map.map.setCenter(this.graphic.getCenter());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.graphic.getPosition) {
|
|
49
|
+
this.hnMap.map.map.setCenter(this.graphic.getPosition());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (this.graphic.getBounds) {
|
|
53
|
+
const bounds = this.graphic.getBounds();
|
|
54
|
+
this.hnMap.map.map.setBounds(bounds);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
destroy() {
|
|
59
|
+
this.graphic.remove()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {getMapRangeHeightByLevel} from "../util";
|
|
2
|
+
|
|
3
|
+
export default class mars3d_entity {
|
|
4
|
+
option: any = null;
|
|
5
|
+
event: any = {};
|
|
6
|
+
graphic: any = null;
|
|
7
|
+
|
|
8
|
+
constructor(hnMap: any) {
|
|
9
|
+
this.event = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 添加属性弹窗
|
|
13
|
+
addPopupByAttr() {
|
|
14
|
+
this.graphic.bindPopup((event: any) => {
|
|
15
|
+
const data = event.graphic.attr;
|
|
16
|
+
return mars3d.Util.getTemplateHtml({
|
|
17
|
+
title: "详情",
|
|
18
|
+
template: "all",
|
|
19
|
+
attr: data,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 添加自定义dom弹窗
|
|
25
|
+
addCustomPopup(getCustomDom: any) {
|
|
26
|
+
this.graphic.bindPopup(
|
|
27
|
+
async (event: any) => {
|
|
28
|
+
if (event.graphic.attr) {
|
|
29
|
+
const data = event.graphic.attr || {};
|
|
30
|
+
return await getCustomDom(data);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{offsetY: -20}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
flyTo(option = {}) {
|
|
38
|
+
this.graphic.flyTo(option);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
destroy() {
|
|
42
|
+
console.log(this.graphic, "=====this.graphic===");
|
|
43
|
+
this.graphic.destroy();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
on(eventType: any, callback: any) {
|
|
47
|
+
this.off(eventType);
|
|
48
|
+
switch (eventType) {
|
|
49
|
+
case "click":
|
|
50
|
+
this.event[eventType] = () => {
|
|
51
|
+
callback(this.option.data);
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
this.graphic.on(eventType, this.event[eventType]);
|
|
56
|
+
} // 监听事件
|
|
57
|
+
|
|
58
|
+
off(eventType: any) {
|
|
59
|
+
if (this.event[eventType]) {
|
|
60
|
+
this.graphic.off(eventType, this.event[eventType]);
|
|
61
|
+
delete this.event[eventType];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export default class siji_entity {
|
|
2
|
+
event: any = {};
|
|
3
|
+
infoWindow: any = null;
|
|
4
|
+
hnMap: any = null;
|
|
5
|
+
config: any = null;
|
|
6
|
+
graphic: any = null;
|
|
7
|
+
option: any = null;
|
|
8
|
+
type: any = null;
|
|
9
|
+
show:boolean = false;
|
|
10
|
+
|
|
11
|
+
constructor(hnMap: any) {
|
|
12
|
+
this.hnMap = hnMap;
|
|
13
|
+
this.event = {};
|
|
14
|
+
this.show = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 添加属性弹窗
|
|
18
|
+
addPopupByAttr() {
|
|
19
|
+
alert("添加属性弹窗");
|
|
20
|
+
console.log(this.config);
|
|
21
|
+
console.log(this.graphic);
|
|
22
|
+
// 如果已有弹窗,先关闭
|
|
23
|
+
this.removePopup();
|
|
24
|
+
|
|
25
|
+
this.infoWindow = new SGMap.Popup({
|
|
26
|
+
offset: { bottom: [0, 0] },
|
|
27
|
+
className: "my-popupAttr-class",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const handleClick = (e: any) => {
|
|
31
|
+
alert("添加属性弹窗111");
|
|
32
|
+
// const data = e.features[0].properties;
|
|
33
|
+
const data = this.option.data;
|
|
34
|
+
// 创建弹窗内容
|
|
35
|
+
let content = "";
|
|
36
|
+
for (const key in data) {
|
|
37
|
+
content += `<div>${key}: ${data[key]}</div>`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.infoWindow.setHTML(content);
|
|
41
|
+
this.infoWindow.setLngLat(e.lngLat).addTo(this.hnMap.map.map);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
this.hnMap.map.map.on("click", this.config.id, handleClick);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 添加自定义dom弹窗
|
|
48
|
+
addCustomPopup(getCustomDom: any) {
|
|
49
|
+
this.removePopup();
|
|
50
|
+
|
|
51
|
+
this.infoWindow = new SGMap.Popup({
|
|
52
|
+
offset: { bottom: [0, 0] },
|
|
53
|
+
className: "my-customPopup-class",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const handleClick = (e: any) => {
|
|
57
|
+
const data = this.option.data;
|
|
58
|
+
// const data = e.features[0].properties;
|
|
59
|
+
const dom = getCustomDom(data);
|
|
60
|
+
this.infoWindow.setHTML(dom);
|
|
61
|
+
this.infoWindow.setLngLat(e.lngLat).addTo(this.hnMap.map.map);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
this.hnMap.map.map.on("click", this.config.id, handleClick);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 弹窗删除
|
|
68
|
+
removePopup() {
|
|
69
|
+
if (this.infoWindow) {
|
|
70
|
+
this.infoWindow.remove();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
flyTo() {
|
|
75
|
+
let zoom = this.hnMap.map.map.getZoom();
|
|
76
|
+
this.hnMap.map.map.flyTo({
|
|
77
|
+
duration: 1000, // 持续时间
|
|
78
|
+
zoom: zoom,
|
|
79
|
+
center:
|
|
80
|
+
this.type == "line" ||
|
|
81
|
+
this.type == "dash" ||
|
|
82
|
+
this.type == "flicker" ||
|
|
83
|
+
this.type == "flow" ||
|
|
84
|
+
this.type == "arrow" ||
|
|
85
|
+
this.type == "mapLabel" ||
|
|
86
|
+
this.type == "polygon" ||
|
|
87
|
+
this.type == "rectangle"
|
|
88
|
+
? this.option.position[0]
|
|
89
|
+
: this.type == "route"
|
|
90
|
+
? [this.option.position[0][0], this.option.position[0][1]]
|
|
91
|
+
: this.option.position,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
destroy() {
|
|
96
|
+
this.hnMap.map.map.removeLayer(this.config.id);
|
|
97
|
+
this.hnMap.map.map.removeSource(this.config.id);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
on(eventType: any, eventId: any, callback: any) {
|
|
101
|
+
this.off(eventType, eventId);
|
|
102
|
+
switch (eventType) {
|
|
103
|
+
case "click":
|
|
104
|
+
this.event[eventType] = () => {
|
|
105
|
+
callback(this.option.data);
|
|
106
|
+
};
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
this.hnMap.map.map.on(eventType, eventId, this.event[eventType]);
|
|
110
|
+
} // 监听事件
|
|
111
|
+
|
|
112
|
+
off(eventType: any, eventId: any) {
|
|
113
|
+
if (this.event[eventType]) {
|
|
114
|
+
this.hnMap.map.map.off(eventType, eventId, this.event[eventType]);
|
|
115
|
+
delete this.event[eventType];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
|
|
2
|
+
import mars3d_entity from "../base/mars3d_entity";
|
|
3
|
+
import gaode_entity from "../base/gaode_entity";
|
|
4
|
+
import siji_entity from "../base/siji_entity";
|
|
5
|
+
|
|
6
|
+
export default (hnMap: any) => {
|
|
7
|
+
const defaultOption = {
|
|
8
|
+
id: "",
|
|
9
|
+
position: [],
|
|
10
|
+
type: "color",
|
|
11
|
+
radius: 20,
|
|
12
|
+
color: "#ff0000",
|
|
13
|
+
opacity: 1,
|
|
14
|
+
waveCount: 2,
|
|
15
|
+
waveSpeed: 5,
|
|
16
|
+
outlineWidth: 0,
|
|
17
|
+
outlineColor: "#ffffff",
|
|
18
|
+
outlineOpacity: 1,
|
|
19
|
+
outlineHighLight: false,
|
|
20
|
+
outlineHighLightGlowPower: 0.1,
|
|
21
|
+
outlineHighLightTaperPower: 1,
|
|
22
|
+
scaleByDistance: true,
|
|
23
|
+
distanceDisplayCondition: false,
|
|
24
|
+
distanceDisplayCondition_far: 1,
|
|
25
|
+
distanceDisplayCondition_near: 18,
|
|
26
|
+
data: null,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class mars3d_class extends mars3d_entity {
|
|
30
|
+
type: any = "circle";
|
|
31
|
+
id: any = null;
|
|
32
|
+
option: any = JSON.parse(JSON.stringify(defaultOption));
|
|
33
|
+
config: any = null;
|
|
34
|
+
graphic: any = null;
|
|
35
|
+
|
|
36
|
+
constructor(option: any) {
|
|
37
|
+
super(hnMap);
|
|
38
|
+
this.id = option.id;
|
|
39
|
+
deepMerge(this.option, option);
|
|
40
|
+
this.config = this.formatConfig(this.option);
|
|
41
|
+
this.graphic = new mars3d.graphic.CircleEntity(this.config);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
formatConfig(option: any) {
|
|
45
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
|
|
46
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
|
|
47
|
+
let config: any = {
|
|
48
|
+
id: option.id,
|
|
49
|
+
position: new mars3d.LngLatPoint(
|
|
50
|
+
option.position[0],
|
|
51
|
+
option.position[1],
|
|
52
|
+
option.position[2] || 0
|
|
53
|
+
),
|
|
54
|
+
style: {
|
|
55
|
+
radius: option.radius || 1,
|
|
56
|
+
color: option.color,
|
|
57
|
+
opacity: option.opacity,
|
|
58
|
+
outline: !!option.outlineWidth,
|
|
59
|
+
outlineColor: option.outlineColor,
|
|
60
|
+
outlineWidth: option.outlineWidth,
|
|
61
|
+
outlineOpacity: option.outlineOpacity,
|
|
62
|
+
scaleByDistance: option.scaleByDistance,
|
|
63
|
+
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
64
|
+
distanceDisplayCondition_far: distanceDisplayCondition_far,
|
|
65
|
+
distanceDisplayCondition_near: distanceDisplayCondition_near,
|
|
66
|
+
clampToGround: !option.position[2],
|
|
67
|
+
},
|
|
68
|
+
attr: option.data,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
switch (option.type) {
|
|
72
|
+
case "color":
|
|
73
|
+
config.style.materialType = mars3d.MaterialType.Color;
|
|
74
|
+
break;
|
|
75
|
+
case "wave":
|
|
76
|
+
config.style.materialType = mars3d.MaterialType.CircleWave;
|
|
77
|
+
config.style.materialOptions = {
|
|
78
|
+
color: option.color,
|
|
79
|
+
count: option.waveCount,
|
|
80
|
+
speed: option.waveSpeed,
|
|
81
|
+
};
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (option.outlineHighLight) {
|
|
86
|
+
config.style.outlineStyle = {
|
|
87
|
+
materialType: "PolylineGlow",
|
|
88
|
+
materialOptions: {
|
|
89
|
+
color: option.outlineColor,
|
|
90
|
+
glowPower: option.outlineHighLightGlowPower,
|
|
91
|
+
taperPower: option.outlineHighLightTaperPower,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set(option: any) {
|
|
99
|
+
deepMerge(this.option, option);
|
|
100
|
+
this.config = this.formatConfig(this.option);
|
|
101
|
+
this.graphic.setOptions(this.config);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// flyTo(option = {}) {
|
|
105
|
+
// let config = {}
|
|
106
|
+
// if(option.height){
|
|
107
|
+
// config.scale = this.calculateScaleFromHeight(this.graphic, option.height)
|
|
108
|
+
// }
|
|
109
|
+
//
|
|
110
|
+
// this.graphic.flyTo(config);
|
|
111
|
+
// }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class gaode_class extends gaode_entity {
|
|
115
|
+
id: any = null;
|
|
116
|
+
option: any = JSON.parse(JSON.stringify(defaultOption));
|
|
117
|
+
config: any = null;
|
|
118
|
+
graphic: any = null;
|
|
119
|
+
|
|
120
|
+
constructor(option: any) {
|
|
121
|
+
super(hnMap);
|
|
122
|
+
this.id = option.id;
|
|
123
|
+
deepMerge(this.option, option);
|
|
124
|
+
this.config = this.formatConfig(this.option);
|
|
125
|
+
this.graphic = new AMap.Circle(this.config);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
formatConfig(option: any) {
|
|
129
|
+
let amapPosition = wgs84ToGcj02Format(option.position);
|
|
130
|
+
return {
|
|
131
|
+
center: new AMap.LngLat(amapPosition[0], amapPosition[1]),
|
|
132
|
+
radius: option.radius,
|
|
133
|
+
fillColor: option.color,
|
|
134
|
+
fillOpacity: option.opacity,
|
|
135
|
+
strokeColor: option.outline.color,
|
|
136
|
+
strokeOpacity: option.outline.show ? option.outline.opacity : 0,
|
|
137
|
+
strokeWeight: option.outline.show ? option.outline.width : 0,
|
|
138
|
+
extData: {
|
|
139
|
+
id: option.id,
|
|
140
|
+
data: option.data,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set(option: any) {
|
|
146
|
+
deepMerge(this.option, option);
|
|
147
|
+
this.config = this.formatConfig(this.option);
|
|
148
|
+
this.graphic.setOptions(this.config);
|
|
149
|
+
this.graphic.setCenter(this.config.center);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
class siji_class extends siji_entity {
|
|
153
|
+
type: any = "circle";
|
|
154
|
+
id: any = null;
|
|
155
|
+
option: any = JSON.parse(JSON.stringify(defaultOption));
|
|
156
|
+
config: any = null;
|
|
157
|
+
graphic: any = null;
|
|
158
|
+
|
|
159
|
+
constructor(option: any) {
|
|
160
|
+
super(hnMap);
|
|
161
|
+
this.id = option.id;
|
|
162
|
+
deepMerge(this.option, option);
|
|
163
|
+
this.config = this.formatConfig(this.option);
|
|
164
|
+
this.graphic = new SGMap.DrawCircleHandler(this.config);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
formatConfig(option: any) {
|
|
168
|
+
let config: any = {
|
|
169
|
+
id: option.id,
|
|
170
|
+
map: hnMap.map.map,
|
|
171
|
+
// 允许编辑
|
|
172
|
+
enableEdit: false,
|
|
173
|
+
// 允许调整圆心
|
|
174
|
+
canMove: false,
|
|
175
|
+
// 设置非编辑状态下的图层颜色
|
|
176
|
+
drawColor: option.outlineColor,
|
|
177
|
+
// 设置编辑状态下的图层颜色
|
|
178
|
+
// editColor: "red",
|
|
179
|
+
style: {
|
|
180
|
+
// 设置非编辑状态下多边形面的样式
|
|
181
|
+
polygon: {
|
|
182
|
+
"fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
183
|
+
"fill-opacity": Number(option.opacity),
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
// 编辑数据
|
|
187
|
+
featuresList: [],
|
|
188
|
+
};
|
|
189
|
+
return config;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
set(option: any) {
|
|
193
|
+
deepMerge(this.option, option);
|
|
194
|
+
this.config = this.formatConfig(this.option);
|
|
195
|
+
this.graphic.remove();
|
|
196
|
+
this.graphic.clearData();
|
|
197
|
+
this.graphic = new SGMap.DrawCircleHandler(this.config);
|
|
198
|
+
let featureArr = {
|
|
199
|
+
type: "Feature",
|
|
200
|
+
properties: {
|
|
201
|
+
centerPoint: option.position,
|
|
202
|
+
radius: option.radius,
|
|
203
|
+
},
|
|
204
|
+
geometry: {
|
|
205
|
+
type: "Polygon",
|
|
206
|
+
coordinates: [],
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
this.graphic.addFeature(featureArr);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const fn: any = {
|
|
213
|
+
mars3d: mars3d_class,
|
|
214
|
+
gaode: gaode_class,
|
|
215
|
+
siji: siji_class,
|
|
216
|
+
};
|
|
217
|
+
return fn[hnMap.mapType];
|
|
218
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
|
|
2
|
+
import mars3d_entity from "../base/mars3d_entity";
|
|
3
|
+
import gaode_entity from "../base/gaode_entity";
|
|
4
|
+
import siji_entity from "../base/siji_entity";
|
|
5
|
+
const HorizontalOrigin: any = {
|
|
6
|
+
center: 0,
|
|
7
|
+
left: 1,
|
|
8
|
+
right: -1,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const VerticalOrigin: any = {
|
|
12
|
+
center: 0,
|
|
13
|
+
top: -1,
|
|
14
|
+
bottom: 1,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default (hnMap: any) => {
|
|
18
|
+
const defaultOption = {
|
|
19
|
+
id: "",
|
|
20
|
+
position: [],
|
|
21
|
+
html: "",
|
|
22
|
+
horizontalOrigin: "center",
|
|
23
|
+
verticalOrigin: "center",
|
|
24
|
+
offset: [0, 0],
|
|
25
|
+
scaleByDistance: true,
|
|
26
|
+
distanceDisplayCondition: false,
|
|
27
|
+
distanceDisplayCondition_far: 1,
|
|
28
|
+
distanceDisplayCondition_near: 18,
|
|
29
|
+
data: null,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class mars3d_class extends mars3d_entity {
|
|
33
|
+
type: any = "divPoint";
|
|
34
|
+
id: any = null;
|
|
35
|
+
option: any = JSON.parse(JSON.stringify(defaultOption));
|
|
36
|
+
config: any = null;
|
|
37
|
+
graphic: any = null;
|
|
38
|
+
|
|
39
|
+
constructor(option: any) {
|
|
40
|
+
super(hnMap);
|
|
41
|
+
this.id = option.id;
|
|
42
|
+
deepMerge(this.option, option);
|
|
43
|
+
this.config = this.formatConfig(this.option);
|
|
44
|
+
this.graphic = new mars3d.graphic.DivGraphic(this.config);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
formatConfig(option: any) {
|
|
48
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
|
|
49
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
|
|
50
|
+
return {
|
|
51
|
+
id: option.id,
|
|
52
|
+
position: option.position,
|
|
53
|
+
style: {
|
|
54
|
+
html: option.html,
|
|
55
|
+
offsetX: option.offset[0],
|
|
56
|
+
offsetY: option.offset[1],
|
|
57
|
+
scaleByDistance: option.scaleByDistance,
|
|
58
|
+
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
59
|
+
distanceDisplayCondition_far: distanceDisplayCondition_far,
|
|
60
|
+
distanceDisplayCondition_near: distanceDisplayCondition_near,
|
|
61
|
+
clampToGround: !option.position[2],
|
|
62
|
+
horizontalOrigin: HorizontalOrigin[option.horizontalOrigin],
|
|
63
|
+
verticalOrigin: VerticalOrigin[option.verticalOrigin],
|
|
64
|
+
},
|
|
65
|
+
attr: option.data,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set(option: any) {
|
|
70
|
+
deepMerge(this.option, option);
|
|
71
|
+
this.config = this.formatConfig(this.option);
|
|
72
|
+
this.graphic.setOptions(this.config);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
openPopup() {
|
|
76
|
+
this.graphic.openPopup();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class siji_class extends siji_entity {
|
|
80
|
+
type: any = "divPoint";
|
|
81
|
+
id: any = null;
|
|
82
|
+
option: any = JSON.parse(JSON.stringify(defaultOption));
|
|
83
|
+
config: any = null;
|
|
84
|
+
graphic: any = null;
|
|
85
|
+
|
|
86
|
+
constructor(option: any) {
|
|
87
|
+
super(hnMap);
|
|
88
|
+
this.id = option.id;
|
|
89
|
+
deepMerge(this.option, option);
|
|
90
|
+
this.config = this.formatConfig(this.option);
|
|
91
|
+
this.graphic = new SGMap.Marker(this.config);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
formatConfig(option: any) {
|
|
95
|
+
let el = document.createElement("div");
|
|
96
|
+
el.className = "marker";
|
|
97
|
+
el.id = option.id;
|
|
98
|
+
el.innerHTML = option.html;
|
|
99
|
+
|
|
100
|
+
// el.style.backgroundImage =
|
|
101
|
+
// 'url("https://map.sgcc.com.cn/products/js-sdk/v3/assets/images/markers_new2_4ab0bc5_78.png")';
|
|
102
|
+
el.style.width = "0";
|
|
103
|
+
el.style.height = "0";
|
|
104
|
+
return {
|
|
105
|
+
id: option.id,
|
|
106
|
+
element: el,
|
|
107
|
+
anchor: "center",
|
|
108
|
+
offset: option.offset,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set(option: any) {
|
|
113
|
+
deepMerge(this.option, option);
|
|
114
|
+
this.config = this.formatConfig(this.option);
|
|
115
|
+
if (this.graphic) {
|
|
116
|
+
this.graphic.remove();
|
|
117
|
+
}
|
|
118
|
+
this.graphic = new SGMap.Marker(this.config);
|
|
119
|
+
this.graphic.setLngLat(option.position).addTo(hnMap.map.map);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
openPopup() {
|
|
123
|
+
this.graphic.openPopup();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const fn: any = {
|
|
127
|
+
mars3d: mars3d_class,
|
|
128
|
+
gaode: mars3d_class,
|
|
129
|
+
siji: siji_class,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return fn[hnMap.mapType];
|
|
133
|
+
};
|