我花了4个多小时试图找出如何做到这一点。 我使用Leaflet和Leaflet Draw在我的地图上绘制新闻特征。
现在我希望能够编辑现有WFS图层的功能(来自地理服务器)。
我在互联网上搜索了很多,我找不到如何使我的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));
}
});
图层显示在地图上。但是当我点击编辑按钮(传单绘制插件)时,我得到了一个:
Cannot read property 'enable' of undefined
我做错了什么? 请指教! 如果我按照我提供的链接中的示例进行操作。但他那里的人用他的代码内联数据。我需要使用WFS请求中的图层。