在IOS下,聚合点的marker如果没有设置iconPath,就会出现这种情况,虽然设置了width,height为0,但是在ios下不生效,所以转换了下思路,换一个透明图片替换iconPath,下面是效果图
clusterMarkers = clusters.map(cluster => {
const { center, clusterId, markerIds } = cluster;
return {
...center,
width: 0,
height: 0,
clusterId,
joinCluster: isJoinCluster.value, //核心代码,没有这个自定义样式就不会生效
***iconPath: '/static/device/transparent.png',***
label: {
content: markerIds.length + '',
fontSize: 14,
color: '#fff',
width: 32,
height: 32,
bgColor: '#FF7D00',
borderRadius: 16,
textAlign: 'center',
anchorX: -16,
anchorY: -32,
},
};
});
console.log('聚合点', clusterMarkers);
mapContext.value?.addMarkers({
markers: clusterMarkers,
clear: false,
});