|
@@ -1360,7 +1360,7 @@ export default {
|
|
|
* 对外暴露:为指定子区路口列表绘制凸包多边形蒙层,点击不同子区时自动替换上一个
|
|
* 对外暴露:为指定子区路口列表绘制凸包多边形蒙层,点击不同子区时自动替换上一个
|
|
|
* @param {Array<{lng: number, lat: number}>} leaves - 子区内所有叶子路口节点
|
|
* @param {Array<{lng: number, lat: number}>} leaves - 子区内所有叶子路口节点
|
|
|
*/
|
|
*/
|
|
|
- drawSubAreaCircle(leaves) {
|
|
|
|
|
|
|
+ drawSubAreaCircle(leaves, label) {
|
|
|
if (!this.isMapReady() || !leaves || leaves.length === 0) return;
|
|
if (!this.isMapReady() || !leaves || leaves.length === 0) return;
|
|
|
|
|
|
|
|
this.clearSubAreaOverlays();
|
|
this.clearSubAreaOverlays();
|
|
@@ -1394,6 +1394,40 @@ export default {
|
|
|
|
|
|
|
|
this.subAreaOverlays.push(polygon);
|
|
this.subAreaOverlays.push(polygon);
|
|
|
this.map.add(polygon);
|
|
this.map.add(polygon);
|
|
|
|
|
+
|
|
|
|
|
+ // 在凸包重心位置显示子区名称(水印风格,字号随区域大小缩放)
|
|
|
|
|
+ if (label) {
|
|
|
|
|
+ // 用地图坐标转像素,精确计算区域在屏幕上的实际大小
|
|
|
|
|
+ const lngs = paddedHull.map(p => p[0]);
|
|
|
|
|
+ const lats = paddedHull.map(p => p[1]);
|
|
|
|
|
+ const topLeft = this.map.lngLatToContainer([Math.min(...lngs), Math.max(...lats)]);
|
|
|
|
|
+ const bottomRight = this.map.lngLatToContainer([Math.max(...lngs), Math.min(...lats)]);
|
|
|
|
|
+ const pixelW = Math.abs(bottomRight.x - topLeft.x);
|
|
|
|
|
+ const pixelH = Math.abs(bottomRight.y - topLeft.y);
|
|
|
|
|
+ // 字号以横向宽度为基准,按文字长度均分,确保不超出区域
|
|
|
|
|
+ const charCount = label.length || 1;
|
|
|
|
|
+ const fontSize = Math.min(Math.max(12, Math.round(pixelW / (charCount + 1))), 48);
|
|
|
|
|
+
|
|
|
|
|
+ const text = new this.AMap.Text({
|
|
|
|
|
+ text: label,
|
|
|
|
|
+ position: [cx, cy],
|
|
|
|
|
+ anchor: 'center',
|
|
|
|
|
+ zIndex: 11,
|
|
|
|
|
+ style: {
|
|
|
|
|
+ 'background': 'transparent',
|
|
|
|
|
+ 'border': 'none',
|
|
|
|
|
+ 'color': 'rgba(255, 255, 255, 0.25)',
|
|
|
|
|
+ 'font-size': `${fontSize}px`,
|
|
|
|
|
+ 'font-weight': 'bold',
|
|
|
|
|
+ 'padding': '0',
|
|
|
|
|
+ 'letter-spacing': '2px',
|
|
|
|
|
+ 'white-space': 'nowrap',
|
|
|
|
|
+ 'pointer-events': 'none',
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ this.subAreaOverlays.push(text);
|
|
|
|
|
+ this.map.add(text);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|