function onEachFeature(feature, layer) { layer.on({ mouseover: highlightFeature,//鼠標移入事件 mouseout: resetHighlight,//鼠標移出事件 click: zoomToFeature//鼠標點擊事件 }); }
let geoJsonLayer = L.geoJson(coordinates, { style: style, pane: pane, onEachFeature: (feature, layer) => {//onEachFeature回調 關鍵方法
if (onEachFeature) {
onEachFeature(feature, layer); }
}
}).addTo(this.editLayer);