更改折线选项传单
Change polyline options leaflet
我想在构建后更改分配给 Leaflet 多段线(然后渲染它)的选项:
// Add polyline
var polyline = L.polyline([], {weight:weight, opacity:1, color:'gray'}).addTo(map);
// Attempts to change color
polyline.options.color = 'blue' // doesn't render
polyline.options.color('blue') // throws error
polyline({color:'blue'}) // throws error
polyline._updateStyle(polyline) // throws error: not sure how exactly this works
polyline._updateStyle() // throws error
polyline({color:blue}) // throws error
这可能吗?
L.Polyline
是从 L.Path
扩展而来的 setStyle
方法:
polyline.setStyle({
color: 'black'
});
我想在构建后更改分配给 Leaflet 多段线(然后渲染它)的选项:
// Add polyline
var polyline = L.polyline([], {weight:weight, opacity:1, color:'gray'}).addTo(map);
// Attempts to change color
polyline.options.color = 'blue' // doesn't render
polyline.options.color('blue') // throws error
polyline({color:'blue'}) // throws error
polyline._updateStyle(polyline) // throws error: not sure how exactly this works
polyline._updateStyle() // throws error
polyline({color:blue}) // throws error
这可能吗?
L.Polyline
是从 L.Path
扩展而来的 setStyle
方法:
polyline.setStyle({
color: 'black'
});