2

I want to draw only one polygon, modify it and then save the polygon. I already do the saving. I'm not able to modify the polygon as it snaps.

Here is what I need but I'm not able to make it work. https://openlayers.org/en/latest/examples/draw-and-modify-features.html

This is my map:

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

This is the function that draws the polygon and then puts an end to it:

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();

    });


}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.