2014-10-22 70 views
3

似乎標題不言自明,但要詳細說明,這裏是我遇到的問題,我有一個折線陣列,我在地圖上顯示,現在我是什麼目標是當我將鼠標懸停在列表中的某條多段線上時,只有該多段線突出顯示(或更改顏色)。我現在所擁有的是這樣的(這個代碼是一個循環,去年底填充polyLineArray個別折線數據中,leafletjs:在鼠標懸停上突出顯示折線

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); 

希望有人能夠幫助我,這將是不錯 ,如果有人甚至諮詢如何改變折線的任何屬性,而不僅僅是顏色。

謝謝你,等待你的答覆:)

回答

6

好吧,

很抱歉,但我已經成功推測這一個,這要感謝教程以下鏈接,

Interactive Choropleth Map

這是所有被要求,

polyLine.on('mouseover', function(e) { 
    var layer = e.target; 

    layer.setStyle({ 
     color: 'blue', 
     opacity: 1, 
     weight: 5 
    }); 
}); 

謝謝大家閱讀。

相關問題