|
@@ -286,11 +286,22 @@ function setMapMarker() {
|
|
|
(map as any).centerAndZoom(new T.LngLat(114.416110, 23.111582), 10);
|
|
|
|
|
|
if (jobUserList.value.length > 0) {
|
|
|
+ let zoomLevel = (map as any).getZoom();
|
|
|
+ let newIconSize = Math.min(Math.max(zoomLevel * 3, 15), 45);
|
|
|
+ let iconAnchor = new T.Point(10 * (newIconSize / 45), 20 * (newIconSize / 45));
|
|
|
+ let offsetX = -20 + ((newIconSize - 45) / 3);
|
|
|
+ let offsetY = 28 + ((newIconSize - 45) / 3);
|
|
|
+ offsetX = Math.max(offsetX, -20);
|
|
|
+ offsetY = Math.min(offsetY, 28);
|
|
|
+ let newOffset = new T.Point(offsetX, offsetY);
|
|
|
+ let fontSize = Math.min(12, Math.max(8, 12 - (45 - newIconSize) / 3))
|
|
|
+
|
|
|
+
|
|
|
// 设置图标
|
|
|
const icon = new T.Icon({
|
|
|
iconUrl: thIcon,
|
|
|
- iconSize: new T.Point(20, 20),
|
|
|
- iconAnchor: new T.Point(10, 20)
|
|
|
+ iconSize: new T.Point(newIconSize, newIconSize),
|
|
|
+ iconAnchor: iconAnchor
|
|
|
})
|
|
|
|
|
|
// 筛选数据并统计相同点的总数
|
|
@@ -316,12 +327,12 @@ function setMapMarker() {
|
|
|
let label = new T.Label({
|
|
|
text: labelNumberCount.value + "", //文本标注的内容
|
|
|
position: new T.LngLat(114.416110, 23.111582), //文本标注的地理位置
|
|
|
- offset: new T.Point(-20, 23), //文本标注的位置偏移值
|
|
|
+ offset: newOffset, //文本标注的位置偏移值
|
|
|
});
|
|
|
label.setBackgroundColor("transparent");
|
|
|
label.setBorderColor("transparent");
|
|
|
label.setBorderLine(0);
|
|
|
- label.setFontSize(12);
|
|
|
+ label.setFontSize(fontSize);
|
|
|
label.setFontColor("white");
|
|
|
jobUserCountMarker.value = marker;
|
|
|
jobUserCountLabel.value = label;
|
|
@@ -334,12 +345,12 @@ function setMapMarker() {
|
|
|
let label = new T.Label({
|
|
|
text: item.count + "", //文本标注的内容
|
|
|
position: new T.LngLat(item.longitude, item.latitude), //文本标注的地理位置
|
|
|
- offset: new T.Point(-20, 23), //文本标注的位置偏移值
|
|
|
+ offset: newOffset, //文本标注的位置偏移值
|
|
|
});
|
|
|
label.setBackgroundColor("transparent");
|
|
|
label.setBorderColor("transparent");
|
|
|
label.setBorderLine(0);
|
|
|
- label.setFontSize(12);
|
|
|
+ label.setFontSize(fontSize);
|
|
|
label.setFontColor("white");
|
|
|
(map as any).addOverLay(marker);// 将标注添加到地图中
|
|
|
(map as any).addOverLay(label);// 将标注添加到地图中
|