hn-map 1.1.4 → 1.1.6
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/dist/index.js +150 -66
- package/package.json +1 -1
- package/src/base/siji_entity.ts +3 -2
- package/src/graphic/circle.ts +15 -4
- package/src/graphic/divPoint.ts +12 -3
- package/src/graphic/imagePoint.ts +25 -11
- package/src/graphic/label.ts +29 -16
- package/src/graphic/line.ts +35 -6
- package/src/graphic/numPoint.ts +9 -3
- package/src/graphic/point.ts +39 -12
- package/src/graphic/polygon.ts +16 -5
- package/src/graphic/rectangle.ts +10 -4
- package/src/layer/layer.ts +19 -2
- package/src/map.ts +29 -6
- package/src/util.ts +153 -135
- package/src/other/geocodingTask.ts +0 -120
package/src/graphic/label.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepMerge,
|
|
3
|
+
getLevelMiddleHeight,
|
|
4
|
+
wgs84ToGcj02Format,
|
|
5
|
+
convertPosition,
|
|
6
|
+
} from "../util";
|
|
2
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
3
8
|
import gaode_entity from "../base/gaode_entity";
|
|
4
9
|
import siji_entity from "../base/siji_entity";
|
|
@@ -54,8 +59,12 @@ export default (hnMap: any) => {
|
|
|
54
59
|
option.position[1],
|
|
55
60
|
option.position[2] || 0
|
|
56
61
|
);
|
|
57
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
58
|
-
|
|
62
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
63
|
+
option.distanceDisplayCondition_far
|
|
64
|
+
);
|
|
65
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
66
|
+
option.distanceDisplayCondition_near
|
|
67
|
+
);
|
|
59
68
|
return {
|
|
60
69
|
id: option.id,
|
|
61
70
|
position: position,
|
|
@@ -69,7 +78,7 @@ export default (hnMap: any) => {
|
|
|
69
78
|
outlineColor: option.outlineColor,
|
|
70
79
|
outlineWidth: option.outlineWidth,
|
|
71
80
|
outlineOpacity: option.outlineOpacity,
|
|
72
|
-
pixelOffset: option.offset,
|
|
81
|
+
pixelOffset: convertPosition(option.offset),
|
|
73
82
|
scaleByDistance: option.scaleByDistance,
|
|
74
83
|
clampToGround: !option.position[2],
|
|
75
84
|
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
@@ -199,14 +208,21 @@ export default (hnMap: any) => {
|
|
|
199
208
|
"text-field": "{name}",
|
|
200
209
|
"text-size": Number(option.fontSize),
|
|
201
210
|
"text-anchor": "top", // 顶部对齐
|
|
202
|
-
"text-offset": this.pixelOffsetToTextOffset(
|
|
211
|
+
"text-offset": this.pixelOffsetToTextOffset(
|
|
212
|
+
option.offset,
|
|
213
|
+
option.fontSize
|
|
214
|
+
),
|
|
203
215
|
"text-max-width": 8,
|
|
204
216
|
"text-font": ["Microsoft YaHei Regular"],
|
|
205
217
|
}, // 文本样式
|
|
206
218
|
paint: {
|
|
207
219
|
"text-color": option.color,
|
|
208
|
-
"text-halo-color": option.
|
|
209
|
-
|
|
220
|
+
"text-halo-color": option.outline
|
|
221
|
+
? option.outlineColor
|
|
222
|
+
: "transparent", // 文字外边线颜色
|
|
223
|
+
"text-halo-width": option.outline ? Number(option.outlineWidth) : 0, // 文字外边线宽度
|
|
224
|
+
"text-opacity": Number(option.opacity),
|
|
225
|
+
// "text-halo-opacity": option.outline ? option.outlineOpacity : 1,
|
|
210
226
|
}, // 填充样式
|
|
211
227
|
};
|
|
212
228
|
if (option.type === "label") {
|
|
@@ -214,7 +230,7 @@ export default (hnMap: any) => {
|
|
|
214
230
|
type: "Feature",
|
|
215
231
|
geometry: {
|
|
216
232
|
type: "Point",
|
|
217
|
-
coordinates: option.position
|
|
233
|
+
coordinates: convertPosition(option.position),
|
|
218
234
|
},
|
|
219
235
|
properties: {
|
|
220
236
|
name: option.text,
|
|
@@ -227,7 +243,7 @@ export default (hnMap: any) => {
|
|
|
227
243
|
properties: { name: option.text },
|
|
228
244
|
geometry: {
|
|
229
245
|
type: "Point",
|
|
230
|
-
coordinates:
|
|
246
|
+
coordinates: convertPosition(option.position),
|
|
231
247
|
},
|
|
232
248
|
});
|
|
233
249
|
});
|
|
@@ -242,11 +258,8 @@ export default (hnMap: any) => {
|
|
|
242
258
|
* @param {number} textSizePx - 字体大小(px)
|
|
243
259
|
* @returns {Array<number>} text-offset in ems
|
|
244
260
|
*/
|
|
245
|
-
pixelOffsetToTextOffset(pixelOffset:any, textSizePx:any): Array<number> {
|
|
246
|
-
return [
|
|
247
|
-
pixelOffset[0] / textSizePx,
|
|
248
|
-
pixelOffset[1] / textSizePx
|
|
249
|
-
];
|
|
261
|
+
pixelOffsetToTextOffset(pixelOffset: any, textSizePx: any): Array<number> {
|
|
262
|
+
return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
|
|
250
263
|
}
|
|
251
264
|
|
|
252
265
|
set(option: any) {
|
|
@@ -262,7 +275,7 @@ export default (hnMap: any) => {
|
|
|
262
275
|
properties: { name: this.option.text },
|
|
263
276
|
geometry: {
|
|
264
277
|
type: "Point",
|
|
265
|
-
coordinates:
|
|
278
|
+
coordinates: convertPosition(option.position),
|
|
266
279
|
},
|
|
267
280
|
},
|
|
268
281
|
],
|
|
@@ -294,7 +307,7 @@ export default (hnMap: any) => {
|
|
|
294
307
|
hnMap.map.map.setPaintProperty(
|
|
295
308
|
this.config.id,
|
|
296
309
|
key2,
|
|
297
|
-
key2 == "text-halo-width"
|
|
310
|
+
key2 == "text-halo-width" || key2 == "text-opacity"
|
|
298
311
|
? Number(this.config[key][key2])
|
|
299
312
|
: this.config[key][key2]
|
|
300
313
|
);
|
package/src/graphic/line.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepMerge,
|
|
3
|
+
getLevelMiddleHeight,
|
|
4
|
+
wgs84ToGcj02Format,
|
|
5
|
+
convertPosition,
|
|
6
|
+
} from "../util";
|
|
2
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
3
8
|
import gaode_entity from "../base/gaode_entity";
|
|
4
9
|
import siji_entity from "../base/siji_entity";
|
|
@@ -50,8 +55,12 @@ export default (hnMap: any) => {
|
|
|
50
55
|
|
|
51
56
|
formatConfig(option: any) {
|
|
52
57
|
let config: any = {};
|
|
53
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
54
|
-
|
|
58
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
59
|
+
option.distanceDisplayCondition_far
|
|
60
|
+
);
|
|
61
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
62
|
+
option.distanceDisplayCondition_near
|
|
63
|
+
);
|
|
55
64
|
if (option.combine) {
|
|
56
65
|
config = {
|
|
57
66
|
id: option.id,
|
|
@@ -233,7 +242,7 @@ export default (hnMap: any) => {
|
|
|
233
242
|
type: "Feature",
|
|
234
243
|
geometry: {
|
|
235
244
|
type: "LineString",
|
|
236
|
-
coordinates: option.position,
|
|
245
|
+
coordinates: convertPosition(option.position),
|
|
237
246
|
},
|
|
238
247
|
properties: {
|
|
239
248
|
id: option.id,
|
|
@@ -244,13 +253,14 @@ export default (hnMap: any) => {
|
|
|
244
253
|
},
|
|
245
254
|
},
|
|
246
255
|
layout: {
|
|
247
|
-
"line-cap": "round",
|
|
248
|
-
"line-join": "round",
|
|
256
|
+
"line-cap": "round", // 线端点样式
|
|
257
|
+
"line-join": "round", // 线连接样式
|
|
249
258
|
},
|
|
250
259
|
paint: {
|
|
251
260
|
"line-color": option.type == "dash" ? option.dashColor : option.color,
|
|
252
261
|
"line-width": Number(option.width),
|
|
253
262
|
"line-opacity": Number(option.opacity),
|
|
263
|
+
// "line-gap-width": 4,
|
|
254
264
|
},
|
|
255
265
|
};
|
|
256
266
|
let isShow: boolean = true;
|
|
@@ -279,6 +289,25 @@ export default (hnMap: any) => {
|
|
|
279
289
|
set(option: any) {
|
|
280
290
|
deepMerge(this.option, option);
|
|
281
291
|
this.config = this.formatConfig(this.option);
|
|
292
|
+
|
|
293
|
+
let mySource = hnMap.map.map.getSource(this.config.id);
|
|
294
|
+
mySource.setData({
|
|
295
|
+
type: "FeatureCollection",
|
|
296
|
+
features: [
|
|
297
|
+
{
|
|
298
|
+
type: "Feature",
|
|
299
|
+
properties: {
|
|
300
|
+
id: option.id,
|
|
301
|
+
...option.data,
|
|
302
|
+
},
|
|
303
|
+
geometry: {
|
|
304
|
+
type: "LineString",
|
|
305
|
+
coordinates: convertPosition(this.option.position),
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
});
|
|
310
|
+
|
|
282
311
|
for (let key in this.config) {
|
|
283
312
|
if (this.config.hasOwnProperty(key)) {
|
|
284
313
|
if (key == "paint") {
|
package/src/graphic/numPoint.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepMerge,
|
|
3
|
+
getLevelMiddleHeight,
|
|
4
|
+
wgs84ToGcj02Format,
|
|
5
|
+
convertPosition,
|
|
6
|
+
} from "../util";
|
|
2
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
3
8
|
import gaode_entity from "../base/gaode_entity";
|
|
4
9
|
import siji_entity from "../base/siji_entity";
|
|
@@ -144,7 +149,7 @@ export default (hnMap: any) => {
|
|
|
144
149
|
type: "Feature",
|
|
145
150
|
geometry: {
|
|
146
151
|
type: "Point",
|
|
147
|
-
coordinates: option.position
|
|
152
|
+
coordinates: convertPosition(option.position),
|
|
148
153
|
},
|
|
149
154
|
properties: {
|
|
150
155
|
name: option.text,
|
|
@@ -153,6 +158,7 @@ export default (hnMap: any) => {
|
|
|
153
158
|
],
|
|
154
159
|
},
|
|
155
160
|
},
|
|
161
|
+
|
|
156
162
|
paint: {
|
|
157
163
|
"circle-opacity": Number(option.opacity),
|
|
158
164
|
"circle-radius": Number(option.size),
|
|
@@ -177,7 +183,7 @@ export default (hnMap: any) => {
|
|
|
177
183
|
type: "Feature",
|
|
178
184
|
geometry: {
|
|
179
185
|
type: "Point",
|
|
180
|
-
coordinates: option.position
|
|
186
|
+
coordinates: convertPosition(option.position),
|
|
181
187
|
},
|
|
182
188
|
properties: {
|
|
183
189
|
name: option.num,
|
package/src/graphic/point.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepMerge,
|
|
3
|
+
getLevelMiddleHeight,
|
|
4
|
+
wgs84ToGcj02Format,
|
|
5
|
+
convertPosition,
|
|
6
|
+
} from "../util";
|
|
2
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
3
8
|
import gaode_entity from "../base/gaode_entity";
|
|
4
9
|
import siji_entity from "../base/siji_entity";
|
|
@@ -48,8 +53,12 @@ export default (hnMap: any) => {
|
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
formatConfig(option: any) {
|
|
51
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
52
|
-
|
|
56
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
57
|
+
option.distanceDisplayCondition_far
|
|
58
|
+
);
|
|
59
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
60
|
+
option.distanceDisplayCondition_near
|
|
61
|
+
);
|
|
53
62
|
return {
|
|
54
63
|
id: option.id,
|
|
55
64
|
position: option.position,
|
|
@@ -162,29 +171,43 @@ export default (hnMap: any) => {
|
|
|
162
171
|
type: "Feature",
|
|
163
172
|
geometry: {
|
|
164
173
|
type: "Point",
|
|
165
|
-
coordinates: option.position
|
|
174
|
+
coordinates: convertPosition(option.position),
|
|
166
175
|
},
|
|
167
176
|
properties: {
|
|
168
|
-
|
|
169
|
-
...option.data,
|
|
177
|
+
name: option.text,
|
|
170
178
|
},
|
|
171
179
|
},
|
|
172
180
|
],
|
|
173
181
|
},
|
|
174
182
|
},
|
|
183
|
+
|
|
175
184
|
paint: {
|
|
176
185
|
"circle-opacity": Number(option.opacity),
|
|
177
186
|
"circle-radius": Number(option.size),
|
|
178
187
|
"circle-color": option.color,
|
|
179
|
-
"circle-stroke-color": option.
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
"circle-stroke-color": option.outline
|
|
189
|
+
? option.outlineColor
|
|
190
|
+
: "transparent",
|
|
191
|
+
"circle-stroke-width": option.outline
|
|
192
|
+
? Number(option.outlineWidth)
|
|
193
|
+
: 0,
|
|
194
|
+
"circle-stroke-opacity": option.outline
|
|
195
|
+
? Number(option.outlineOpacity)
|
|
196
|
+
: 1, // 边框样式
|
|
182
197
|
}, // 填充样式
|
|
183
198
|
};
|
|
184
199
|
|
|
185
200
|
return config;
|
|
186
201
|
}
|
|
187
|
-
|
|
202
|
+
/**
|
|
203
|
+
* 将 pixelOffset 转换为 text-offset (ems)
|
|
204
|
+
* @param {Array<number>} pixelOffset - [x, y] 像素偏移
|
|
205
|
+
* @param {number} textSizePx - 字体大小(px)
|
|
206
|
+
* @returns {Array<number>} text-offset in ems
|
|
207
|
+
*/
|
|
208
|
+
pixelOffsetToTextOffset(pixelOffset: any, textSizePx: any): Array<number> {
|
|
209
|
+
return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
|
|
210
|
+
}
|
|
188
211
|
set(option: any) {
|
|
189
212
|
console.log("=====set point====", option);
|
|
190
213
|
deepMerge(this.option, option);
|
|
@@ -198,7 +221,7 @@ export default (hnMap: any) => {
|
|
|
198
221
|
properties: { name: this.option.text },
|
|
199
222
|
geometry: {
|
|
200
223
|
type: "Point",
|
|
201
|
-
coordinates: this.option.position
|
|
224
|
+
coordinates: convertPosition(this.option.position),
|
|
202
225
|
},
|
|
203
226
|
},
|
|
204
227
|
],
|
|
@@ -212,7 +235,11 @@ export default (hnMap: any) => {
|
|
|
212
235
|
hnMap.map.map.setPaintProperty(
|
|
213
236
|
this.config.id,
|
|
214
237
|
key2,
|
|
215
|
-
key2 == "circle-opacity" ||
|
|
238
|
+
key2 == "circle-opacity" ||
|
|
239
|
+
key2 == "circle-radius" ||
|
|
240
|
+
key2 == "circle-stroke-opacity" ||
|
|
241
|
+
key2 == "circle-stroke-width" ||
|
|
242
|
+
key2 == "text-opacity"
|
|
216
243
|
? Number(this.config[key][key2])
|
|
217
244
|
: this.config[key][key2]
|
|
218
245
|
);
|
package/src/graphic/polygon.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepMerge,
|
|
3
|
+
getLevelMiddleHeight,
|
|
4
|
+
wgs84ToGcj02Format,
|
|
5
|
+
convertPosition,
|
|
6
|
+
} from "../util";
|
|
2
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
3
8
|
import gaode_entity from "../base/gaode_entity";
|
|
4
9
|
import siji_entity from "../base/siji_entity";
|
|
@@ -35,8 +40,12 @@ export default (hnMap: any) => {
|
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
formatConfig(option: any) {
|
|
38
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
39
|
-
|
|
43
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
44
|
+
option.distanceDisplayCondition_far
|
|
45
|
+
);
|
|
46
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
47
|
+
option.distanceDisplayCondition_near
|
|
48
|
+
);
|
|
40
49
|
return {
|
|
41
50
|
id: option.id,
|
|
42
51
|
positions: option.position,
|
|
@@ -129,7 +138,7 @@ export default (hnMap: any) => {
|
|
|
129
138
|
type: "Feature",
|
|
130
139
|
geometry: {
|
|
131
140
|
type: "Polygon",
|
|
132
|
-
coordinates: option.position,
|
|
141
|
+
coordinates: convertPosition(option.position),
|
|
133
142
|
},
|
|
134
143
|
},
|
|
135
144
|
],
|
|
@@ -139,6 +148,8 @@ export default (hnMap: any) => {
|
|
|
139
148
|
paint: {
|
|
140
149
|
"fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
141
150
|
"fill-opacity": Number(option.opacity),
|
|
151
|
+
"fill-antialias": true,
|
|
152
|
+
"fill-outline-color": option.outlineColor,
|
|
142
153
|
},
|
|
143
154
|
};
|
|
144
155
|
return config;
|
|
@@ -155,7 +166,7 @@ export default (hnMap: any) => {
|
|
|
155
166
|
type: "Feature",
|
|
156
167
|
geometry: {
|
|
157
168
|
type: "Polygon",
|
|
158
|
-
coordinates:
|
|
169
|
+
coordinates: convertPosition(option.position), //三层数组[[[0,0],[0,0]]]
|
|
159
170
|
},
|
|
160
171
|
},
|
|
161
172
|
],
|
package/src/graphic/rectangle.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deepMerge,
|
|
3
3
|
wgs84ToGcj02Format,
|
|
4
|
-
createRectangleCoordinates,
|
|
4
|
+
createRectangleCoordinates,
|
|
5
|
+
getLevelMiddleHeight,
|
|
5
6
|
} from "../util";
|
|
6
7
|
import mars3d_entity from "../base/mars3d_entity";
|
|
7
8
|
import gaode_entity from "../base/gaode_entity";
|
|
@@ -39,8 +40,12 @@ export default (hnMap: any) => {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
formatConfig(option: any) {
|
|
42
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
43
|
-
|
|
43
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
44
|
+
option.distanceDisplayCondition_far
|
|
45
|
+
);
|
|
46
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
47
|
+
option.distanceDisplayCondition_near
|
|
48
|
+
);
|
|
44
49
|
return {
|
|
45
50
|
id: option.id,
|
|
46
51
|
positions: option.position,
|
|
@@ -127,7 +132,6 @@ export default (hnMap: any) => {
|
|
|
127
132
|
option.position[0],
|
|
128
133
|
option.position[1]
|
|
129
134
|
);
|
|
130
|
-
console.log([RectanglePosition], "========RectanglePosition=======");
|
|
131
135
|
let config = {
|
|
132
136
|
id: option.id,
|
|
133
137
|
type: "fill",
|
|
@@ -150,6 +154,8 @@ export default (hnMap: any) => {
|
|
|
150
154
|
paint: {
|
|
151
155
|
"fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
152
156
|
"fill-opacity": Number(option.opacity),
|
|
157
|
+
"fill-antialias": true,
|
|
158
|
+
"fill-outline-color": option.outlineColor,
|
|
153
159
|
},
|
|
154
160
|
};
|
|
155
161
|
return config;
|
package/src/layer/layer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepMerge } from "../util";
|
|
1
|
+
import { deepMerge, convertPosition } from "../util";
|
|
2
2
|
|
|
3
3
|
export default (hnMap: any) => {
|
|
4
4
|
const defaultOption = {};
|
|
@@ -41,7 +41,12 @@ export default (hnMap: any) => {
|
|
|
41
41
|
|
|
42
42
|
removeEntity(entityParam: any) {
|
|
43
43
|
const entity = this.getEntity(entityParam);
|
|
44
|
+
console.log("removeEntity", entity);
|
|
44
45
|
if (entity) {
|
|
46
|
+
this.children = this.children.filter((v: any) => {
|
|
47
|
+
return v.id !== entity.id;
|
|
48
|
+
});
|
|
49
|
+
console.log("layerEntity", this.layerEntity);
|
|
45
50
|
this.layerEntity.removeGraphic(entity.graphic);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -276,6 +281,7 @@ export default (hnMap: any) => {
|
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
updateEntity(entity: any, viewPos: any) {
|
|
284
|
+
console.log("updateEntity", entity, viewPos);
|
|
279
285
|
const isUpdateEntity =
|
|
280
286
|
hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) &&
|
|
281
287
|
hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
|
|
@@ -335,11 +341,17 @@ export default (hnMap: any) => {
|
|
|
335
341
|
|
|
336
342
|
addLevelEntity(entity: any) {
|
|
337
343
|
if (entity.type == "imagePoint") {
|
|
344
|
+
console.log("addLevelEntity=====", entity);
|
|
338
345
|
hnMap.map.map.loadImage(
|
|
339
346
|
entity.option.image,
|
|
340
347
|
function (error: any, image: any) {
|
|
341
348
|
entity.config.layout["icon-size"] =
|
|
342
349
|
entity.option.width / image.width;
|
|
350
|
+
entity.config.layout["icon-offset"] = [
|
|
351
|
+
entity.option.offset[0] / entity.config.layout["icon-size"],
|
|
352
|
+
entity.option.offset[1] / entity.config.layout["icon-size"],
|
|
353
|
+
];
|
|
354
|
+
|
|
343
355
|
hnMap.map.map.addImage(entity.id + "_image", image);
|
|
344
356
|
hnMap.map.map.addLayer(entity.config);
|
|
345
357
|
}
|
|
@@ -353,7 +365,7 @@ export default (hnMap: any) => {
|
|
|
353
365
|
let featureArr = {
|
|
354
366
|
type: "Feature",
|
|
355
367
|
properties: {
|
|
356
|
-
centerPoint: entity.option.position,
|
|
368
|
+
centerPoint: convertPosition(entity.option.position),
|
|
357
369
|
radius: entity.option.radius,
|
|
358
370
|
},
|
|
359
371
|
geometry: {
|
|
@@ -394,6 +406,10 @@ export default (hnMap: any) => {
|
|
|
394
406
|
hnMap.map.map.removeLayer(entity.config_routeplay.id);
|
|
395
407
|
hnMap.map.map.removeSource(entity.config_routeplay.id);
|
|
396
408
|
entity.imgMarker.remove();
|
|
409
|
+
} else if (entity.type == "imagePoint") {
|
|
410
|
+
hnMap.map.map.removeImage(entity.id + "_image");
|
|
411
|
+
hnMap.map.map.removeLayer(entity.id);
|
|
412
|
+
hnMap.map.map.removeSource(entity.id);
|
|
397
413
|
} else {
|
|
398
414
|
hnMap.map.map.removeLayer(entity.id);
|
|
399
415
|
hnMap.map.map.removeSource(entity.id);
|
|
@@ -405,6 +421,7 @@ export default (hnMap: any) => {
|
|
|
405
421
|
moveEntity(layerIds: Array<string>) {
|
|
406
422
|
// 数组转字符串
|
|
407
423
|
let s = layerIds.join(",");
|
|
424
|
+
console.log("s===", s);
|
|
408
425
|
hnMap.map.map.moveLayer(s);
|
|
409
426
|
}
|
|
410
427
|
clearEntity() {
|
package/src/map.ts
CHANGED
|
@@ -277,11 +277,6 @@ export default (hnMap: any) => {
|
|
|
277
277
|
this.map.on("moveend", (e: any) => this.updateMapParams(e)); // 地图移动完成
|
|
278
278
|
this.map.on("zoomend", (e: any) => this.updateMapParams(e)); // 地图缩放完成
|
|
279
279
|
this.map.on("pitchend", (e: any) => this.updateMapParams(e)); // 地图俯仰角度完成
|
|
280
|
-
this.map.on("load", (e: any) => {
|
|
281
|
-
// 路况展示
|
|
282
|
-
let roadNetLayer = new SGMap.RoadNetLayer({ map: this.map });
|
|
283
|
-
roadNetLayer.render();
|
|
284
|
-
});
|
|
285
280
|
}
|
|
286
281
|
|
|
287
282
|
static async create(id: string, option: any) {
|
|
@@ -290,6 +285,34 @@ export default (hnMap: any) => {
|
|
|
290
285
|
// 返回一个 Promise,等待地图的 'load' 事件
|
|
291
286
|
await new Promise((resolve) => {
|
|
292
287
|
instance.map.on("load", (e: any) => {
|
|
288
|
+
// 路况展示
|
|
289
|
+
let roadNetLayer = new SGMap.RoadNetLayer({ map: instance.map });
|
|
290
|
+
roadNetLayer.render();
|
|
291
|
+
//添加天空图层
|
|
292
|
+
instance.map.addLayer({
|
|
293
|
+
"id": "sky",
|
|
294
|
+
"type": "sky",
|
|
295
|
+
"paint": {
|
|
296
|
+
"sky-type": "atmosphere",
|
|
297
|
+
"sky-atmosphere-sun": [
|
|
298
|
+
0,
|
|
299
|
+
0
|
|
300
|
+
],
|
|
301
|
+
"sky-atmosphere-sun-intensity": 15
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
// 加载地形(需要v3.1.0,且需要新的key和secret)
|
|
306
|
+
// !instance.map.getSource('terrain') && instance.map.addSource('terrain',{
|
|
307
|
+
// type:'raster-dem',
|
|
308
|
+
// url:"aegis://aegis.Terrain3D",//地形高程数据源名称
|
|
309
|
+
// tileSize:512,
|
|
310
|
+
//
|
|
311
|
+
// })
|
|
312
|
+
// instance.map.setTerrain({
|
|
313
|
+
// source:'terrain',
|
|
314
|
+
// exaggeration:1,//地形夸张比例
|
|
315
|
+
// })
|
|
293
316
|
resolve(e);
|
|
294
317
|
});
|
|
295
318
|
});
|
|
@@ -362,7 +385,7 @@ export default (hnMap: any) => {
|
|
|
362
385
|
callback({
|
|
363
386
|
lng: event.lngLat.lng,
|
|
364
387
|
lat: event.lngLat.lat,
|
|
365
|
-
alt: event.lngLat.alt||0,
|
|
388
|
+
alt: event.lngLat.alt || 0,
|
|
366
389
|
});
|
|
367
390
|
};
|
|
368
391
|
break;
|