Leaflet 带有自定义图标的传单超星系团标记?

Leaflet 带有自定义图标的传单超星系团标记?,leaflet,leaflet.markercluster,Leaflet,Leaflet.markercluster,使用时是否有方法更改默认标记图标 我遵循了演示中给出的示例。我能够让超级星团工作,并能够创建星团。但是单个标记具有默认的传单标记图标,该图标来自示例中的createClusterIcon方法 我有不同类型的标记,希望每个标记有不同的图标 超级集群使用具有pointToLayer功能的geoJSON层来创建集群图标。我们如何修改或自定义它来创建集群图标,并为每个标记创建自定义图标 createClusterIcon方法- function createClusterIcon(feature, la

使用时是否有方法更改默认标记图标

我遵循了演示中给出的示例。我能够让超级星团工作,并能够创建星团。但是单个标记具有默认的传单标记图标,该图标来自示例中的createClusterIcon方法

我有不同类型的标记,希望每个标记有不同的图标

超级集群使用具有pointToLayer功能的geoJSON层来创建集群图标。我们如何修改或自定义它来创建集群图标,并为每个标记创建自定义图标

createClusterIcon方法-

function createClusterIcon(feature, latlng) {
if (!feature.properties.cluster) return L.marker(latlng);

var count = feature.properties.point_count;
var abbrev = feature.properties.point_count_abbreviated;
var size =
    count < 100 ? 'small' :
    count < 1000 ? 'medium' : 'large';
var icon = L.divIcon({
    html: '<div><span>' + feature.properties.point_count_abbreviated + '</span></div>',
    className: 'marker-cluster marker-cluster-' + size,
    iconSize: L.point(40, 40)
});
return L.marker(latlng, {icon: icon});}
使用addData方法将标记添加到geoJSON层

markers.clearLayers();
markers.addData(e.data);

对代码的更集中的理解解决了这个问题

createClusterIcon函数中的if条件应用于创建自定义图标,该函数在功能不具有cluster属性时返回L.marker

我将if条件更改如下:

if (!feature.properties.cluster) {
            let icon = L.icon({
                iconUrl: '<icon_url>',
                iconSize: [40,40]
            })
            return L.marker(latlng, {
                icon: icon
            });

        }
if(!feature.properties.cluster){
让icon=L.icon({
iconUrl:“”,
iconSize:[40,40]
})
返回L.标记(板条{
图标:图标
});
}
现在,每个标记都有一个图标,由iconUrl表示

if (!feature.properties.cluster) {
            let icon = L.icon({
                iconUrl: '<icon_url>',
                iconSize: [40,40]
            })
            return L.marker(latlng, {
                icon: icon
            });

        }