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/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 = {
|
|
@@ -767,13 +786,6 @@
|
|
|
767
786
|
this.map.on("pitchend", function (e) {
|
|
768
787
|
return _this2.updateMapParams(e);
|
|
769
788
|
}); // 地图俯仰角度完成
|
|
770
|
-
this.map.on("load", function (e) {
|
|
771
|
-
// 路况展示
|
|
772
|
-
var roadNetLayer = new SGMap.RoadNetLayer({
|
|
773
|
-
map: _this2.map
|
|
774
|
-
});
|
|
775
|
-
roadNetLayer.render();
|
|
776
|
-
});
|
|
777
789
|
}
|
|
778
790
|
return _createClass(siji_map, [{
|
|
779
791
|
key: "formatConfig",
|
|
@@ -943,6 +955,32 @@
|
|
|
943
955
|
_context3.n = 1;
|
|
944
956
|
return new Promise(function (resolve) {
|
|
945
957
|
instance.map.on("load", function (e) {
|
|
958
|
+
// 路况展示
|
|
959
|
+
var roadNetLayer = new SGMap.RoadNetLayer({
|
|
960
|
+
map: instance.map
|
|
961
|
+
});
|
|
962
|
+
roadNetLayer.render();
|
|
963
|
+
//添加天空图层
|
|
964
|
+
instance.map.addLayer({
|
|
965
|
+
"id": "sky",
|
|
966
|
+
"type": "sky",
|
|
967
|
+
"paint": {
|
|
968
|
+
"sky-type": "atmosphere",
|
|
969
|
+
"sky-atmosphere-sun": [0, 0],
|
|
970
|
+
"sky-atmosphere-sun-intensity": 15
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
// 加载地形(需要v3.1.0,且需要新的key和secret)
|
|
974
|
+
// !instance.map.getSource('terrain') && instance.map.addSource('terrain',{
|
|
975
|
+
// type:'raster-dem',
|
|
976
|
+
// url:"aegis://aegis.Terrain3D",//地形高程数据源名称
|
|
977
|
+
// tileSize:512,
|
|
978
|
+
//
|
|
979
|
+
// })
|
|
980
|
+
// instance.map.setTerrain({
|
|
981
|
+
// source:'terrain',
|
|
982
|
+
// exaggeration:1,//地形夸张比例
|
|
983
|
+
// })
|
|
946
984
|
resolve(e);
|
|
947
985
|
});
|
|
948
986
|
});
|
|
@@ -1010,7 +1048,12 @@
|
|
|
1010
1048
|
key: "removeEntity",
|
|
1011
1049
|
value: function removeEntity(entityParam) {
|
|
1012
1050
|
var entity = this.getEntity(entityParam);
|
|
1051
|
+
console.log("removeEntity", entity);
|
|
1013
1052
|
if (entity) {
|
|
1053
|
+
this.children = this.children.filter(function (v) {
|
|
1054
|
+
return v.id !== entity.id;
|
|
1055
|
+
});
|
|
1056
|
+
console.log("layerEntity", this.layerEntity);
|
|
1014
1057
|
this.layerEntity.removeGraphic(entity.graphic);
|
|
1015
1058
|
}
|
|
1016
1059
|
}
|
|
@@ -1284,6 +1327,7 @@
|
|
|
1284
1327
|
}, {
|
|
1285
1328
|
key: "updateEntity",
|
|
1286
1329
|
value: function updateEntity(entity, viewPos) {
|
|
1330
|
+
console.log("updateEntity", entity, viewPos);
|
|
1287
1331
|
var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
|
|
1288
1332
|
if (isUpdateEntity) {
|
|
1289
1333
|
if (!entity.show && this.isIncludesLabel(entity.option.position, viewPos)) {
|
|
@@ -1338,8 +1382,10 @@
|
|
|
1338
1382
|
key: "addLevelEntity",
|
|
1339
1383
|
value: function addLevelEntity(entity) {
|
|
1340
1384
|
if (entity.type == "imagePoint") {
|
|
1385
|
+
console.log("addLevelEntity=====", entity);
|
|
1341
1386
|
hnMap.map.map.loadImage(entity.option.image, function (error, image) {
|
|
1342
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"]];
|
|
1343
1389
|
hnMap.map.map.addImage(entity.id + "_image", image);
|
|
1344
1390
|
hnMap.map.map.addLayer(entity.config);
|
|
1345
1391
|
});
|
|
@@ -1352,7 +1398,7 @@
|
|
|
1352
1398
|
var featureArr = {
|
|
1353
1399
|
type: "Feature",
|
|
1354
1400
|
properties: {
|
|
1355
|
-
centerPoint: entity.option.position,
|
|
1401
|
+
centerPoint: convertPosition(entity.option.position),
|
|
1356
1402
|
radius: entity.option.radius
|
|
1357
1403
|
},
|
|
1358
1404
|
geometry: {
|
|
@@ -1393,6 +1439,10 @@
|
|
|
1393
1439
|
hnMap.map.map.removeLayer(entity.config_routeplay.id);
|
|
1394
1440
|
hnMap.map.map.removeSource(entity.config_routeplay.id);
|
|
1395
1441
|
entity.imgMarker.remove();
|
|
1442
|
+
} else if (entity.type == "imagePoint") {
|
|
1443
|
+
hnMap.map.map.removeImage(entity.id + "_image");
|
|
1444
|
+
hnMap.map.map.removeLayer(entity.id);
|
|
1445
|
+
hnMap.map.map.removeSource(entity.id);
|
|
1396
1446
|
} else {
|
|
1397
1447
|
hnMap.map.map.removeLayer(entity.id);
|
|
1398
1448
|
hnMap.map.map.removeSource(entity.id);
|
|
@@ -1406,6 +1456,7 @@
|
|
|
1406
1456
|
value: function moveEntity(layerIds) {
|
|
1407
1457
|
// 数组转字符串
|
|
1408
1458
|
var s = layerIds.join(",");
|
|
1459
|
+
console.log("s===", s);
|
|
1409
1460
|
hnMap.map.map.moveLayer(s);
|
|
1410
1461
|
}
|
|
1411
1462
|
}, {
|
|
@@ -1700,8 +1751,8 @@
|
|
|
1700
1751
|
var handleClick = function handleClick(e) {
|
|
1701
1752
|
var data = _this2.option.data;
|
|
1702
1753
|
// const data = e.features[0].properties;
|
|
1703
|
-
getCustomDom(data);
|
|
1704
|
-
_this2.infoWindow.setHTML(
|
|
1754
|
+
var dom = getCustomDom(data);
|
|
1755
|
+
_this2.infoWindow.setHTML(dom);
|
|
1705
1756
|
_this2.infoWindow.setLngLat(e.lngLat).addTo(_this2.hnMap.map.map);
|
|
1706
1757
|
};
|
|
1707
1758
|
this.hnMap.map.map.on("click", this.config.id, handleClick);
|
|
@@ -1725,10 +1776,12 @@
|
|
|
1725
1776
|
if (this.option.center) {
|
|
1726
1777
|
center = this.option.center;
|
|
1727
1778
|
} else {
|
|
1728
|
-
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") {
|
|
1729
1780
|
center = this.option.position[0];
|
|
1730
1781
|
} else if (this.type == "route") {
|
|
1731
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];
|
|
1732
1785
|
} else {
|
|
1733
1786
|
center = this.option.position;
|
|
1734
1787
|
}
|
|
@@ -1942,13 +1995,11 @@
|
|
|
1942
1995
|
type: "Feature",
|
|
1943
1996
|
geometry: {
|
|
1944
1997
|
type: "Point",
|
|
1945
|
-
coordinates: option.position
|
|
1946
|
-
return Number(num);
|
|
1947
|
-
})
|
|
1998
|
+
coordinates: convertPosition(option.position)
|
|
1948
1999
|
},
|
|
1949
|
-
properties:
|
|
1950
|
-
|
|
1951
|
-
}
|
|
2000
|
+
properties: {
|
|
2001
|
+
name: option.text
|
|
2002
|
+
}
|
|
1952
2003
|
}]
|
|
1953
2004
|
}
|
|
1954
2005
|
},
|
|
@@ -1956,13 +2007,24 @@
|
|
|
1956
2007
|
"circle-opacity": Number(option.opacity),
|
|
1957
2008
|
"circle-radius": Number(option.size),
|
|
1958
2009
|
"circle-color": option.color,
|
|
1959
|
-
"circle-stroke-color": option.outlineColor,
|
|
1960
|
-
"circle-stroke-width": option.outlineWidth,
|
|
1961
|
-
"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 // 边框样式
|
|
1962
2013
|
} // 填充样式
|
|
1963
2014
|
};
|
|
1964
2015
|
return config;
|
|
1965
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
|
+
}
|
|
1966
2028
|
}, {
|
|
1967
2029
|
key: "set",
|
|
1968
2030
|
value: function set(option) {
|
|
@@ -1979,9 +2041,7 @@
|
|
|
1979
2041
|
},
|
|
1980
2042
|
geometry: {
|
|
1981
2043
|
type: "Point",
|
|
1982
|
-
coordinates: this.option.position
|
|
1983
|
-
return Number(num);
|
|
1984
|
-
})
|
|
2044
|
+
coordinates: convertPosition(this.option.position)
|
|
1985
2045
|
}
|
|
1986
2046
|
}]
|
|
1987
2047
|
});
|
|
@@ -1991,7 +2051,7 @@
|
|
|
1991
2051
|
for (var key2 in this.config[key]) {
|
|
1992
2052
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
1993
2053
|
// 遍历 paint 属性
|
|
1994
|
-
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]);
|
|
1995
2055
|
}
|
|
1996
2056
|
}
|
|
1997
2057
|
}
|
|
@@ -2149,9 +2209,7 @@
|
|
|
2149
2209
|
type: "Feature",
|
|
2150
2210
|
geometry: {
|
|
2151
2211
|
type: "Point",
|
|
2152
|
-
coordinates: option.position
|
|
2153
|
-
return Number(num);
|
|
2154
|
-
})
|
|
2212
|
+
coordinates: convertPosition(option.position)
|
|
2155
2213
|
},
|
|
2156
2214
|
properties: {
|
|
2157
2215
|
name: option.text
|
|
@@ -2182,9 +2240,7 @@
|
|
|
2182
2240
|
type: "Feature",
|
|
2183
2241
|
geometry: {
|
|
2184
2242
|
type: "Point",
|
|
2185
|
-
coordinates: option.position
|
|
2186
|
-
return Number(num);
|
|
2187
|
-
})
|
|
2243
|
+
coordinates: convertPosition(option.position)
|
|
2188
2244
|
},
|
|
2189
2245
|
properties: {
|
|
2190
2246
|
name: option.num
|
|
@@ -2468,9 +2524,7 @@
|
|
|
2468
2524
|
type: "Feature",
|
|
2469
2525
|
geometry: {
|
|
2470
2526
|
type: "Point",
|
|
2471
|
-
coordinates: option.position
|
|
2472
|
-
return Number(num);
|
|
2473
|
-
})
|
|
2527
|
+
coordinates: convertPosition(option.position)
|
|
2474
2528
|
},
|
|
2475
2529
|
properties: {
|
|
2476
2530
|
name: option.text
|
|
@@ -2480,15 +2534,17 @@
|
|
|
2480
2534
|
},
|
|
2481
2535
|
layout: {
|
|
2482
2536
|
"icon-image": option.id + "_image",
|
|
2483
|
-
"icon-size": 1,
|
|
2484
|
-
"icon-ignore-placement":
|
|
2485
|
-
"
|
|
2537
|
+
// "icon-size": 1,
|
|
2538
|
+
"icon-ignore-placement": false,
|
|
2539
|
+
// "icon-offset": convertPosition(option.offset),
|
|
2540
|
+
"text-ignore-placement": false,
|
|
2541
|
+
//
|
|
2486
2542
|
"text-field": "{name}",
|
|
2487
2543
|
// 文本
|
|
2488
|
-
"text-size": option.fontSize,
|
|
2489
|
-
"text-anchor":
|
|
2490
|
-
"icon-anchor":
|
|
2491
|
-
"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),
|
|
2492
2548
|
},
|
|
2493
2549
|
paint: {
|
|
2494
2550
|
"text-color": option.color
|
|
@@ -2501,16 +2557,20 @@
|
|
|
2501
2557
|
value: function set(option) {
|
|
2502
2558
|
deepMerge(this.option, option);
|
|
2503
2559
|
this.config = this.formatConfig(this.option);
|
|
2560
|
+
console.log(this.config, "======CONFIG=====");
|
|
2561
|
+
console.log(this.option, "=========OPTION");
|
|
2504
2562
|
var mySource = hnMap.map.map.getSource(this.config.id);
|
|
2563
|
+
console.log(mySource, "=========SOURCE");
|
|
2505
2564
|
mySource.setData({
|
|
2506
2565
|
type: "FeatureCollection",
|
|
2507
2566
|
features: [{
|
|
2508
2567
|
type: "Feature",
|
|
2509
2568
|
geometry: {
|
|
2510
2569
|
type: "Point",
|
|
2511
|
-
coordinates: this.option.position
|
|
2512
|
-
|
|
2513
|
-
|
|
2570
|
+
coordinates: convertPosition(this.option.position)
|
|
2571
|
+
},
|
|
2572
|
+
properties: {
|
|
2573
|
+
name: this.option.text
|
|
2514
2574
|
}
|
|
2515
2575
|
}]
|
|
2516
2576
|
});
|
|
@@ -2520,7 +2580,7 @@
|
|
|
2520
2580
|
for (var key2 in this.config[key]) {
|
|
2521
2581
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
2522
2582
|
// 遍历 layout 属性
|
|
2523
|
-
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]);
|
|
2524
2584
|
}
|
|
2525
2585
|
}
|
|
2526
2586
|
}
|
|
@@ -2753,7 +2813,7 @@
|
|
|
2753
2813
|
outlineColor: option.outlineColor,
|
|
2754
2814
|
outlineWidth: option.outlineWidth,
|
|
2755
2815
|
outlineOpacity: option.outlineOpacity,
|
|
2756
|
-
pixelOffset: option.offset,
|
|
2816
|
+
pixelOffset: convertPosition(option.offset),
|
|
2757
2817
|
scaleByDistance: option.scaleByDistance,
|
|
2758
2818
|
clampToGround: !option.position[2],
|
|
2759
2819
|
distanceDisplayCondition: option.distanceDisplayCondition,
|
|
@@ -2896,9 +2956,12 @@
|
|
|
2896
2956
|
// 文本样式
|
|
2897
2957
|
paint: {
|
|
2898
2958
|
"text-color": option.color,
|
|
2899
|
-
"text-halo-color": option.outlineColor,
|
|
2959
|
+
"text-halo-color": option.outline ? option.outlineColor : "transparent",
|
|
2900
2960
|
// 文字外边线颜色
|
|
2901
|
-
"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,
|
|
2902
2965
|
} // 填充样式
|
|
2903
2966
|
};
|
|
2904
2967
|
if (option.type === "label") {
|
|
@@ -2906,9 +2969,7 @@
|
|
|
2906
2969
|
type: "Feature",
|
|
2907
2970
|
geometry: {
|
|
2908
2971
|
type: "Point",
|
|
2909
|
-
coordinates: option.position
|
|
2910
|
-
return Number(num);
|
|
2911
|
-
})
|
|
2972
|
+
coordinates: convertPosition(option.position)
|
|
2912
2973
|
},
|
|
2913
2974
|
properties: {
|
|
2914
2975
|
name: option.text
|
|
@@ -2923,7 +2984,7 @@
|
|
|
2923
2984
|
},
|
|
2924
2985
|
geometry: {
|
|
2925
2986
|
type: "Point",
|
|
2926
|
-
coordinates:
|
|
2987
|
+
coordinates: convertPosition(option.position)
|
|
2927
2988
|
}
|
|
2928
2989
|
});
|
|
2929
2990
|
});
|
|
@@ -2958,9 +3019,7 @@
|
|
|
2958
3019
|
},
|
|
2959
3020
|
geometry: {
|
|
2960
3021
|
type: "Point",
|
|
2961
|
-
coordinates:
|
|
2962
|
-
return Number(num);
|
|
2963
|
-
})
|
|
3022
|
+
coordinates: convertPosition(option.position)
|
|
2964
3023
|
}
|
|
2965
3024
|
}]
|
|
2966
3025
|
});
|
|
@@ -2990,7 +3049,7 @@
|
|
|
2990
3049
|
for (var key2 in this.config[key]) {
|
|
2991
3050
|
if (this.config[key].hasOwnProperty(key2)) {
|
|
2992
3051
|
// 遍历 paint 属性
|
|
2993
|
-
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]);
|
|
2994
3053
|
}
|
|
2995
3054
|
}
|
|
2996
3055
|
}
|
|
@@ -3261,7 +3320,7 @@
|
|
|
3261
3320
|
type: "Feature",
|
|
3262
3321
|
geometry: {
|
|
3263
3322
|
type: "LineString",
|
|
3264
|
-
coordinates: option.position
|
|
3323
|
+
coordinates: convertPosition(option.position)
|
|
3265
3324
|
},
|
|
3266
3325
|
properties: Object.assign({
|
|
3267
3326
|
id: option.id
|
|
@@ -3271,12 +3330,14 @@
|
|
|
3271
3330
|
},
|
|
3272
3331
|
layout: {
|
|
3273
3332
|
"line-cap": "round",
|
|
3274
|
-
|
|
3333
|
+
// 线端点样式
|
|
3334
|
+
"line-join": "round" // 线连接样式
|
|
3275
3335
|
},
|
|
3276
3336
|
paint: {
|
|
3277
3337
|
"line-color": option.type == "dash" ? option.dashColor : option.color,
|
|
3278
3338
|
"line-width": Number(option.width),
|
|
3279
3339
|
"line-opacity": Number(option.opacity)
|
|
3340
|
+
// "line-gap-width": 4,
|
|
3280
3341
|
}
|
|
3281
3342
|
};
|
|
3282
3343
|
var isShow = true;
|
|
@@ -3297,6 +3358,20 @@
|
|
|
3297
3358
|
value: function set(option) {
|
|
3298
3359
|
deepMerge(this.option, option);
|
|
3299
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
|
+
});
|
|
3300
3375
|
for (var key in this.config) {
|
|
3301
3376
|
if (this.config.hasOwnProperty(key)) {
|
|
3302
3377
|
if (key == "paint") {
|
|
@@ -3524,7 +3599,7 @@
|
|
|
3524
3599
|
// 允许调整圆心
|
|
3525
3600
|
canMove: false,
|
|
3526
3601
|
// 设置非编辑状态下的图层颜色
|
|
3527
|
-
drawColor: option.outlineColor,
|
|
3602
|
+
// drawColor: option.outlineColor,
|
|
3528
3603
|
// 设置编辑状态下的图层颜色
|
|
3529
3604
|
// editColor: "red",
|
|
3530
3605
|
style: {
|
|
@@ -3532,7 +3607,13 @@
|
|
|
3532
3607
|
polygon: {
|
|
3533
3608
|
"fill-color": option.color,
|
|
3534
3609
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3535
|
-
"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)
|
|
3536
3617
|
}
|
|
3537
3618
|
},
|
|
3538
3619
|
// 编辑数据
|
|
@@ -3551,8 +3632,8 @@
|
|
|
3551
3632
|
var featureArr = {
|
|
3552
3633
|
type: "Feature",
|
|
3553
3634
|
properties: {
|
|
3554
|
-
centerPoint: option.position,
|
|
3555
|
-
radius: option.radius
|
|
3635
|
+
centerPoint: convertPosition(this.option.position),
|
|
3636
|
+
radius: this.option.radius
|
|
3556
3637
|
},
|
|
3557
3638
|
geometry: {
|
|
3558
3639
|
type: "Polygon",
|
|
@@ -3703,7 +3784,6 @@
|
|
|
3703
3784
|
key: "formatConfig",
|
|
3704
3785
|
value: function formatConfig(option) {
|
|
3705
3786
|
var RectanglePosition = createRectangleCoordinates(option.position[0], option.position[1]);
|
|
3706
|
-
console.log([RectanglePosition], "========RectanglePosition=======");
|
|
3707
3787
|
var config = {
|
|
3708
3788
|
id: option.id,
|
|
3709
3789
|
type: "fill",
|
|
@@ -3723,7 +3803,9 @@
|
|
|
3723
3803
|
paint: {
|
|
3724
3804
|
"fill-color": option.color,
|
|
3725
3805
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3726
|
-
"fill-opacity": Number(option.opacity)
|
|
3806
|
+
"fill-opacity": Number(option.opacity),
|
|
3807
|
+
"fill-antialias": true,
|
|
3808
|
+
"fill-outline-color": option.outlineColor
|
|
3727
3809
|
}
|
|
3728
3810
|
};
|
|
3729
3811
|
return config;
|
|
@@ -3907,7 +3989,7 @@
|
|
|
3907
3989
|
type: "Feature",
|
|
3908
3990
|
geometry: {
|
|
3909
3991
|
type: "Polygon",
|
|
3910
|
-
coordinates: option.position
|
|
3992
|
+
coordinates: convertPosition(option.position)
|
|
3911
3993
|
}
|
|
3912
3994
|
}]
|
|
3913
3995
|
}
|
|
@@ -3915,7 +3997,9 @@
|
|
|
3915
3997
|
paint: {
|
|
3916
3998
|
"fill-color": option.color,
|
|
3917
3999
|
// 填充颜色覆盖drawColor设置的颜色,呈现绿色
|
|
3918
|
-
"fill-opacity": Number(option.opacity)
|
|
4000
|
+
"fill-opacity": Number(option.opacity),
|
|
4001
|
+
"fill-antialias": true,
|
|
4002
|
+
"fill-outline-color": option.outlineColor
|
|
3919
4003
|
}
|
|
3920
4004
|
};
|
|
3921
4005
|
return config;
|
|
@@ -3932,7 +4016,7 @@
|
|
|
3932
4016
|
type: "Feature",
|
|
3933
4017
|
geometry: {
|
|
3934
4018
|
type: "Polygon",
|
|
3935
|
-
coordinates:
|
|
4019
|
+
coordinates: convertPosition(option.position) //三层数组[[[0,0],[0,0]]]
|
|
3936
4020
|
}
|
|
3937
4021
|
}]
|
|
3938
4022
|
});
|
package/package.json
CHANGED
package/src/base/siji_entity.ts
CHANGED
|
@@ -53,7 +53,7 @@ export default class siji_entity {
|
|
|
53
53
|
const data = this.option.data;
|
|
54
54
|
// const data = e.features[0].properties;
|
|
55
55
|
const dom = getCustomDom(data);
|
|
56
|
-
this.infoWindow.setHTML(
|
|
56
|
+
this.infoWindow.setHTML(dom);
|
|
57
57
|
this.infoWindow.setLngLat(e.lngLat).addTo(this.hnMap.map.map);
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -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
|
}
|