繁体   English   中英

使用angular-leaflet-directive时如何自定义markercluster图标

[英]How to customize markercluster icon when using angular-leaflet-directive

Leaflet文档概述了一种使用iconCreateFunction指定MarkerClusterGroup的方法,您可以在其中自定义群集图标的外观。 我想知道是否有通过angular-leaflet指令公开的东西也可以执行此操作,或者是否有一种使用指令降低到较低级Leaflet API的方法。 基本上,我只是尝试更改颜色更改的值,而不是10和100,我也希望更改图标的直径为不同的值。 与Google MarkerClusterer类似。

谢谢

在您指定标记集群的叠加层中,可以添加选项。 就像是:

layerOptions: {
                            showCoverageOnHover: false,
                            disableClusteringAtZoom: 12,
                            iconCreateFunction: function (cluster) {
                                    var childCount = cluster.getChildCount();

                                    var c = ' marker-cluster-';
                                    if (childCount < 10) {
                                        c += 'small';
                                    } else if (childCount < 100) {
                                        c += 'medium';
                                    } else {
                                        c += 'large';
                                    }

                                    return new L.DivIcon({ html: '<div><span>' + "CUSTOM" + '</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
                                }
                        }

暂无
暂无

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

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