我正在尝试根据某些特征属性设置单个标记或大小为 1 的集群的样式。
var markers = L.markerClusterGroup();
function onEachFeature(feature, layer) {
if (feature.properties.EncounterType && feature.properties.Year) {
layer.bindPopup(feature.properties.EncounterType + " in " +
feature.properties.Year);
}
}
function style(feature) {
switch (feature.properties.EncounterType) {
case 'Shooting':
return {
color: "ff0000"
};
case 'Sighting':
return {
color: "0000ff"
};
case 'Hunting':
return {
color: "ff0000"
};
}
}
var geoJsonLayer = L.geoJSON(storer, {
onEachFeature: onEachFeature
}, {
style: style
});
markers.addLayer(geoJsonLayer);
map.addLayer(markers);
该onEachFeature
函数成功创建了弹出窗口。但是,样式函数不会改变大小为 1 的簇的颜色。我iconCreateFunction
在初始化标记簇组时尝试过使用,但是,这也不起作用。