我花了4个多小时试图弄清楚如何做到这一点 . 我使用Leaflet和Leaflet Draw在我的 Map 上绘制新闻特征 .
现在我希望能够编辑现有WFS图层的功能(来自geoserver) .
我在互联网上搜索了很多,我找不到一个如何使我的WFS图层可编辑的明确例子 .
这是我根据here的例子做的:
// intialize the drawItems and add it to the map
var drawnItems = new L.FeatureGroup();
map_add.addLayer(drawnItems);
// initialize the controls (only editing) and add it to the map
var drawControl = new L.Control.Draw({
draw: {
position: 'topleft'
},
edit: {
featureGroup: drawnItems,
edit: true
}
}
});
map_add.addControl(drawControl);
url_string = "thats my url"
// make wfs request and add the layer in the drawItems
var geojson = $.ajax({
type: "GET",
dataType: "json",
url: url_string,
success: function (response) {
drawnItems.addLayer(L.geoJson(response));
}
});
图层显示在 Map 上 . 但是当我点击编辑按钮(传单绘制插件)时,我得到一个:
Cannot read property 'enable' of undefined
我究竟做错了什么?请指教!如果我按照我提供的链接中的示例进行操作 . 但他那里的人用他的代码内联数据 . 我需要使用WFS请求中的图层 .