hn-map 1.0.9 → 1.1.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/README.md +5 -22
- package/dist/index.js +2317 -609
- 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 +202 -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 +217 -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 -104
- 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/src/graphic/line.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import {deepMerge, wgs84ToGcj02Format} from '../util.js'
|
|
2
|
-
import mars3d_entity from '../base/mars3d_entity.js'
|
|
3
|
-
import gaode_entity from "../base/gaode_entity.js";
|
|
4
|
-
|
|
5
|
-
export default (hnMap) => {
|
|
6
|
-
|
|
7
|
-
const defaultOption = {
|
|
8
|
-
id: "",
|
|
9
|
-
position: [],
|
|
10
|
-
type: 'line',
|
|
11
|
-
color: "#ffffff",
|
|
12
|
-
width: 2,
|
|
13
|
-
opacity: 1,
|
|
14
|
-
outline: false,
|
|
15
|
-
outlineColor: "#ffffff",
|
|
16
|
-
outlineWidth: 2,
|
|
17
|
-
dashColor: "#00ff00",
|
|
18
|
-
dashLength: 16,
|
|
19
|
-
image: '',
|
|
20
|
-
repeat: [1, 1],
|
|
21
|
-
speed: 5,
|
|
22
|
-
scaleByDistance: true,
|
|
23
|
-
distanceDisplayCondition: false,
|
|
24
|
-
distanceDisplayCondition_far: Number.MAX_VALUE,
|
|
25
|
-
distanceDisplayCondition_near: 0,
|
|
26
|
-
data: null,
|
|
27
|
-
combine: false,
|
|
28
|
-
instances:[],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class mars3d_class extends mars3d_entity {
|
|
32
|
-
type = 'line'
|
|
33
|
-
id = null
|
|
34
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
35
|
-
config = null
|
|
36
|
-
graphic = null
|
|
37
|
-
|
|
38
|
-
constructor(option) {
|
|
39
|
-
super()
|
|
40
|
-
this.id = option.id
|
|
41
|
-
deepMerge(this.option, option)
|
|
42
|
-
this.config = this.formatConfig(this.option)
|
|
43
|
-
if(option.combine){
|
|
44
|
-
this.graphic = new mars3d.graphic.PolylineCombine(this.config)
|
|
45
|
-
}else{
|
|
46
|
-
this.graphic = new mars3d.graphic.PolylineEntity(this.config)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
formatConfig(option) {
|
|
51
|
-
let config = {}
|
|
52
|
-
if (option.combine) {
|
|
53
|
-
config = {
|
|
54
|
-
id: option.id,
|
|
55
|
-
combine: true,
|
|
56
|
-
instances: option.instances.map(item => {
|
|
57
|
-
let itemOption = JSON.parse(JSON.stringify(defaultOption))
|
|
58
|
-
deepMerge(itemOption, item)
|
|
59
|
-
return this.formatConfig(itemOption)
|
|
60
|
-
}),
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
|
|
64
|
-
config = {
|
|
65
|
-
id: option.id,
|
|
66
|
-
positions: option.position,
|
|
67
|
-
style: {
|
|
68
|
-
materialType: 'Color',
|
|
69
|
-
color: option.color,
|
|
70
|
-
width: option.width,
|
|
71
|
-
opacity: option.opacity,
|
|
72
|
-
outline: option.outline,
|
|
73
|
-
outlineColor: option.outlineColor,
|
|
74
|
-
outlineWidth: option.outlineWidth,
|
|
75
|
-
clampToGround: !option.position[0][2],
|
|
76
|
-
scaleByDistance: option.scaleByDistance,
|
|
77
|
-
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
78
|
-
distanceDisplayCondition_far: option.distanceDisplayCondition_far,
|
|
79
|
-
distanceDisplayCondition_near: option.distanceDisplayCondition_near,
|
|
80
|
-
},
|
|
81
|
-
attr: option.data
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
switch (option.type) {
|
|
85
|
-
case 'line':
|
|
86
|
-
config.style.materialType = 'Color'
|
|
87
|
-
break
|
|
88
|
-
case 'dash':
|
|
89
|
-
config.style.materialType = 'PolylineDash'
|
|
90
|
-
config.style.materialOptions = {
|
|
91
|
-
color: option.color,
|
|
92
|
-
gapColor: option.dashColor,
|
|
93
|
-
dashPattern: option.dashPattern
|
|
94
|
-
}
|
|
95
|
-
break
|
|
96
|
-
case 'flicker':
|
|
97
|
-
config.style.materialType = 'LineFlicker'
|
|
98
|
-
config.style.materialOptions = {
|
|
99
|
-
color: option.color,
|
|
100
|
-
speed: option.speed,
|
|
101
|
-
}
|
|
102
|
-
break
|
|
103
|
-
case 'flow':
|
|
104
|
-
config.style.materialType = 'LineFlow'
|
|
105
|
-
config.style.materialOptions = {
|
|
106
|
-
color: option.color,
|
|
107
|
-
image: option.image,
|
|
108
|
-
repeat: new Cesium.Cartesian2(option.repeat[0], option.repeat[1]),
|
|
109
|
-
speed: option.speed,
|
|
110
|
-
}
|
|
111
|
-
break
|
|
112
|
-
case 'arrow':
|
|
113
|
-
config.style.materialType = 'PolylineArrow'
|
|
114
|
-
config.style.materialOptions = {
|
|
115
|
-
color: option.color,
|
|
116
|
-
}
|
|
117
|
-
break
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return config
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
set(option) {
|
|
125
|
-
deepMerge(this.option, option)
|
|
126
|
-
this.config = this.formatConfig(this.option)
|
|
127
|
-
this.graphic.setOptions(this.config)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// flyTo(option = {}) {
|
|
132
|
-
// let config = {}
|
|
133
|
-
// if(option.height){
|
|
134
|
-
// config.scale = this.calculateScaleFromHeight(this.graphic, option.height)
|
|
135
|
-
// }
|
|
136
|
-
// console.log(config)
|
|
137
|
-
// this.graphic.flyTo(config);
|
|
138
|
-
// }
|
|
139
|
-
|
|
140
|
-
openPopup() {
|
|
141
|
-
this.graphic.openPopup();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* 判断给定的经纬度坐标是否在某个多边形内
|
|
147
|
-
*
|
|
148
|
-
* @param {number} lng - 经度
|
|
149
|
-
* @param {number} lat - 纬度
|
|
150
|
-
* @returns {boolean} 返回一个布尔值,如果给定的坐标在多边形内则为true,否则为false
|
|
151
|
-
*/
|
|
152
|
-
isInPoly(lng, lat) {
|
|
153
|
-
return this.graphic.isInPoly(new mars3d.LngLatPoint(lng, lat))
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
class gaode_class extends gaode_entity {
|
|
159
|
-
|
|
160
|
-
id = null
|
|
161
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
162
|
-
config = null
|
|
163
|
-
graphic = null
|
|
164
|
-
|
|
165
|
-
constructor(option) {
|
|
166
|
-
super()
|
|
167
|
-
this.id = option.id
|
|
168
|
-
deepMerge(this.option, option)
|
|
169
|
-
this.config = this.formatConfig(this.option)
|
|
170
|
-
this.graphic = new AMap.Polyline(this.config)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
formatConfig(option) {
|
|
174
|
-
let amapPosition = wgs84ToGcj02Format(option.position)
|
|
175
|
-
return {
|
|
176
|
-
path: amapPosition,
|
|
177
|
-
strokeColor: option.color,
|
|
178
|
-
strokeOpacity: option.opacity,
|
|
179
|
-
strokeWeight: option.width,
|
|
180
|
-
outlineColor: option.outlineColor,
|
|
181
|
-
borderWeight: option.outlineWidth,
|
|
182
|
-
extData: {
|
|
183
|
-
id: option.id,
|
|
184
|
-
data: option.data,
|
|
185
|
-
},
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
set(option) {
|
|
190
|
-
deepMerge(this.option, option)
|
|
191
|
-
this.config = this.formatConfig(this.option)
|
|
192
|
-
this.graphic.setOptions(this.config)
|
|
193
|
-
this.graphic.setPath(this.config.path)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const fn = {
|
|
198
|
-
mars3d: mars3d_class,
|
|
199
|
-
gaode: gaode_class
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return fn[hnMap.mapType]
|
|
203
|
-
}
|
package/src/graphic/numPoint.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {deepMerge, wgs84ToGcj02Format} from '../util.js'
|
|
2
|
-
import mars3d_entity from '../base/mars3d_entity.js'
|
|
3
|
-
import gaode_entity from "../base/gaode_entity.js";
|
|
4
|
-
|
|
5
|
-
export default (hnMap) => {
|
|
6
|
-
const defaultOption = {
|
|
7
|
-
id: "",
|
|
8
|
-
position: [],
|
|
9
|
-
num: 0,
|
|
10
|
-
color: "#ffffff",
|
|
11
|
-
opacity: 1,
|
|
12
|
-
size: 6,
|
|
13
|
-
fontColor: "#000000",
|
|
14
|
-
scale: 1,
|
|
15
|
-
scaleByDistance: true,
|
|
16
|
-
distanceDisplayCondition: false,
|
|
17
|
-
distanceDisplayCondition_far: Number.MAX_VALUE,
|
|
18
|
-
distanceDisplayCondition_near: 0,
|
|
19
|
-
data: null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class mars3d_class extends mars3d_entity {
|
|
23
|
-
type = 'numPoint'
|
|
24
|
-
id = null
|
|
25
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
26
|
-
config = null
|
|
27
|
-
graphic = null
|
|
28
|
-
|
|
29
|
-
constructor(option) {
|
|
30
|
-
super()
|
|
31
|
-
this.id = option.id
|
|
32
|
-
deepMerge(this.option, option)
|
|
33
|
-
this.config = this.formatConfig(this.option)
|
|
34
|
-
this.graphic = new mars3d.graphic.BillboardEntity(this.config)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
formatConfig(option) {
|
|
38
|
-
return {
|
|
39
|
-
id: option.id,
|
|
40
|
-
position: option.position,
|
|
41
|
-
style: {
|
|
42
|
-
image: mars3d.Util.getCircleImage(option.num, {
|
|
43
|
-
color: option.color,
|
|
44
|
-
radius: option.size / 2,
|
|
45
|
-
borderWidth: 0,
|
|
46
|
-
fontColor: option.fontColor,
|
|
47
|
-
}),
|
|
48
|
-
scale: option.scale,
|
|
49
|
-
clampToGround: !option.position[2],
|
|
50
|
-
scaleByDistance: option.scaleByDistance,
|
|
51
|
-
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
52
|
-
distanceDisplayCondition_far: option.distanceDisplayCondition_far,
|
|
53
|
-
distanceDisplayCondition_near: option.distanceDisplayCondition_near
|
|
54
|
-
},
|
|
55
|
-
attr: option.data
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
set(option) {
|
|
60
|
-
deepMerge(this.option, option)
|
|
61
|
-
this.config = this.formatConfig(this.option)
|
|
62
|
-
this.graphic.setOptions(this.config)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class gaode_class extends gaode_entity {
|
|
67
|
-
id = null
|
|
68
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
69
|
-
config = null
|
|
70
|
-
graphic = null
|
|
71
|
-
|
|
72
|
-
constructor(option) {
|
|
73
|
-
super()
|
|
74
|
-
this.id = option.id
|
|
75
|
-
deepMerge(this.option, option)
|
|
76
|
-
this.config = this.formatConfig(this.option)
|
|
77
|
-
this.graphic = new AMap.Marker(this.config)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
formatConfig(option) {
|
|
81
|
-
const amapPosition = wgs84ToGcj02Format(option.position)
|
|
82
|
-
var markerContent =
|
|
83
|
-
`<div style="
|
|
84
|
-
background-color: ${option.color || "#ffff00"};
|
|
85
|
-
font-size: ${option.size / 2}px;
|
|
86
|
-
border-radius: 50%;
|
|
87
|
-
width: ${option.size}px;
|
|
88
|
-
height: ${option.size}px;
|
|
89
|
-
text-align: center;
|
|
90
|
-
line-height: ${option.size}px;
|
|
91
|
-
color: ${option.fontColor};"
|
|
92
|
-
>${option.num}</div>`;
|
|
93
|
-
return {
|
|
94
|
-
id: option.id,
|
|
95
|
-
position: new AMap.LngLat(amapPosition[0], amapPosition[1]),
|
|
96
|
-
content: markerContent,
|
|
97
|
-
anchor: 'top-center',
|
|
98
|
-
offset: [0, -20],
|
|
99
|
-
extData: {
|
|
100
|
-
id: option.id,
|
|
101
|
-
data: option.data,
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
set(option) {
|
|
107
|
-
deepMerge(this.option, option)
|
|
108
|
-
this.config = this.formatConfig(this.option)
|
|
109
|
-
this.graphic.setOptions(this.config)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const fn = {
|
|
114
|
-
mars3d: mars3d_class,
|
|
115
|
-
gaode: gaode_class
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return fn[hnMap.mapType]
|
|
119
|
-
}
|
package/src/graphic/point.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import {deepMerge, wgs84ToGcj02Format} from '../util.js'
|
|
2
|
-
import mars3d_entity from '../base/mars3d_entity.js'
|
|
3
|
-
import gaode_entity from '../base/gaode_entity.js'
|
|
4
|
-
|
|
5
|
-
export default (hnMap) => {
|
|
6
|
-
|
|
7
|
-
const defaultOption = {
|
|
8
|
-
id: "",
|
|
9
|
-
position: [],
|
|
10
|
-
color: "#ffffff",
|
|
11
|
-
opacity: 1,
|
|
12
|
-
size: 6,
|
|
13
|
-
text: "",
|
|
14
|
-
fontSize: 12,
|
|
15
|
-
fontColor: "#ffffff",
|
|
16
|
-
fontOpacity: 1,
|
|
17
|
-
fontOffset: [0, 0],
|
|
18
|
-
outline: false,
|
|
19
|
-
outlineColor: "#ffffff",
|
|
20
|
-
outlineWidth: 20,
|
|
21
|
-
outlineOpacity: 0.5,
|
|
22
|
-
textOutline: false,
|
|
23
|
-
textOutlineColor: "#000000",
|
|
24
|
-
textOutlineOpacity: 0.6,
|
|
25
|
-
textOutlineWidth: 2,
|
|
26
|
-
textBackgroundColor: "",
|
|
27
|
-
textBackgroundOpacity: 0.5,
|
|
28
|
-
scaleByDistance: true,
|
|
29
|
-
distanceDisplayCondition: false,
|
|
30
|
-
distanceDisplayCondition_far: Number.MAX_VALUE,
|
|
31
|
-
distanceDisplayCondition_near: 0,
|
|
32
|
-
data: null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
class mars3d_class extends mars3d_entity {
|
|
36
|
-
type = 'point'
|
|
37
|
-
id = null
|
|
38
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
39
|
-
config = null
|
|
40
|
-
graphic = null
|
|
41
|
-
|
|
42
|
-
constructor(option) {
|
|
43
|
-
super()
|
|
44
|
-
this.id = option.id
|
|
45
|
-
deepMerge(this.option, option)
|
|
46
|
-
this.config = this.formatConfig(this.option)
|
|
47
|
-
this.graphic = new mars3d.graphic.PointEntity(this.config)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
formatConfig(option) {
|
|
51
|
-
return {
|
|
52
|
-
id: option.id,
|
|
53
|
-
position: option.position,
|
|
54
|
-
style: {
|
|
55
|
-
color: option.color,
|
|
56
|
-
opacity: option.opacity,
|
|
57
|
-
pixelSize: option.size,
|
|
58
|
-
outline: option.outline,
|
|
59
|
-
outlineColor: option.outlineColor,
|
|
60
|
-
outlineWidth: option.outlineWidth,
|
|
61
|
-
outlineOpacity: option.outlineOpacity,
|
|
62
|
-
clampToGround: !option.position[2],
|
|
63
|
-
scaleByDistance: option.scaleByDistance,
|
|
64
|
-
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
65
|
-
distanceDisplayCondition_far: option.distanceDisplayCondition_far,
|
|
66
|
-
distanceDisplayCondition_near: option.distanceDisplayCondition_near,
|
|
67
|
-
label: {
|
|
68
|
-
text: option.text,
|
|
69
|
-
font_size: option.fontSize,
|
|
70
|
-
color: option.fontColor,
|
|
71
|
-
opacity: option.fontOpacity,
|
|
72
|
-
outline: option.textOutline,
|
|
73
|
-
outlineColor: option.textOutlineColor,
|
|
74
|
-
outlineOpacity: option.textOutlineOpacity,
|
|
75
|
-
outlineWidth: option.textOutlineWidth,
|
|
76
|
-
background: !!option.textBackgroundColor,
|
|
77
|
-
backgroundColor: option.textBackgroundColor,
|
|
78
|
-
backgroundOpacity: option.textBackgroundOpacity,
|
|
79
|
-
pixelOffset: option.fontOffset,
|
|
80
|
-
scaleByDistance: option.fontScaleByDistance,
|
|
81
|
-
distanceDisplayCondition: option.fontDistanceDisplayCondition,
|
|
82
|
-
distanceDisplayCondition_far: option.fontDistanceDisplayCondition_far,
|
|
83
|
-
distanceDisplayCondition_near: option.fontDistanceDisplayCondition_near,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
attr: option.data
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
set(option) {
|
|
91
|
-
deepMerge(this.option, option)
|
|
92
|
-
this.config = this.formatConfig(this.option)
|
|
93
|
-
this.graphic.setOptions(this.config)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
class gaode_class extends gaode_entity {
|
|
99
|
-
|
|
100
|
-
id = null
|
|
101
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
102
|
-
config = null
|
|
103
|
-
graphic = null
|
|
104
|
-
|
|
105
|
-
constructor(option) {
|
|
106
|
-
super()
|
|
107
|
-
this.id = option.id
|
|
108
|
-
deepMerge(this.option, option)
|
|
109
|
-
this.config = this.formatConfig(this.option)
|
|
110
|
-
this.graphic = new AMap.CircleMarker(this.config)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
formatConfig(option) {
|
|
114
|
-
let amapPosition = wgs84ToGcj02Format(option.position)
|
|
115
|
-
return {
|
|
116
|
-
center: amapPosition,
|
|
117
|
-
radius: option.size / 2,
|
|
118
|
-
strokeColor: option.outlineColor,
|
|
119
|
-
strokeOpacity: option.outlineOpacity,
|
|
120
|
-
strokeWeight: option.outlineWidth,
|
|
121
|
-
fillColor: option.color,
|
|
122
|
-
fillOpacity: option.opacity,
|
|
123
|
-
extData: {
|
|
124
|
-
id: option.id,
|
|
125
|
-
data: option.data,
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
set(option) {
|
|
131
|
-
deepMerge(this.option, option)
|
|
132
|
-
this.config = this.formatConfig(this.option)
|
|
133
|
-
this.graphic.setOptions(this.config)
|
|
134
|
-
this.graphic.setCenter(this.config.center)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const fn = {
|
|
139
|
-
mars3d: mars3d_class,
|
|
140
|
-
gaode: gaode_class
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return fn[hnMap.mapType]
|
|
144
|
-
}
|
package/src/graphic/polygon.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {deepMerge, wgs84ToGcj02Format} from '../util.js'
|
|
2
|
-
import mars3d_entity from "../base/mars3d_entity.js";
|
|
3
|
-
import gaode_entity from "../base/gaode_entity.js";
|
|
4
|
-
|
|
5
|
-
export default (hnMap) => {
|
|
6
|
-
const defaultOption = {
|
|
7
|
-
id: "",
|
|
8
|
-
position: [],
|
|
9
|
-
color: "#ff0000",
|
|
10
|
-
opacity: 1,
|
|
11
|
-
outline: false,
|
|
12
|
-
outlineWidth: 2,
|
|
13
|
-
outlineColor: "#ffffff",
|
|
14
|
-
outlineOpacity: 1,
|
|
15
|
-
scaleByDistance: true,
|
|
16
|
-
distanceDisplayCondition: false,
|
|
17
|
-
distanceDisplayCondition_far: Number.MAX_VALUE,
|
|
18
|
-
distanceDisplayCondition_near: 0,
|
|
19
|
-
data: null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class mars3d_class extends mars3d_entity {
|
|
23
|
-
type = 'polygon'
|
|
24
|
-
id = null
|
|
25
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
26
|
-
config = null
|
|
27
|
-
graphic = null
|
|
28
|
-
|
|
29
|
-
constructor(option) {
|
|
30
|
-
super()
|
|
31
|
-
this.id = option.id
|
|
32
|
-
deepMerge(this.option, option)
|
|
33
|
-
this.config = this.formatConfig(this.option)
|
|
34
|
-
this.graphic = new mars3d.graphic.PolygonEntity(this.config)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
formatConfig(option) {
|
|
38
|
-
return {
|
|
39
|
-
id: option.id,
|
|
40
|
-
positions: option.position,
|
|
41
|
-
style: {
|
|
42
|
-
color: option.color,
|
|
43
|
-
opacity: option.opacity,
|
|
44
|
-
outline: option.outline,
|
|
45
|
-
outlineColor: option.outlineColor,
|
|
46
|
-
outlineWidth: option.outlineWidth,
|
|
47
|
-
outlineOpacity: option.outlineOpacity,
|
|
48
|
-
scaleByDistance: option.scaleByDistance,
|
|
49
|
-
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
50
|
-
distanceDisplayCondition_far: option.distanceDisplayCondition_far,
|
|
51
|
-
distanceDisplayCondition_near: option.distanceDisplayCondition_near,
|
|
52
|
-
clampToGround: option.position[0] && !option.position[0][2],
|
|
53
|
-
},
|
|
54
|
-
attr: option.data
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set(option) {
|
|
59
|
-
deepMerge(this.option, option)
|
|
60
|
-
this.config = this.formatConfig(this.option)
|
|
61
|
-
this.graphic.setOptions(this.config)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class gaode_class extends gaode_entity {
|
|
67
|
-
|
|
68
|
-
id = null
|
|
69
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
70
|
-
config = null
|
|
71
|
-
graphic = null
|
|
72
|
-
|
|
73
|
-
constructor(option) {
|
|
74
|
-
super()
|
|
75
|
-
this.id = option.id
|
|
76
|
-
deepMerge(this.option, option)
|
|
77
|
-
this.config = this.formatConfig(this.option)
|
|
78
|
-
this.graphic = new AMap.Polygon(this.config)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
formatConfig(option) {
|
|
82
|
-
const amapPosition = wgs84ToGcj02Format(option.position)
|
|
83
|
-
return {
|
|
84
|
-
path: amapPosition,
|
|
85
|
-
fillColor: option.color,
|
|
86
|
-
fillOpacity: option.opacity,
|
|
87
|
-
strokeColor: option.outlineColor,
|
|
88
|
-
strokeOpacity: option.outline ? option.outlineOpacity : 0,
|
|
89
|
-
strokeWeight: option.outline ? option.outlineWidth : 0,
|
|
90
|
-
extData: {
|
|
91
|
-
id: option.id,
|
|
92
|
-
data: option.data,
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
set(option) {
|
|
98
|
-
deepMerge(this.option, option)
|
|
99
|
-
this.config = this.formatConfig(this.option)
|
|
100
|
-
this.graphic.setOptions(this.config)
|
|
101
|
-
this.graphic.setPath(this.config.path)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const fn = {
|
|
106
|
-
mars3d: mars3d_class,
|
|
107
|
-
gaode: gaode_class
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return fn[hnMap.mapType]
|
|
111
|
-
}
|
package/src/graphic/rectangle.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {deepMerge, wgs84ToGcj02Format} from '../util.js'
|
|
2
|
-
import mars3d_entity from "../base/mars3d_entity.js";
|
|
3
|
-
import gaode_entity from "../base/gaode_entity.js";
|
|
4
|
-
|
|
5
|
-
export default (hnMap) => {
|
|
6
|
-
|
|
7
|
-
const defaultOption = {
|
|
8
|
-
id: "",
|
|
9
|
-
position: [],
|
|
10
|
-
color: "#ff0000",
|
|
11
|
-
opacity: 1,
|
|
12
|
-
outline: false,
|
|
13
|
-
outlineWidth: 2,
|
|
14
|
-
outlineColor: "#ffffff",
|
|
15
|
-
outlineOpacity: 1,
|
|
16
|
-
scaleByDistance: true,
|
|
17
|
-
distanceDisplayCondition: false,
|
|
18
|
-
distanceDisplayCondition_far: Number.MAX_VALUE,
|
|
19
|
-
distanceDisplayCondition_near: 0,
|
|
20
|
-
data: null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class mars3d_class extends mars3d_entity {
|
|
24
|
-
type = 'retangle'
|
|
25
|
-
id = null
|
|
26
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
27
|
-
config = null
|
|
28
|
-
graphic = null
|
|
29
|
-
|
|
30
|
-
constructor(option) {
|
|
31
|
-
super()
|
|
32
|
-
this.id = option.id
|
|
33
|
-
deepMerge(this.option, option)
|
|
34
|
-
this.config = this.formatConfig(this.option)
|
|
35
|
-
this.graphic = new mars3d.graphic.RectangleEntity(this.config)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
formatConfig(option) {
|
|
39
|
-
return {
|
|
40
|
-
id: option.id,
|
|
41
|
-
positions: option.position,
|
|
42
|
-
style: {
|
|
43
|
-
color: option.color,
|
|
44
|
-
opacity: option.opacity,
|
|
45
|
-
outline: option.outline,
|
|
46
|
-
outlineColor: option.outlineColor,
|
|
47
|
-
outlineWidth: option.outlineWidth,
|
|
48
|
-
outlineOpacity: option.outlineOpacity,
|
|
49
|
-
scaleByDistance: option.scaleByDistance,
|
|
50
|
-
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
51
|
-
distanceDisplayCondition_far: option.distanceDisplayCondition_far,
|
|
52
|
-
distanceDisplayCondition_near: option.distanceDisplayCondition_near,
|
|
53
|
-
clampToGround: !option.position[0][2],
|
|
54
|
-
},
|
|
55
|
-
attr: option.data
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
set(option) {
|
|
60
|
-
deepMerge(this.option, option)
|
|
61
|
-
this.config = this.formatConfig(this.option)
|
|
62
|
-
this.graphic.setOptions(this.config)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
class gaode_class extends gaode_entity {
|
|
68
|
-
|
|
69
|
-
id = null
|
|
70
|
-
option = JSON.parse(JSON.stringify(defaultOption))
|
|
71
|
-
config = null
|
|
72
|
-
graphic = null
|
|
73
|
-
|
|
74
|
-
constructor(option) {
|
|
75
|
-
super()
|
|
76
|
-
this.id = option.id
|
|
77
|
-
deepMerge(this.option, option)
|
|
78
|
-
this.config = this.formatConfig(this.option)
|
|
79
|
-
this.graphic = new AMap.Rectangle(this.config)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
formatConfig(option) {
|
|
83
|
-
const amapPosition = wgs84ToGcj02Format(option.position)
|
|
84
|
-
const southWest = new AMap.LngLat(amapPosition[0][0], amapPosition[0][1])
|
|
85
|
-
const northEast = new AMap.LngLat(amapPosition[1][0], amapPosition[1][1])
|
|
86
|
-
const bounds = new AMap.Bounds(southWest, northEast)
|
|
87
|
-
return {
|
|
88
|
-
bounds: bounds,
|
|
89
|
-
fillColor: option.color,
|
|
90
|
-
fillOpacity: option.opacity,
|
|
91
|
-
strokeColor: option.outlineColor,
|
|
92
|
-
strokeOpacity: option.outline ? option.outlineOpacity : 0,
|
|
93
|
-
strokeWeight: option.outline ? option.outlineWidth : 0,
|
|
94
|
-
extData: {
|
|
95
|
-
id: option.id,
|
|
96
|
-
data: option.data,
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
set(option) {
|
|
102
|
-
deepMerge(this.option, option)
|
|
103
|
-
this.config = this.formatConfig(this.option)
|
|
104
|
-
this.graphic.setOptions(this.config)
|
|
105
|
-
this.graphic.setBounds(this.config.bounds)
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const fn = {
|
|
111
|
-
mars3d: mars3d_class,
|
|
112
|
-
gaode: gaode_class
|
|
113
|
-
}
|
|
114
|
-
return fn[hnMap.mapType]
|
|
115
|
-
}
|