hn-map 1.1.5 → 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 +117 -58
- package/package.json +1 -1
- package/src/base/siji_entity.ts +2 -1
- 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 +14 -2
- package/src/util.ts +16 -7
package/dist/index.js
CHANGED
|
@@ -442,6 +442,25 @@
|
|
|
442
442
|
// 限制在 1~18
|
|
443
443
|
return Math.max(1, Math.min(18, level));
|
|
444
444
|
}
|
|
445
|
+
// 將坐标数组中的元素字符串类型统一处理为number类型
|
|
446
|
+
function convertPosition(position) {
|
|
447
|
+
return position.map(function (item) {
|
|
448
|
+
if (Array.isArray(item)) {
|
|
449
|
+
return item.map(function (innerItem) {
|
|
450
|
+
if (Array.isArray(innerItem)) {
|
|
451
|
+
// 第三层,将每个字符串转数字
|
|
452
|
+
return innerItem.map(function (str) {
|
|
453
|
+
return Number(str);
|
|
454
|
+
});
|
|
455
|
+
} else {
|
|
456
|
+
return Number(innerItem);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
} else {
|
|
460
|
+
return Number(item);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
445
464
|
|
|
446
465
|
var map = (function (hnMap) {
|
|
447
466
|
var defaultOption = {
|
|
@@ -1029,7 +1048,12 @@
|
|
|
1029
1048
|
key: "removeEntity",
|
|
1030
1049
|
value: function removeEntity(entityParam) {
|
|
1031
1050
|
var entity = this.getEntity(entityParam);
|
|
1051
|
+
console.log("removeEntity", entity);
|
|
1032
1052
|
if (entity) {
|
|
1053
|
+
this.children = this.children.filter(function (v) {
|
|
1054
|
+
return v.id !== entity.id;
|
|
1055
|
+
});
|
|
1056
|
+
console.log("layerEntity", this.layerEntity);
|
|
1033
1057
|
this.layerEntity.removeGraphic(entity.graphic);
|
|
1034
1058
|
}
|
|
1035
1059
|
}
|
|
@@ -1303,6 +1327,7 @@
|
|
|
1303
1327
|
}, {
|
|
1304
1328
|
key: "updateEntity",
|
|
1305
1329
|
value: function updateEntity(entity, viewPos) {
|
|
1330
|
+
console.log("updateEntity", entity, viewPos);
|
|
1306
1331
|
var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
|
|
1307
1332
|
if (isUpdateEntity) {
|
|
1308
1333
|
if (!entity.show && this.isIncludesLabel(entity.option.position, viewPos)) {
|
|
@@ -1357,8 +1382,10 @@
|
|
|
1357
1382
|
key: "addLevelEntity",
|
|
1358
1383
|
value: function addLevelEntity(entity) {
|
|
1359
1384
|
if (entity.type == "imagePoint") {
|
|
1385
|
+
console.log("addLevelEntity=====", entity);
|
|
1360
1386
|
hnMap.map.map.loadImage(entity.option.image, function (error, image) {
|
|
1361
1387
|
entity.config.layout["icon-size"] = entity.option.width / image.width;
|
|
1388
|
+
entity.config.layout["icon-offset"] = [entity.option.offset[0] / entity.config.layout["icon-size"], entity.option.offset[1] / entity.config.layout["icon-size"]];
|
|
1362
1389
|
hnMap.map.map.addImage(entity.id + "_image", image);
|
|
1363
1390
|
hnMap.map.map.addLayer(entity.config);
|
|
1364
1391
|
});
|
|
@@ -1371,7 +1398,7 @@
|
|
|
1371
1398
|
var featureArr = {
|
|
1372
1399
|
type: "Feature",
|
|
1373
1400
|
properties: {
|
|
1374
|
-
centerPoint: entity.option.position,
|
|
1401
|
+
centerPoint: convertPosition(entity.option.position),
|
|
1375
1402
|
radius: entity.option.radius
|
|
1376
1403
|
},
|
|
1377
1404
|
geometry: {
|
|
@@ -1749,10 +1776,12 @@
|
|
|
1749
1776
|
if (this.option.center) {
|
|
1750
1777
|
center = this.option.center;
|
|
1751
1778
|
} else {
|
|
1752
|
-
if (this.type == "line" || this.type == "dash" || this.type == "flicker" || this.type == "flow" || this.type == "arrow" || this.type == "mapLabel" || this.type == "
|
|
1779
|
+
if (this.type == "line" || this.type == "dash" || this.type == "flicker" || this.type == "flow" || this.type == "arrow" || this.type == "mapLabel" || this.type == "rectangle") {
|
|
1753
1780
|
center = this.option.position[0];
|
|
1754
1781
|
} else if (this.type == "route") {
|
|
1755
1782
|
center = [this.option.position[0][0], this.option.position[0][1]];
|
|
1783
|
+
} else if (this.type == "polygon") {
|
|
1784
|
+
center = this.option.position[0][0];
|
|
1756
1785
|
} else {
|
|
1757
1786
|
center = this.option.position;
|
|
1758
1787
|
}
|
|
@@ -1966,13 +1995,11 @@
|
|
|
1966
1995
|
type: "Feature",
|
|
1967
1996
|
geometry: {
|
|
1968
1997
|
type: "Point",
|
|
1969
|
-
coordinates: option.position
|
|
1970
|
-
return Number(num);
|
|
1971
|
-
})
|
|
1998
|
+
coordinates: convertPosition(option.position)
|
|
1972
1999
|
},
|
|
1973
|
-
properties:
|
|
1974
|
-
|
|
1975
|
-
}
|
|
2000
|
+
properties: {
|
|
2001
|
+
name: option.text
|
|
2002
|
+
}
|
|
1976
2003
|
}]
|
|
1977
2004
|
}
|
|
1978
2005
|
},
|
|
@@ -1980,13 +2007,24 @@
|
|
|
1980
2007
|
"circle-opacity": Number(option.opacity),
|
|
1981
2008
|
"circle-radius": Number(option.size),
|
|
1982
2009
|
"circle-color": option.color,
|
|
1983
|
-
"circle-stroke-color": option.outlineColor,
|
|
1984
|
-
"circle-stroke-width": option.outlineWidth,
|
|
1985
|
-
"circle-stroke-opacity": Number(option.outlineOpacity) // 边框样式
|
|
2010
|
+
"circle-stroke-color": option.outline ? option.outlineColor : "transparent",
|
|
2011
|
+
"circle-stroke-width": option.outline ? Number(option.outlineWidth) : 0,
|
|
2012
|
+
"circle-stroke-opacity": option.outline ? Number(option.outlineOpacity) : 1 // 边框样式
|
|
1986
2013
|
} // 填充样式
|
|
1987
2014
|
};
|
|
1988
2015
|
return config;
|
|
1989
2016
|
}
|
|
2017
|
+
/**
|
|
2018
|
+
* 将 pixelOffset 转换为 text-offset (ems)
|
|
2019
|
+
* @param {Array<number>} pixelOffset - [x, y] 像素偏移
|
|
2020
|
+
* @param {number} textSizePx - 字体大小(px)
|
|
2021
|
+
* @returns {Array<number>} text-offset in ems
|
|
2022
|
+
*/
|
|
2023
|
+
}, {
|
|
2024
|
+
key: "pixelOffsetToTextOffset",
|
|
2025
|
+
value: function pixelOffsetToTextOffset(pixelOffset, textSizePx) {
|
|
2026
|
+
return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
|
|
2027
|
+
}
|
|
1990
2028
|
}, {
|
|
1991
2029
|
key: "set",
|
|
1992
2030
|
value: function set(option) {
|
|
@@ -2003,9 +2041,7 @@
|
|
|
2003
2041
|
},
|
|
2004
2042
|
geometry: {
|
|
2005
2043
|
type: "Point",
|
|
2006
|
-
coordinates: this.option.position
|
|
2007
|
-
return Number(num);
|
|
2008
|
-
})
|
|
2044
|
+
coordinates: convertPosition(this.option.position)
|
|
2009
2045
|
}
|
|
2010
2046
|
}]
|
|
2011
2047
|
});
|
|
@@ -2015,7 +2051,7 @@
|
|
|
2015
2051
|
for (var key2 in this.config[key]) {
|
|
2016
2052
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
2017
2053
|
// 遍历 paint 属性
|
|
2018
|
-
hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" || key2 == "circle-stroke-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
|
|
2054
|
+
hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" || key2 == "circle-radius" || key2 == "circle-stroke-opacity" || key2 == "circle-stroke-width" || key2 == "text-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
|
|
2019
2055
|
}
|
|
2020
2056
|
}
|
|
2021
2057
|
}
|
|
@@ -2173,9 +2209,7 @@
|
|
|
2173
2209
|
type: "Feature",
|
|
2174
2210
|
geometry: {
|
|
2175
2211
|
type: "Point",
|
|
2176
|
-
coordinates: option.position
|
|
2177
|
-
return Number(num);
|
|
2178
|
-
})
|
|
2212
|
+
coordinates: convertPosition(option.position)
|
|
2179
2213
|
},
|
|
2180
2214
|
properties: {
|
|
2181
2215
|
name: option.text
|
|
@@ -2206,9 +2240,7 @@
|
|
|
2206
2240
|
type: "Feature",
|
|
2207
2241
|
geometry: {
|
|
2208
2242
|
type: "Point",
|
|
2209
|
-
coordinates: option.position
|
|
2210
|
-
return Number(num);
|
|
2211
|
-
})
|
|
2243
|
+
coordinates: convertPosition(option.position)
|
|
2212
2244
|
},
|
|
2213
2245
|
properties: {
|
|
2214
2246
|
name: option.num
|
|
@@ -2492,9 +2524,7 @@
|
|
|
2492
2524
|
type: "Feature",
|
|
2493
2525
|
geometry: {
|
|
2494
2526
|
type: "Point",
|
|
2495
|
-
coordinates: option.position
|
|
2496
|
-
return Number(num);
|
|
2497
|
-
})
|
|
2527
|
+
coordinates: convertPosition(option.position)
|
|
2498
2528
|
},
|
|
2499
2529
|
properties: {
|
|
2500
2530
|
name: option.text
|
|
@@ -2504,15 +2534,17 @@
|
|
|
2504
2534
|
},
|
|
2505
2535
|
layout: {
|
|
2506
2536
|
"icon-image": option.id + "_image",
|
|
2507
|
-
"icon-size": 1,
|
|
2508
|
-
"icon-ignore-placement":
|
|
2509
|
-
"
|
|
2537
|
+
// "icon-size": 1,
|
|
2538
|
+
"icon-ignore-placement": false,
|
|
2539
|
+
// "icon-offset": convertPosition(option.offset),
|
|
2540
|
+
"text-ignore-placement": false,
|
|
2541
|
+
//
|
|
2510
2542
|
"text-field": "{name}",
|
|
2511
2543
|
// 文本
|
|
2512
|
-
"text-size": option.fontSize,
|
|
2513
|
-
"text-anchor":
|
|
2514
|
-
"icon-anchor":
|
|
2515
|
-
"text-offset": option.offset
|
|
2544
|
+
"text-size": Number(option.fontSize),
|
|
2545
|
+
"text-anchor": option.verticalOrigin,
|
|
2546
|
+
"icon-anchor": option.verticalOrigin
|
|
2547
|
+
// "text-offset": convertPosition(option.offset),
|
|
2516
2548
|
},
|
|
2517
2549
|
paint: {
|
|
2518
2550
|
"text-color": option.color
|
|
@@ -2525,16 +2557,20 @@
|
|
|
2525
2557
|
value: function set(option) {
|
|
2526
2558
|
deepMerge(this.option, option);
|
|
2527
2559
|
this.config = this.formatConfig(this.option);
|
|
2560
|
+
console.log(this.config, "======CONFIG=====");
|
|
2561
|
+
console.log(this.option, "=========OPTION");
|
|
2528
2562
|
var mySource = hnMap.map.map.getSource(this.config.id);
|
|
2563
|
+
console.log(mySource, "=========SOURCE");
|
|
2529
2564
|
mySource.setData({
|
|
2530
2565
|
type: "FeatureCollection",
|
|
2531
2566
|
features: [{
|
|
2532
2567
|
type: "Feature",
|
|
2533
2568
|
geometry: {
|
|
2534
2569
|
type: "Point",
|
|
2535
|
-
coordinates: this.option.position
|
|
2536
|
-
|
|
2537
|
-
|
|
2570
|
+
coordinates: convertPosition(this.option.position)
|
|
2571
|
+
},
|
|
2572
|
+
properties: {
|
|
2573
|
+
name: this.option.text
|
|
2538
2574
|
}
|
|
2539
2575
|
}]
|
|
2540
2576
|
});
|
|
@@ -2544,7 +2580,7 @@
|
|
|
2544
2580
|
for (var key2 in this.config[key]) {
|
|
2545
2581
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
2546
2582
|
// 遍历 layout 属性
|
|
2547
|
-
hnMap.map.map.setLayoutProperty(this.config.id, key2, this.config[key][key2]);
|
|
2583
|
+
hnMap.map.map.setLayoutProperty(this.config.id, key2, key2 == "text-size" ? Number(this.config[key][key2]) : this.config[key][key2]);
|
|
2548
2584
|
}
|
|
2549
2585
|
}
|
|
2550
2586
|
}
|
|
@@ -2777,7 +2813,7 @@
|
|
|
2777
2813
|
outlineColor: option.outlineColor,
|
|
2778
2814
|
outlineWidth: option.outlineWidth,
|
|
2779
2815
|
outlineOpacity: option.outlineOpacity,
|
|
2780
|
-
pixelOffset: option.offset,
|
|
2816
|
+
pixelOffset: convertPosition(option.offset),
|
|
2781
2817
|
scaleByDistance: option.scaleByDistance,
|
|
2782
2818
|
clampToGround: !option.position[2],
|
|
2783
2819
|
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
@@ -2920,9 +2956,12 @@
|
|
|
2920
2956
|
// 文本样式
|
|
2921
2957
|
paint: {
|
|
2922
2958
|
"text-color": option.color,
|
|
2923
|
-
"text-halo-color": option.outlineColor,
|
|
2959
|
+
"text-halo-color": option.outline ? option.outlineColor : "transparent",
|
|
2924
2960
|
// 文字外边线颜色
|
|
2925
|
-
"text-halo-width": option.outlineWidth
|
|
2961
|
+
"text-halo-width": option.outline ? Number(option.outlineWidth) : 0,
|
|
2962
|
+
// 文字外边线宽度
|
|
2963
|
+
"text-opacity": Number(option.opacity)
|
|
2964
|
+
// "text-halo-opacity": option.outline ? option.outlineOpacity : 1,
|
|
2926
2965
|
} // 填充样式
|
|
2927
2966
|
};
|
|
2928
2967
|
if (option.type === "label") {
|
|
@@ -2930,9 +2969,7 @@
|
|
|
2930
2969
|
type: "Feature",
|
|
2931
2970
|
geometry: {
|
|
2932
2971
|
type: "Point",
|
|
2933
|
-
coordinates: option.position
|
|
2934
|
-
return Number(num);
|
|
2935
|
-
})
|
|
2972
|
+
coordinates: convertPosition(option.position)
|
|
2936
2973
|
},
|
|
2937
2974
|
properties: {
|
|
2938
2975
|
name: option.text
|
|
@@ -2947,7 +2984,7 @@
|
|
|
2947
2984
|
},
|
|
2948
2985
|
geometry: {
|
|
2949
2986
|
type: "Point",
|
|
2950
|
-
coordinates:
|
|
2987
|
+
coordinates: convertPosition(option.position)
|
|
2951
2988
|
}
|
|
2952
2989
|
});
|
|
2953
2990
|
});
|
|
@@ -2982,9 +3019,7 @@
|
|
|
2982
3019
|
},
|
|
2983
3020
|
geometry: {
|
|
2984
3021
|
type: "Point",
|
|
2985
|
-
coordinates:
|
|
2986
|
-
return Number(num);
|
|
2987
|
-
})
|
|
3022
|
+
coordinates: convertPosition(option.position)
|
|
2988
3023
|
}
|
|
2989
3024
|
}]
|
|
2990
3025
|
});
|
|
@@ -3014,7 +3049,7 @@
|
|
|
3014
3049
|
for (var key2 in this.config[key]) {
|
|
3015
3050
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
3016
3051
|
// 遍历 paint 属性
|
|
3017
|
-
hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "text-halo-width" ? Number(this.config[key][key2]) : this.config[key][key2]);
|
|
3052
|
+
hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "text-halo-width" || key2 == "text-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
|
|
3018
3053
|
}
|
|
3019
3054
|
}
|
|
3020
3055
|
}
|
|
@@ -3285,7 +3320,7 @@
|
|
|
3285
3320
|
type: "Feature",
|
|
3286
3321
|
geometry: {
|
|
3287
3322
|
type: "LineString",
|
|
3288
|
-
coordinates: option.position
|
|
3323
|
+
coordinates: convertPosition(option.position)
|
|
3289
3324
|
},
|
|
3290
3325
|
properties: Object.assign({
|
|
3291
3326
|
id: option.id
|
|
@@ -3295,12 +3330,14 @@
|
|
|
3295
3330
|
},
|
|
3296
3331
|
layout: {
|
|
3297
3332
|
"line-cap": "round",
|
|
3298
|
-
|
|
3333
|
+
// 线端点样式
|
|
3334
|
+
"line-join": "round" // 线连接样式
|
|
3299
3335
|
},
|
|
3300
3336
|
paint: {
|
|
3301
3337
|
"line-color": option.type == "dash" ? option.dashColor : option.color,
|
|
3302
3338
|
"line-width": Number(option.width),
|
|
3303
3339
|
"line-opacity": Number(option.opacity)
|
|
3340
|
+
// "line-gap-width": 4,
|
|
3304
3341
|
}
|
|
3305
3342
|
};
|
|
3306
3343
|
var isShow = true;
|
|
@@ -3321,6 +3358,20 @@
|
|
|
3321
3358
|
value: function set(option) {
|
|
3322
3359
|
deepMerge(this.option, option);
|
|
3323
3360
|
this.config = this.formatConfig(this.option);
|
|
3361
|
+
var mySource = hnMap.map.map.getSource(this.config.id);
|
|
3362
|
+
mySource.setData({
|
|
3363
|
+
type: "FeatureCollection",
|
|
3364
|
+
features: [{
|
|
3365
|
+
type: "Feature",
|
|
3366
|
+
properties: Object.assign({
|
|
3367
|
+
id: option.id
|
|
3368
|
+
}, option.data),
|
|
3369
|
+
geometry: {
|
|
3370
|
+
type: "LineString",
|
|
3371
|
+
coordinates: convertPosition(this.option.position)
|
|
3372
|
+
}
|
|
3373
|
+
}]
|
|
3374
|
+
});
|
|
3324
3375
|
for (var key in this.config) {
|
|
3325
3376
|
if (this.config.hasOwnProperty(key)) {
|
|
3326
3377
|
if (key == "paint") {
|
|
@@ -3548,7 +3599,7 @@
|
|
|
3548
3599
|
// 允许调整圆心
|
|
3549
3600
|
canMove: false,
|
|
3550
3601
|
// 设置非编辑状态下的图层颜色
|
|
3551
|
-
drawColor: option.outlineColor,
|
|
3602
|
+
// drawColor: option.outlineColor,
|
|
3552
3603
|
// 设置编辑状态下的图层颜色
|
|
3553
3604
|
// editColor: "red",
|
|
3554
3605
|
style: {
|
|
@@ -3556,7 +3607,13 @@
|
|
|
3556
3607
|
polygon: {
|
|
3557
3608
|
"fill-color": option.color,
|
|
3558
3609
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3559
|
-
"fill-opacity": Number(option.opacity)
|
|
3610
|
+
"fill-opacity": Number(option.opacity),
|
|
3611
|
+
"fill-outline-color": option.outlineColor
|
|
3612
|
+
},
|
|
3613
|
+
polyline: {
|
|
3614
|
+
"line-color": option.outlineColor,
|
|
3615
|
+
"line-opacity": Number(option.outlineOpacity),
|
|
3616
|
+
"line-width": Number(option.outlineWidth)
|
|
3560
3617
|
}
|
|
3561
3618
|
},
|
|
3562
3619
|
// 编辑数据
|
|
@@ -3575,8 +3632,8 @@
|
|
|
3575
3632
|
var featureArr = {
|
|
3576
3633
|
type: "Feature",
|
|
3577
3634
|
properties: {
|
|
3578
|
-
centerPoint: option.position,
|
|
3579
|
-
radius: option.radius
|
|
3635
|
+
centerPoint: convertPosition(this.option.position),
|
|
3636
|
+
radius: this.option.radius
|
|
3580
3637
|
},
|
|
3581
3638
|
geometry: {
|
|
3582
3639
|
type: "Polygon",
|
|
@@ -3727,7 +3784,6 @@
|
|
|
3727
3784
|
key: "formatConfig",
|
|
3728
3785
|
value: function formatConfig(option) {
|
|
3729
3786
|
var RectanglePosition = createRectangleCoordinates(option.position[0], option.position[1]);
|
|
3730
|
-
console.log([RectanglePosition], "========RectanglePosition=======");
|
|
3731
3787
|
var config = {
|
|
3732
3788
|
id: option.id,
|
|
3733
3789
|
type: "fill",
|
|
@@ -3747,7 +3803,9 @@
|
|
|
3747
3803
|
paint: {
|
|
3748
3804
|
"fill-color": option.color,
|
|
3749
3805
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3750
|
-
"fill-opacity": Number(option.opacity)
|
|
3806
|
+
"fill-opacity": Number(option.opacity),
|
|
3807
|
+
"fill-antialias": true,
|
|
3808
|
+
"fill-outline-color": option.outlineColor
|
|
3751
3809
|
}
|
|
3752
3810
|
};
|
|
3753
3811
|
return config;
|
|
@@ -3931,7 +3989,7 @@
|
|
|
3931
3989
|
type: "Feature",
|
|
3932
3990
|
geometry: {
|
|
3933
3991
|
type: "Polygon",
|
|
3934
|
-
coordinates: option.position
|
|
3992
|
+
coordinates: convertPosition(option.position)
|
|
3935
3993
|
}
|
|
3936
3994
|
}]
|
|
3937
3995
|
}
|
|
@@ -3939,7 +3997,9 @@
|
|
|
3939
3997
|
paint: {
|
|
3940
3998
|
"fill-color": option.color,
|
|
3941
3999
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3942
|
-
"fill-opacity": Number(option.opacity)
|
|
4000
|
+
"fill-opacity": Number(option.opacity),
|
|
4001
|
+
"fill-antialias": true,
|
|
4002
|
+
"fill-outline-color": option.outlineColor
|
|
3943
4003
|
}
|
|
3944
4004
|
};
|
|
3945
4005
|
return config;
|
|
@@ -3956,7 +4016,7 @@
|
|
|
3956
4016
|
type: "Feature",
|
|
3957
4017
|
geometry: {
|
|
3958
4018
|
type: "Polygon",
|
|
3959
|
-
coordinates:
|
|
4019
|
+
coordinates: convertPosition(option.position) //三层数组[[[0,0],[0,0]]]
|
|
3960
4020
|
}
|
|
3961
4021
|
}]
|
|
3962
4022
|
});
|
|
@@ -5333,7 +5393,6 @@
|
|
|
5333
5393
|
case 0:
|
|
5334
5394
|
// 判断是否在子路径下
|
|
5335
5395
|
basePath = window.location.pathname.endsWith("/") ? window.location.pathname : window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
|
|
5336
|
-
console.log(basePath);
|
|
5337
5396
|
_context.n = 1;
|
|
5338
5397
|
return loadResource(basePath + "lib/turf/turf.min.js", "js");
|
|
5339
5398
|
case 1:
|
package/package.json
CHANGED
package/src/base/siji_entity.ts
CHANGED
|
@@ -82,12 +82,13 @@ export default class siji_entity {
|
|
|
82
82
|
this.type == "flow" ||
|
|
83
83
|
this.type == "arrow" ||
|
|
84
84
|
this.type == "mapLabel" ||
|
|
85
|
-
this.type == "polygon" ||
|
|
86
85
|
this.type == "rectangle"
|
|
87
86
|
) {
|
|
88
87
|
center = this.option.position[0];
|
|
89
88
|
} else if (this.type == "route") {
|
|
90
89
|
center = [this.option.position[0][0], this.option.position[0][1]];
|
|
90
|
+
} else if (this.type == "polygon") {
|
|
91
|
+
center = this.option.position[0][0];
|
|
91
92
|
} else {
|
|
92
93
|
center = this.option.position;
|
|
93
94
|
}
|
package/src/graphic/circle.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";
|
|
@@ -177,7 +182,7 @@ export default (hnMap: any) => {
|
|
|
177
182
|
// 允许调整圆心
|
|
178
183
|
canMove: false,
|
|
179
184
|
// 设置非编辑状态下的图层颜色
|
|
180
|
-
drawColor: option.outlineColor,
|
|
185
|
+
// drawColor: option.outlineColor,
|
|
181
186
|
// 设置编辑状态下的图层颜色
|
|
182
187
|
// editColor: "red",
|
|
183
188
|
style: {
|
|
@@ -185,6 +190,12 @@ export default (hnMap: any) => {
|
|
|
185
190
|
polygon: {
|
|
186
191
|
"fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
187
192
|
"fill-opacity": Number(option.opacity),
|
|
193
|
+
"fill-outline-color": option.outlineColor,
|
|
194
|
+
},
|
|
195
|
+
polyline: {
|
|
196
|
+
"line-color": option.outlineColor,
|
|
197
|
+
"line-opacity": Number(option.outlineOpacity),
|
|
198
|
+
"line-width": Number(option.outlineWidth),
|
|
188
199
|
},
|
|
189
200
|
},
|
|
190
201
|
// 编辑数据
|
|
@@ -202,8 +213,8 @@ export default (hnMap: any) => {
|
|
|
202
213
|
let featureArr = {
|
|
203
214
|
type: "Feature",
|
|
204
215
|
properties: {
|
|
205
|
-
centerPoint: option.position,
|
|
206
|
-
radius: option.radius,
|
|
216
|
+
centerPoint: convertPosition(this.option.position),
|
|
217
|
+
radius: this.option.radius,
|
|
207
218
|
},
|
|
208
219
|
geometry: {
|
|
209
220
|
type: "Polygon",
|
package/src/graphic/divPoint.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";
|
|
@@ -45,8 +50,12 @@ export default (hnMap: any) => {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
formatConfig(option: any) {
|
|
48
|
-
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
49
|
-
|
|
53
|
+
const distanceDisplayCondition_far = getLevelMiddleHeight(
|
|
54
|
+
option.distanceDisplayCondition_far
|
|
55
|
+
);
|
|
56
|
+
const distanceDisplayCondition_near = getLevelMiddleHeight(
|
|
57
|
+
option.distanceDisplayCondition_near
|
|
58
|
+
);
|
|
50
59
|
return {
|
|
51
60
|
id: option.id,
|
|
52
61
|
position: option.position,
|
|
@@ -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";
|
|
@@ -178,7 +183,7 @@ export default (hnMap: any) => {
|
|
|
178
183
|
type: "Feature",
|
|
179
184
|
geometry: {
|
|
180
185
|
type: "Point",
|
|
181
|
-
coordinates: option.position
|
|
186
|
+
coordinates: convertPosition(option.position),
|
|
182
187
|
},
|
|
183
188
|
properties: {
|
|
184
189
|
name: option.text,
|
|
@@ -189,14 +194,15 @@ export default (hnMap: any) => {
|
|
|
189
194
|
},
|
|
190
195
|
layout: {
|
|
191
196
|
"icon-image": option.id + "_image",
|
|
192
|
-
"icon-size": 1,
|
|
193
|
-
"icon-ignore-placement":
|
|
194
|
-
"
|
|
197
|
+
// "icon-size": 1,
|
|
198
|
+
"icon-ignore-placement": false,
|
|
199
|
+
// "icon-offset": convertPosition(option.offset),
|
|
200
|
+
"text-ignore-placement": false, //
|
|
195
201
|
"text-field": "{name}", // 文本
|
|
196
|
-
"text-size": option.fontSize,
|
|
197
|
-
"text-anchor":
|
|
198
|
-
"icon-anchor":
|
|
199
|
-
"text-offset": option.offset,
|
|
202
|
+
"text-size": Number(option.fontSize),
|
|
203
|
+
"text-anchor": option.verticalOrigin,
|
|
204
|
+
"icon-anchor": option.verticalOrigin,
|
|
205
|
+
// "text-offset": convertPosition(option.offset),
|
|
200
206
|
},
|
|
201
207
|
paint: {
|
|
202
208
|
"text-color": option.color,
|
|
@@ -208,7 +214,10 @@ export default (hnMap: any) => {
|
|
|
208
214
|
set(option: any) {
|
|
209
215
|
deepMerge(this.option, option);
|
|
210
216
|
this.config = this.formatConfig(this.option);
|
|
217
|
+
console.log(this.config, "======CONFIG=====");
|
|
218
|
+
console.log(this.option, "=========OPTION");
|
|
211
219
|
let mySource = hnMap.map.map.getSource(this.config.id);
|
|
220
|
+
console.log(mySource, "=========SOURCE");
|
|
212
221
|
mySource.setData({
|
|
213
222
|
type: "FeatureCollection",
|
|
214
223
|
features: [
|
|
@@ -216,7 +225,10 @@ export default (hnMap: any) => {
|
|
|
216
225
|
type: "Feature",
|
|
217
226
|
geometry: {
|
|
218
227
|
type: "Point",
|
|
219
|
-
coordinates: this.option.position
|
|
228
|
+
coordinates: convertPosition(this.option.position),
|
|
229
|
+
},
|
|
230
|
+
properties: {
|
|
231
|
+
name: this.option.text,
|
|
220
232
|
},
|
|
221
233
|
},
|
|
222
234
|
],
|
|
@@ -231,7 +243,9 @@ export default (hnMap: any) => {
|
|
|
231
243
|
hnMap.map.map.setLayoutProperty(
|
|
232
244
|
this.config.id,
|
|
233
245
|
key2,
|
|
234
|
-
|
|
246
|
+
key2 == "text-size"
|
|
247
|
+
? Number(this.config[key][key2])
|
|
248
|
+
: this.config[key][key2]
|
|
235
249
|
);
|
|
236
250
|
}
|
|
237
251
|
}
|
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: {
|
package/src/util.ts
CHANGED
|
@@ -215,11 +215,20 @@ export function getHeightToLevel(height: number): number {
|
|
|
215
215
|
}
|
|
216
216
|
// 將坐标数组中的元素字符串类型统一处理为number类型
|
|
217
217
|
export function convertPosition(
|
|
218
|
-
position: string[] | string[][]
|
|
219
|
-
): number[] | number[][] {
|
|
220
|
-
return position.map((item) =>
|
|
221
|
-
Array.isArray(item)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
position: string[] | string[][] | string[][][]
|
|
219
|
+
): number[] | number[][] | number[][][] {
|
|
220
|
+
return position.map((item) => {
|
|
221
|
+
if (Array.isArray(item)) {
|
|
222
|
+
return item.map((innerItem) => {
|
|
223
|
+
if (Array.isArray(innerItem)) {
|
|
224
|
+
// 第三层,将每个字符串转数字
|
|
225
|
+
return innerItem.map((str) => Number(str));
|
|
226
|
+
} else {
|
|
227
|
+
return Number(innerItem);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
return Number(item);
|
|
232
|
+
}
|
|
233
|
+
}) as number[] | number[][] | number[][][];
|
|
225
234
|
}
|