1***@163.com
1***@163.com
  • 发布:2023-02-25 22:07
  • 更新:2023-02-27 10:43
  • 阅读:373

makers 自定义点聚合微信小程序真机调试时,出现marker默认的红色图标

分类:uni-app

使用默认样式正常,图片如下:


自定义点聚合代码:

    // 监听聚合事件  
            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)  
                        }    
                })    
            })            
            },
2023-02-25 22:07 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

没配置 iconPath,会使用默认图标,你的问题是什么?

  • 1***@163.com (作者)

    没有配置 iconPath,已解决

    2023-02-27 14:02

要回复问题请先登录注册