0

我花了 4 个多小时试图弄清楚如何做到这一点。我使用 Leaflet 和 Leaflet Draw 在我的地图上绘制新闻功能。

现在我希望能够编辑现有 WFS 图层的功能(来自地理服务器)。

我在互联网上进行了很多搜索,但找不到一个清晰的示例来说明如何使我的 WFS 图层可编辑。

这是我根据此处的示例所做的:

// 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 请求中的图层。

4

0 回答 0