Leaflet 如何在传单API中更新featuregroup中的相关图层样式
我正在尝试使用传单API为featureGroup中的相关层设置样式,以下是我的代码:Leaflet 如何在传单API中更新featuregroup中的相关图层样式,leaflet,Leaflet,我正在尝试使用传单API为featureGroup中的相关层设置样式,以下是我的代码: var highlightStyle = { color: '#9b1d41', weight: 3, opacity: 0.6, fillOpacity: 0.65, fillColor: '#9b1d41' }; $wnd.mapareas.eachLayer(function(layerOnMap) { layerOnMap.setStyle(high
var highlightStyle = {
color: '#9b1d41',
weight: 3,
opacity: 0.6,
fillOpacity: 0.65,
fillColor: '#9b1d41'
};
$wnd.mapareas.eachLayer(function(layerOnMap) {
layerOnMap.setStyle(highlightStyle);
console.log(layerOnMap);
});
我可以在日志中看到图层有了新的设置样式,但它在地图上不可见,就像颜色没有改变一样 对于GeoJSON层(功能组),您可以这样做
new L.GeoJSON(mp, {
style: highlightStyle
});
对于标准功能组
new L.FeatureGroup([mp1, mp2]).setStyle(highlightStyle);