我尝试加载 geoJson 数据在 map 框 并使用插件编辑它 Leaflet.Draw
这是一个例子:fiddle
var featureGroup = L.featureGroup().addTo(map);
var geojson = {
"type": "FeatureCollection",
"features": [ ........... ]
}
L.geoJson(geojson).addTo(featureGroup);
当我单击编辑按钮时,出现错误:
Uncaught TypeError: Cannot read property 'enable' of undefined
对象似乎是 可编辑 但我不能修改它。
在 map 框中添加 geojson 对象的正确方法是什么 抽奖层 ?
最佳答案
我找到了解决方案:
L.geoJson(geojson, {
onEachFeature: function (feature, layer) {
featureGroup.addLayer(layer);
}
});
关于leaflet - 在 MapBox 中加载 geoJson 以使用 Leaflet.Draw 进行编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23892981/