更改 Leaflet 折线选项

14
我想在构建后更改分配给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

这是可能的吗?
1个回答

26

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接