2
因爲我使用$ .getJSON調用數據,所以我無法刪除地圖上的高光。 當我使用基本地圖(http://www.vegactu.com/m1/europe_abattoir/)的所有作品,但是當我使用Jquery調用geojson文件(而不是使用var = {json}的leaflet json模板)時,高亮不會被刪除。Geojson(GetJSON)並在小冊子上刪除Higlight(鼠標移出)
什麼不起作用的例子(你可以看到它:http://vegactu.com/m1/europe_abattoir/test1.html) 我認爲它來自函數resetHighlight(e),但我無法解決它。
function styleeurope(feature) {
return {
weight: 1.5,
color: '#222',
opacity:0.5,
fillOpacity: 0.7,
fillColor: getColor(feature.properties.statTOTAL)
};
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 3,
color: 'black',
opacity: 0.7,
dashArray: '0',
fillOpacity: 0.5,
fillColor: '#fff200',
});
info.update(layer.feature.properties);
}
//復位亮點//
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
// OnEachFeature
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
});
}
// GeoJSON的呼叫數據//
$.getJSON("data/europe_fao.json",function(dataeurope){ var geojson = L.geoJson(dataeurope,{
style: styleeurope,
onEachFeature: onEachFeature}).addTo(map); });
太感謝你了,如果你設法幫助我!
你檢查'mouseout'射擊?嘗試在你的'geojson'對象上註冊'mouseout'事件。 –
非常感謝Jonatas!我解決了它併發布了一個答案。 –
我很高興聽到。 –