O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using ol.interaction.Modify to update drawing

The assignment will be quite simple because the component at the time of writing needs some refining. It's possible to edit content but there are no events to catch at the end of modification: we will be unable to save the modified features. We will cover the client as is.

  1. Copy the first sample 2360_08_01_simple_select.html as 2360_08_08_modify.html.
  2. Before var london, add the following code:
    var modify = new ol.interaction.Modify({
      features: selectInteraction.getFeatures()
    });
  3. Replace map.getInteractions().extend([selectInteraction]); with the following code:
    map.getInteractions().extend([selectInteraction, modify]);
  4. Add the following code to manage features change:
    var selected_features ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required