使用默认样式正常,图片如下:
自定义点聚合代码:
// 监听聚合事件
this._mapContext.on('markerClusterCreate',res=>{
console.log('markerClusterCreate',res)
let clusterMarkers = []
const clusters = res.clusters
clusters.map(cluster => {
const {
center,
clusterId,
markerIds
} = cluster
let clusterObj = {
...center,
width: 0,
height: 0,
clusterId,
// iconPath: ``,
joinCluster: true,
label: {
content: markerIds.length + '',
fontSize: 16,
color: '#fff',
width: 30,
height: 30,
bgColor: '#5500ff',
borderRadius: 25,
textAlign: 'center',
anchorX: 0,
anchorY: 0,
}
}
clusterMarkers.push(clusterObj)
})
console.log(clusterMarkers)
// 添加聚合簇
that._mapContext .addMarkers({
markers: clusterMarkers,
clear: false, //是否先清空地图上所有的marker
complete(res) {
console.log('监听聚合事件addMarkers', res)
}
})
})
},
1***@163.com (作者)
没有配置 iconPath,已解决
2023-02-27 14:02