hn-map 1.1.13 → 1.1.15
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 +240 -82
- package/package.json +1 -1
- package/src/base/mars3d_entity.ts +0 -2
- package/src/base/siji_entity.ts +139 -118
- package/src/graphic/polygon.ts +1 -1
- package/src/layer/cluster.ts +421 -247
- package/src/layer/heatMap.ts +0 -3
- package/src/layer/layer.ts +30 -2
- package/src/layer/pointCloud.ts +4 -3
- package/src/map.ts +17 -18
- package/src/util.ts +200 -196
package/dist/index.js
CHANGED
|
@@ -392,24 +392,6 @@
|
|
|
392
392
|
return [leftTopPoint, rightTopPoint, rightBottomPoint, leftBottomPoint, leftTopPoint // 闭合矩形
|
|
393
393
|
];
|
|
394
394
|
}
|
|
395
|
-
function getMapRangeHeightByLevel(level) {
|
|
396
|
-
// 输入校验:限制在 1~18
|
|
397
|
-
level = Math.max(1, Math.min(18, Math.floor(level)));
|
|
398
|
-
// 计算指定 level 对应的高度(level >= 2 时使用指数衰减)
|
|
399
|
-
function getHeight(lvl) {
|
|
400
|
-
if (lvl === 1) {
|
|
401
|
-
return Infinity; // level=1 表示“最大高度”,逻辑上为无穷大
|
|
402
|
-
} else {
|
|
403
|
-
return 32000000 / Math.pow(2, lvl - 2);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
var endHeight = getHeight(level); // 当前 level 的“粗略”高度
|
|
407
|
-
var startHeight = level < 18 ? getHeight(level + 1) : 0; // 下一级更细
|
|
408
|
-
return {
|
|
409
|
-
startHeight: startHeight,
|
|
410
|
-
endHeight: endHeight
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
395
|
/**
|
|
414
396
|
* 根据 level 返回该层级的“中间高度”(几何平均值)
|
|
415
397
|
*
|
|
@@ -417,16 +399,19 @@
|
|
|
417
399
|
* @returns {number} 中间高度(米)
|
|
418
400
|
*/
|
|
419
401
|
function getLevelMiddleHeight(level) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
//
|
|
424
|
-
//
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
//
|
|
429
|
-
|
|
402
|
+
// const { startHeight, endHeight } = getMapRangeHeightByLevel(level);
|
|
403
|
+
// // 如果 startHeight 为 0(如 level=18),几何平均会为 0,不合理
|
|
404
|
+
// // 所以 level=18 特殊处理:返回 (0 + end)/2 或直接返回 end * 0.7 左右
|
|
405
|
+
// if (startHeight === 0) {
|
|
406
|
+
// return endHeight * 0.7; // 经验值,贴近“中间感知”
|
|
407
|
+
// }
|
|
408
|
+
//
|
|
409
|
+
// // 几何平均:√(start × end)
|
|
410
|
+
// return Math.sqrt(startHeight * endHeight);
|
|
411
|
+
var EARTH_RADIUS = 6378137; // 赤道半径
|
|
412
|
+
var height = 2 * Math.PI * EARTH_RADIUS / (256 * Math.pow(2, level));
|
|
413
|
+
console.log(height);
|
|
414
|
+
return height;
|
|
430
415
|
}
|
|
431
416
|
/**
|
|
432
417
|
* 根据高度反推 level(1~18)
|
|
@@ -538,6 +523,7 @@
|
|
|
538
523
|
deepMerge(this.option, option);
|
|
539
524
|
this.config = this.formatConfig(this.option);
|
|
540
525
|
this.map = new mars3d.Map(id, this.config);
|
|
526
|
+
console.log(this.config);
|
|
541
527
|
this.map.on("cameraMoveEnd", function (e) {
|
|
542
528
|
var height = _this.map.getCameraView().alt;
|
|
543
529
|
_this.level = getHeightToLevel(height);
|
|
@@ -904,7 +890,7 @@
|
|
|
904
890
|
lng: event.lngLat.lng,
|
|
905
891
|
lat: event.lngLat.lat,
|
|
906
892
|
alt: event.lngLat.alt || 0
|
|
907
|
-
});
|
|
893
|
+
}, event);
|
|
908
894
|
};
|
|
909
895
|
break;
|
|
910
896
|
case "dblclick":
|
|
@@ -1001,9 +987,9 @@
|
|
|
1001
987
|
}
|
|
1002
988
|
//添加天空图层
|
|
1003
989
|
instance.map.addLayer({
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
990
|
+
id: "sky",
|
|
991
|
+
type: "sky",
|
|
992
|
+
paint: {
|
|
1007
993
|
"sky-type": "atmosphere",
|
|
1008
994
|
"sky-atmosphere-sun": [0, 0],
|
|
1009
995
|
"sky-atmosphere-sun-intensity": 15
|
|
@@ -1082,6 +1068,15 @@
|
|
|
1082
1068
|
entity.start();
|
|
1083
1069
|
} else if (entity.type == "pointCloud" || entity.type == "heatMap") {
|
|
1084
1070
|
hnMap.map.map.addLayer(entity.layerEntity);
|
|
1071
|
+
} else if (entity.type == "cluster") {
|
|
1072
|
+
// 添加聚合图层到地图
|
|
1073
|
+
hnMap.map.map.addLayer(entity.layerEntity);
|
|
1074
|
+
// 如果已有位置数据,立即设置
|
|
1075
|
+
if (entity.option.position && entity.option.position.length > 0) {
|
|
1076
|
+
setTimeout(function () {
|
|
1077
|
+
entity.setPosition(entity.option.position);
|
|
1078
|
+
}, 100);
|
|
1079
|
+
}
|
|
1085
1080
|
} else {
|
|
1086
1081
|
this.layerEntity.addGraphic(entity.graphic); // 添加图形
|
|
1087
1082
|
}
|
|
@@ -1096,9 +1091,7 @@
|
|
|
1096
1091
|
return v.id !== entity.id;
|
|
1097
1092
|
});
|
|
1098
1093
|
if (entity.type === "pointCloud" || entity.type === "heatMap") {
|
|
1099
|
-
alert(entity.id);
|
|
1100
1094
|
hnMap.map.map.removeLayer(entity.id);
|
|
1101
|
-
// entity.id.destroy();
|
|
1102
1095
|
}
|
|
1103
1096
|
this.layerEntity.removeGraphic(entity.graphic);
|
|
1104
1097
|
}
|
|
@@ -1467,6 +1460,21 @@
|
|
|
1467
1460
|
duration: 2000,
|
|
1468
1461
|
essential: true
|
|
1469
1462
|
});
|
|
1463
|
+
} else if (entity.type == "cluster") {
|
|
1464
|
+
console.log("cluster=======", entity);
|
|
1465
|
+
hnMap.map.map.addLayer(entity.config_layer);
|
|
1466
|
+
hnMap.map.map.addLayer(entity.config_label);
|
|
1467
|
+
hnMap.map.map.loadImage(entity.option.image, function (error, image) {
|
|
1468
|
+
console.log("image======", image);
|
|
1469
|
+
entity.config_Image.layout["icon-size"] = entity.option.width / image.width;
|
|
1470
|
+
hnMap.map.map.addImage(entity.id + "_poiImage", image);
|
|
1471
|
+
hnMap.map.map.addLayer(entity.config_Image);
|
|
1472
|
+
});
|
|
1473
|
+
hnMap.map.map.flyTo({
|
|
1474
|
+
center: entity.option.position[0].position,
|
|
1475
|
+
duration: 2000,
|
|
1476
|
+
essential: true
|
|
1477
|
+
});
|
|
1470
1478
|
} else {
|
|
1471
1479
|
hnMap.map.map.addLayer(entity.config);
|
|
1472
1480
|
}
|
|
@@ -1775,17 +1783,23 @@
|
|
|
1775
1783
|
className: "my-popupAttr-class"
|
|
1776
1784
|
});
|
|
1777
1785
|
var handleClick = function handleClick(e) {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1786
|
+
var features = _this.hnMap.map.map.queryRenderedFeatures(e.point);
|
|
1787
|
+
if (features.length > 0) {
|
|
1788
|
+
// 当前点击的第一层图形为当前图形时,才满足点击事件
|
|
1789
|
+
if (features[0].layer.id === _this.id) {
|
|
1790
|
+
// const data = e.features[0].properties;
|
|
1791
|
+
var data = _this.option.data;
|
|
1792
|
+
// 创建弹窗内容
|
|
1793
|
+
var content = "";
|
|
1794
|
+
for (var key in data) {
|
|
1795
|
+
content += "<div>".concat(key, ": ").concat(data[key], "</div>");
|
|
1796
|
+
}
|
|
1797
|
+
_this.infoWindow.setHTML(content);
|
|
1798
|
+
_this.infoWindow.setLngLat(e.lngLat).addTo(_this.hnMap.map.map);
|
|
1799
|
+
}
|
|
1784
1800
|
}
|
|
1785
|
-
_this.infoWindow.setHTML(content);
|
|
1786
|
-
_this.infoWindow.setLngLat(e.lngLat).addTo(_this.hnMap.map.map);
|
|
1787
1801
|
};
|
|
1788
|
-
this.hnMap.map.map.on("click", this.
|
|
1802
|
+
this.hnMap.map.map.on("click", this.id, handleClick);
|
|
1789
1803
|
}
|
|
1790
1804
|
// 添加自定义dom弹窗
|
|
1791
1805
|
}, {
|
|
@@ -1800,13 +1814,19 @@
|
|
|
1800
1814
|
className: "my-customPopup-class"
|
|
1801
1815
|
});
|
|
1802
1816
|
var handleClick = function handleClick(e) {
|
|
1803
|
-
var
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1817
|
+
var features = _this2.hnMap.map.map.queryRenderedFeatures(e.point);
|
|
1818
|
+
if (features.length > 0) {
|
|
1819
|
+
// 当前点击的第一层图形为当前图形时,才满足点击事件
|
|
1820
|
+
if (features[0].layer.id === _this2.id) {
|
|
1821
|
+
var data = _this2.option.data;
|
|
1822
|
+
// const data = e.features[0].properties;
|
|
1823
|
+
var dom = getCustomDom(data);
|
|
1824
|
+
_this2.infoWindow.setHTML(dom);
|
|
1825
|
+
_this2.infoWindow.setLngLat(e.lngLat).addTo(_this2.hnMap.map.map);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1808
1828
|
};
|
|
1809
|
-
this.hnMap.map.map.on("click", this.
|
|
1829
|
+
this.hnMap.map.map.on("click", this.id, handleClick);
|
|
1810
1830
|
}
|
|
1811
1831
|
// 弹窗删除
|
|
1812
1832
|
}, {
|
|
@@ -1856,8 +1876,14 @@
|
|
|
1856
1876
|
this.off(eventType);
|
|
1857
1877
|
switch (eventType) {
|
|
1858
1878
|
case "click":
|
|
1859
|
-
this.event[eventType] = function () {
|
|
1860
|
-
|
|
1879
|
+
this.event[eventType] = function (e) {
|
|
1880
|
+
var features = _this3.hnMap.map.map.queryRenderedFeatures(e.point);
|
|
1881
|
+
if (features.length > 0) {
|
|
1882
|
+
// 当前点击的第一层图形为当前图形时,才满足点击事件
|
|
1883
|
+
if (features[0].layer.id === _this3.id) {
|
|
1884
|
+
callback(_this3.option.data);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1861
1887
|
};
|
|
1862
1888
|
break;
|
|
1863
1889
|
}
|
|
@@ -4061,7 +4087,7 @@
|
|
|
4061
4087
|
type: "Feature",
|
|
4062
4088
|
geometry: {
|
|
4063
4089
|
type: "Polygon",
|
|
4064
|
-
coordinates: convertPosition(option.position) //三层数组[[[0,0],[0,0]]]
|
|
4090
|
+
coordinates: convertPosition(this.option.position) //三层数组[[[0,0],[0,0]]]
|
|
4065
4091
|
}
|
|
4066
4092
|
}]
|
|
4067
4093
|
});
|
|
@@ -4754,9 +4780,6 @@
|
|
|
4754
4780
|
geometry: {
|
|
4755
4781
|
type: "Point",
|
|
4756
4782
|
coordinates: [v.lng, v.lat]
|
|
4757
|
-
},
|
|
4758
|
-
properties: {
|
|
4759
|
-
value: v.value
|
|
4760
4783
|
}
|
|
4761
4784
|
};
|
|
4762
4785
|
})
|
|
@@ -4861,7 +4884,7 @@
|
|
|
4861
4884
|
position: [],
|
|
4862
4885
|
pixelRange: 20,
|
|
4863
4886
|
cluster: true,
|
|
4864
|
-
image:
|
|
4887
|
+
image: "",
|
|
4865
4888
|
width: 20,
|
|
4866
4889
|
height: 20,
|
|
4867
4890
|
data: null
|
|
@@ -4871,7 +4894,7 @@
|
|
|
4871
4894
|
var _this;
|
|
4872
4895
|
_classCallCheck(this, mars3d_class);
|
|
4873
4896
|
_this = _callSuper(this, mars3d_class, [option]);
|
|
4874
|
-
_this.type =
|
|
4897
|
+
_this.type = "cluster";
|
|
4875
4898
|
_this.id = null;
|
|
4876
4899
|
_this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
4877
4900
|
_this.config_layer = null;
|
|
@@ -4881,9 +4904,11 @@
|
|
|
4881
4904
|
_this.id = option.id;
|
|
4882
4905
|
_this.children = [];
|
|
4883
4906
|
deepMerge(_this.option, option);
|
|
4907
|
+
console.log("option===", _this.option);
|
|
4884
4908
|
_this.config_layer = _this.formatConfigLayer(_this.option);
|
|
4885
4909
|
_this.config_label = _this.formatConfigLabel(_this.option);
|
|
4886
4910
|
_this.layerEntity = new mars3d.layer.GraphicLayer(_this.config_layer);
|
|
4911
|
+
// this.graphic = new mars3d.graphic.BillboardEntity(this.config_label);
|
|
4887
4912
|
return _this;
|
|
4888
4913
|
}
|
|
4889
4914
|
// 格式化layer配置
|
|
@@ -4894,8 +4919,37 @@
|
|
|
4894
4919
|
return {
|
|
4895
4920
|
id: option.id,
|
|
4896
4921
|
cluster: {
|
|
4897
|
-
enabled: option.cluster,
|
|
4898
|
-
|
|
4922
|
+
enabled: option.cluster !== false,
|
|
4923
|
+
// 默认开启聚合
|
|
4924
|
+
pixelRange: option.pixelRange || 20,
|
|
4925
|
+
// 添加更多聚合样式配置
|
|
4926
|
+
styles: [{
|
|
4927
|
+
scale: 1,
|
|
4928
|
+
image: "img/marker/mark1.png",
|
|
4929
|
+
label: {
|
|
4930
|
+
text: "{count}",
|
|
4931
|
+
color: "#ffffff",
|
|
4932
|
+
font_size: 16,
|
|
4933
|
+
stroke: true,
|
|
4934
|
+
strokeColor: "#000000"
|
|
4935
|
+
}
|
|
4936
|
+
}, {
|
|
4937
|
+
scale: 1.5,
|
|
4938
|
+
image: "img/marker/mark2.png",
|
|
4939
|
+
label: {
|
|
4940
|
+
text: "{count}",
|
|
4941
|
+
color: "#ffffff",
|
|
4942
|
+
font_size: 18
|
|
4943
|
+
}
|
|
4944
|
+
}, {
|
|
4945
|
+
scale: 2,
|
|
4946
|
+
image: "img/marker/mark3.png",
|
|
4947
|
+
label: {
|
|
4948
|
+
text: "{count}",
|
|
4949
|
+
color: "#ffffff",
|
|
4950
|
+
font_size: 20
|
|
4951
|
+
}
|
|
4952
|
+
}]
|
|
4899
4953
|
}
|
|
4900
4954
|
};
|
|
4901
4955
|
}
|
|
@@ -4904,7 +4958,7 @@
|
|
|
4904
4958
|
key: "formatConfigLabel",
|
|
4905
4959
|
value: function formatConfigLabel(option) {
|
|
4906
4960
|
return {
|
|
4907
|
-
id: option.id,
|
|
4961
|
+
id: "label_" + option.id,
|
|
4908
4962
|
image: option.image,
|
|
4909
4963
|
width: option.width,
|
|
4910
4964
|
height: option.height
|
|
@@ -4926,10 +4980,11 @@
|
|
|
4926
4980
|
key: "setPosition",
|
|
4927
4981
|
value: function setPosition(data) {
|
|
4928
4982
|
var _this2 = this;
|
|
4983
|
+
console.log("setPosition", data);
|
|
4929
4984
|
this.clearEntity();
|
|
4930
4985
|
data.forEach(function (item, index) {
|
|
4931
4986
|
var imagePointOption = {
|
|
4932
|
-
id: _this2.config_label.id +
|
|
4987
|
+
id: _this2.config_label.id + "_point" + item.id,
|
|
4933
4988
|
position: item.position,
|
|
4934
4989
|
image: _this2.config_label.image,
|
|
4935
4990
|
height: _this2.config_label.height,
|
|
@@ -4940,6 +4995,7 @@
|
|
|
4940
4995
|
_this2.addEntity(imagePoint);
|
|
4941
4996
|
});
|
|
4942
4997
|
}
|
|
4998
|
+
// 修改 cluster.ts 中的 mars3d_class 类
|
|
4943
4999
|
}, {
|
|
4944
5000
|
key: "destroy",
|
|
4945
5001
|
value: function destroy() {
|
|
@@ -5001,7 +5057,7 @@
|
|
|
5001
5057
|
key: "getEntity",
|
|
5002
5058
|
value: function getEntity(entityParam) {
|
|
5003
5059
|
var entity;
|
|
5004
|
-
if (typeof entityParam ==
|
|
5060
|
+
if (typeof entityParam == "string") {
|
|
5005
5061
|
entity = this.children.find(function (v) {
|
|
5006
5062
|
return v.id === entityParam;
|
|
5007
5063
|
});
|
|
@@ -5009,7 +5065,7 @@
|
|
|
5009
5065
|
entity = entityParam;
|
|
5010
5066
|
}
|
|
5011
5067
|
if (!entity) {
|
|
5012
|
-
return Promise.reject(new Error(
|
|
5068
|
+
return Promise.reject(new Error("未找到此图形"));
|
|
5013
5069
|
}
|
|
5014
5070
|
return entity;
|
|
5015
5071
|
}
|
|
@@ -5058,30 +5114,30 @@
|
|
|
5058
5114
|
lnglat: wgs84ToGcj02Format(item),
|
|
5059
5115
|
// 添加弹窗属性参数
|
|
5060
5116
|
extData: {
|
|
5061
|
-
id: _this5.id +
|
|
5117
|
+
id: _this5.id + "_point" + index
|
|
5062
5118
|
}
|
|
5063
5119
|
};
|
|
5064
5120
|
});
|
|
5065
5121
|
var count = position.length;
|
|
5066
5122
|
var _renderClusterMarker = function _renderClusterMarker(context) {
|
|
5067
5123
|
var factor = Math.pow(context.count / count, 1 / 18);
|
|
5068
|
-
var div = document.createElement(
|
|
5124
|
+
var div = document.createElement("div");
|
|
5069
5125
|
var Hue = 180 - factor * 180;
|
|
5070
|
-
var bgColor =
|
|
5071
|
-
var fontColor =
|
|
5072
|
-
var borderColor =
|
|
5073
|
-
var shadowColor =
|
|
5126
|
+
var bgColor = "hsla(" + Hue + ",100%,40%,0.7)";
|
|
5127
|
+
var fontColor = "hsla(" + Hue + ",100%,90%,1)";
|
|
5128
|
+
var borderColor = "hsla(" + Hue + ",100%,40%,1)";
|
|
5129
|
+
var shadowColor = "hsla(" + Hue + ",100%,90%,1)";
|
|
5074
5130
|
div.style.backgroundColor = bgColor;
|
|
5075
5131
|
var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20);
|
|
5076
|
-
div.style.width = div.style.height = size +
|
|
5077
|
-
div.style.border =
|
|
5078
|
-
div.style.borderRadius = size / 2 +
|
|
5079
|
-
div.style.boxShadow =
|
|
5132
|
+
div.style.width = div.style.height = size + "px";
|
|
5133
|
+
div.style.border = "solid 1px " + borderColor;
|
|
5134
|
+
div.style.borderRadius = size / 2 + "px";
|
|
5135
|
+
div.style.boxShadow = "0 0 5px " + shadowColor;
|
|
5080
5136
|
div.innerHTML = context.count;
|
|
5081
|
-
div.style.lineHeight = size +
|
|
5137
|
+
div.style.lineHeight = size + "px";
|
|
5082
5138
|
div.style.color = fontColor;
|
|
5083
|
-
div.style.fontSize =
|
|
5084
|
-
div.style.textAlign =
|
|
5139
|
+
div.style.fontSize = "14px";
|
|
5140
|
+
div.style.textAlign = "center";
|
|
5085
5141
|
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
|
|
5086
5142
|
context.marker.setContent(div);
|
|
5087
5143
|
};
|
|
@@ -5145,9 +5201,9 @@
|
|
|
5145
5201
|
offset: new AMap.Pixel(0, -30)
|
|
5146
5202
|
});
|
|
5147
5203
|
}
|
|
5148
|
-
this.layerEntity.on(
|
|
5204
|
+
this.layerEntity.on("click", function (cluster) {
|
|
5149
5205
|
if (cluster.clusterData.length === 1) {
|
|
5150
|
-
var content =
|
|
5206
|
+
var content = "";
|
|
5151
5207
|
var data = cluster.clusterData[0].extData;
|
|
5152
5208
|
for (var key in data) {
|
|
5153
5209
|
content += "<div>".concat(key, ": ").concat(data[key], "</div>");
|
|
@@ -5167,7 +5223,7 @@
|
|
|
5167
5223
|
offset: new AMap.Pixel(0, -30)
|
|
5168
5224
|
});
|
|
5169
5225
|
}
|
|
5170
|
-
this.layerEntity.on(
|
|
5226
|
+
this.layerEntity.on("click", function (cluster) {
|
|
5171
5227
|
if (cluster.clusterData.length === 1) {
|
|
5172
5228
|
var data = cluster.clusterData[0].extData;
|
|
5173
5229
|
var dom = getCustomDom(data);
|
|
@@ -5178,9 +5234,111 @@
|
|
|
5178
5234
|
}
|
|
5179
5235
|
}]);
|
|
5180
5236
|
}();
|
|
5237
|
+
var siji_class = /*#__PURE__*/function () {
|
|
5238
|
+
function siji_class(option) {
|
|
5239
|
+
_classCallCheck(this, siji_class);
|
|
5240
|
+
this.type = "cluster";
|
|
5241
|
+
this.id = null;
|
|
5242
|
+
this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
5243
|
+
this.config_layer = null;
|
|
5244
|
+
this.config_label = null;
|
|
5245
|
+
this.config_Image = null;
|
|
5246
|
+
this.layerEntity = null;
|
|
5247
|
+
// 创建全局信息窗口实例
|
|
5248
|
+
this.infoWindow = null;
|
|
5249
|
+
this.id = option.id;
|
|
5250
|
+
deepMerge(this.option, option);
|
|
5251
|
+
console.log("lalallalalalla======this.option", this.option);
|
|
5252
|
+
hnMap.map.map.addSource("themeData", {
|
|
5253
|
+
type: "geojson",
|
|
5254
|
+
data: {
|
|
5255
|
+
type: "FeatureCollection",
|
|
5256
|
+
features: this.option.position.map(function (v) {
|
|
5257
|
+
return {
|
|
5258
|
+
type: "Feature",
|
|
5259
|
+
geometry: {
|
|
5260
|
+
type: "Point",
|
|
5261
|
+
coordinates: convertPosition(v.position)
|
|
5262
|
+
},
|
|
5263
|
+
properties: {
|
|
5264
|
+
name: v.data.name
|
|
5265
|
+
}
|
|
5266
|
+
};
|
|
5267
|
+
})
|
|
5268
|
+
},
|
|
5269
|
+
cluster: true,
|
|
5270
|
+
clusterMaxZoom: 12,
|
|
5271
|
+
// 最大聚类层级
|
|
5272
|
+
clusterRadius: 100 // 聚合点半径,默认50
|
|
5273
|
+
});
|
|
5274
|
+
this.config_layer = this.formatConfigLayer(this.option);
|
|
5275
|
+
this.config_label = this.formatConfigLabel(this.option);
|
|
5276
|
+
this.config_Image = this.formatConfigImage(this.option);
|
|
5277
|
+
}
|
|
5278
|
+
return _createClass(siji_class, [{
|
|
5279
|
+
key: "formatConfigLayer",
|
|
5280
|
+
value: function formatConfigLayer(option) {
|
|
5281
|
+
return {
|
|
5282
|
+
id: "clusters_" + option.id,
|
|
5283
|
+
type: "circle",
|
|
5284
|
+
source: "themeData",
|
|
5285
|
+
filter: ["has", "point_count"],
|
|
5286
|
+
paint: {
|
|
5287
|
+
// 使用step表达式,用于分段匹配圆点的颜色和半径
|
|
5288
|
+
// 根据当前"point_count"值匹配对应的内容
|
|
5289
|
+
// 默认为"#9faebf"
|
|
5290
|
+
// 当大于10小于30时,返回"#3583de"
|
|
5291
|
+
// 大于30小于55时,返回"#04b71e"
|
|
5292
|
+
"circle-color": ["step", ["get", "point_count"], "#9faebf", 10, "#3583de", 30, "#04b71e", 55, "#ff9800", 100, "#f61402", 300, "#f61402"],
|
|
5293
|
+
"circle-radius": ["step", ["get", "point_count"], 20, 50, 30, 100, 35, 500, 35, 2000, 40, 5000, 40],
|
|
5294
|
+
"circle-opacity": 0.7,
|
|
5295
|
+
"circle-stroke-width": 3,
|
|
5296
|
+
"circle-stroke-color": "#ffffff"
|
|
5297
|
+
}
|
|
5298
|
+
};
|
|
5299
|
+
}
|
|
5300
|
+
}, {
|
|
5301
|
+
key: "formatConfigLabel",
|
|
5302
|
+
value: function formatConfigLabel(option) {
|
|
5303
|
+
return {
|
|
5304
|
+
id: "clusterCount_" + option.id,
|
|
5305
|
+
type: "symbol",
|
|
5306
|
+
source: "themeData",
|
|
5307
|
+
filter: ["has", "point_count"],
|
|
5308
|
+
layout: {
|
|
5309
|
+
"text-field": "{point_count_abbreviated}",
|
|
5310
|
+
"text-font": ["Microsoft YaHei Regular"],
|
|
5311
|
+
"text-size": 14
|
|
5312
|
+
},
|
|
5313
|
+
paint: {
|
|
5314
|
+
"text-color": "#ffffff"
|
|
5315
|
+
}
|
|
5316
|
+
};
|
|
5317
|
+
}
|
|
5318
|
+
}, {
|
|
5319
|
+
key: "formatConfigImage",
|
|
5320
|
+
value: function formatConfigImage(option) {
|
|
5321
|
+
return {
|
|
5322
|
+
id: "choicePoi_" + option.id,
|
|
5323
|
+
type: "symbol",
|
|
5324
|
+
source: "themeData",
|
|
5325
|
+
filter: ["!has", "point_count"],
|
|
5326
|
+
layout: {
|
|
5327
|
+
"icon-image": option.id + "_poiImage"
|
|
5328
|
+
},
|
|
5329
|
+
paint: {
|
|
5330
|
+
"text-color": "#555252",
|
|
5331
|
+
"text-halo-color": "#FFFFFF",
|
|
5332
|
+
"text-halo-width": 1.33333
|
|
5333
|
+
}
|
|
5334
|
+
};
|
|
5335
|
+
}
|
|
5336
|
+
}]);
|
|
5337
|
+
}();
|
|
5181
5338
|
var fn = {
|
|
5182
5339
|
mars3d: mars3d_class,
|
|
5183
|
-
gaode: gaode_class
|
|
5340
|
+
gaode: gaode_class,
|
|
5341
|
+
siji: siji_class
|
|
5184
5342
|
};
|
|
5185
5343
|
return fn[hnMap.mapType];
|
|
5186
5344
|
});
|
|
@@ -5312,6 +5470,7 @@
|
|
|
5312
5470
|
type: "custom",
|
|
5313
5471
|
renderingMode: "3d",
|
|
5314
5472
|
onAdd: function onAdd(map, gl) {
|
|
5473
|
+
console.log("map====", map);
|
|
5315
5474
|
this.camera = new THREE.Camera();
|
|
5316
5475
|
this.scene = new THREE.Scene();
|
|
5317
5476
|
var directionalLight = new THREE.DirectionalLight(0xffffff);
|
|
@@ -5323,8 +5482,7 @@
|
|
|
5323
5482
|
// var loader = new THREE.GLTFLoader();
|
|
5324
5483
|
var loader = new THREE.ObjectLoader();
|
|
5325
5484
|
var that = this;
|
|
5326
|
-
loader.load(
|
|
5327
|
-
// 'https://map.sgcc.com.cn/products/js-sdk/v3/assets/model/ZH-SZC3-42.gltf',
|
|
5485
|
+
loader.load('https://map.sgcc.com.cn/products/js-sdk/v3/assets/model/ZH-SZC3-42.gltf',
|
|
5328
5486
|
// function (gltf: any) {
|
|
5329
5487
|
function (object) {
|
|
5330
5488
|
that.scene.add(object);
|
package/package.json
CHANGED