我有一个显示在地图上的多段线阵列,现在我的目标是,当我将鼠标悬停在列表中的某条多段线上时,只有该多段线高亮显示(或更改颜色)。
我现在拥有的是这样的东西(这段代码位于一个循环中,该循环将使用单个折线数据填充polyLineArray,
var pointList = [];
// pointList is an array and lat/lngs
var polyLineProperties = {
color: 'red',
opacity: 1,
weight: 5,
clickable: true
}
var polyLine = new L.polyline(pointList, polyLineProperties);
polyLine.on('mouseover', function() {
// WHAT TO DO HERE to HIGHLIGHT that specific polyline.
});
polyLineArray.push(polyLine);
如何改变多段线的任何特性,而不仅仅是颜色?
好的,
很抱歉,但多亏了下面链接上的教程,我终于弄明白了这一点
交互式Choropleth地图
这就是所需要的,
polyLine.on('mouseover', function(e) {
var layer = e.target;
layer.setStyle({
color: 'blue',
opacity: 1,
weight: 5
});
});
感谢大家的阅读。