绘制并修改多边形

问题描述:

我只想绘制一个多边形,对其进行修改,然后保存该多边形。我已经做了保存。我无法修改多边形,因为它捕捉。绘制并修改多边形

这是我需要的,但我无法使它工作。 https://openlayers.org/en/latest/examples/draw-and-modify-features.html

这是我的地图:

function map() { 
    map = new ol.Map({ 
      controls: ol.control.defaults({ 
     attributionOptions: ({ 
     collapsible: true 
     }) 
    }).extend([ 
     scaleLineControl, new escalaControl(), new quitarContorno() 
    ]), 
    logo: false,     /* es global */ 
    layers: layers, 
    target: 'map', 
    view: new ol.View({ 
     center:ol.proj.fromLonLat([-61.530766,-34.865575]), 
     zoom: 7 
    }) 

    }); 
} 

这是绘制多边形的功能,然后杜绝了它:

function addInteraction() { 

    var value = "polygon"; 
    noDraw(); 
    draw = new ol.interaction.Draw({ 
      source: source, 
      type: "Polygon", 
     }); 

     map.addInteraction(draw); 

     draw.on('drawend', function(evt){ 
      var feature = evt.feature; 
      var p = feature.getGeometry(); 
      var format = new ol.format.WKT(); 

      poligonoWKT = format.writeGeometry(p.transform(ol.proj.get('EPSG:3857'),ol.proj.get('EPSG:4326'))); 
      p.transform(ol.proj.get('EPSG:4326'),ol.proj.get('EPSG:3857')); 
      console.log(poligonoWKT); 

      noDraw(); 

      $("#listgrouparea").show(); 
      getArea(); 

     }); 


    } 

添加修改控制。

var modify = new ol.interaction.Modify({source: source}); 
     map.addInteraction(modify); 

否则,用您的代码发布codepen。