我尝试了很久 无论是下列哪种方式都不显示 要么显示一个正方形要么显示一个纯色(应该是紫色)的图片轮廓,我以为是itemstyle中的颜色吧图片覆盖住了,但去掉了也没用
// symbol:'image://'+this.img2,
// symbol:"path:/M2PoH7pgaNGNuz7。。。。。",
后来想了一个折中的办法,给textStyle添加背景图
img2:require('@/assets/abc.png'), // 图片路径
在option中使用的是geo3D,下面是其中的series
series:[
{
type: 'scatter3D',
coordinateSystem: 'geo3D',
data: this.labelData, // 定位点的数据 包含需要的名称和经纬度
itemStyle:{
borderColor:'transparent',
borderWidth:10,
color:"red",
// opacity:0,
},
silent: false,
label: {
show: true,
position: "top",
distance: -30,
formatter(params) {
return "2";
},
textStyle: {
color: "transparent",
padding: [25, 12],
backgroundColor: {
image: this.img2,
},
},
},
}
这样确实可以显示图片,但如果添加点击事件是 这个图片是无法点击的,只能点击图片正下方和地图交界处才可以