繁体   English   中英

Google Maps API-标记群集样式会阻止图像显示?

[英]Google Maps API - Marker Cluster Styles Prevent Image From Showing?

我有一个问题想要更改标记群集上的字体大小和颜色,但是添加样式会阻止图像显示? 如果我注释掉样式部分,则图像显示正确。

const cluster = new MarkerClusterer(this.map, this.map_markers, {
    imagePath: site_settings.template_directory + '/assets/images/marker-clusterer/m',
    styles:[{
        textSize: 12,
        textColor: 'white'
    }],
    maxZoom: this.map_max_zoom - 1,
    zoomOnClick: true
})

如何将样式添加到标记中,但保留正在使用的图像?

根据上述克里斯蒂安·科瓦切夫(Kristiyan D Kovachev)的建议,已解决。

new MarkerClusterer(this.map, this.map_markers, {
    styles:[{
        url: site_settings.template_directory + '/assets/images/marker-clusterer/m1.png',
        textSize: 12,
        width: 42,
        height: 42,
        textColor: 'white'
    }],
    maxZoom: this.map_max_zoom - 1,
    zoomOnClick: true
})  

根据MarkerCluster库GitHub ,样式对象需要一个覆盖imagePathURL

解:

new MarkerClusterer(this.map, this.map_markers, {
    styles:[{
        url: site_settings.template_directory + '/assets/images/marker-clusterer/m1.png',
        textSize: 12,
        width: 42,
        height: 42,
        textColor: 'white'
    }],
    maxZoom: this.map_max_zoom - 1,
    zoomOnClick: true
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM