我已将 Geojson 图层添加到 Leaflet 的 basemap 中。我使用以下事件来获取 map 数据和图层数据:
map.on('mousemove', function (e) {
console.log(e);
});
它给了我以下日志:
当我将鼠标悬停在 Geojson 图层上时,我找不到任何有关该图层的信息(目标中没有关于该图层的信息)。
有没有人能解决这个问题?
最佳答案
以下是获取Geojson图层信息的代码:
$.ajax({
dataType: "json",....
onEachFeature: function (feature, layer) {
layer.on('mousemove', function (event) {
console.log(event);
});
}
});
关于javascript - 将鼠标悬停在 Leaflet 中的 map 时获取图层信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54185034/