Search code examples
openlayerspostgisgeoserver

openlayers, how to get all modified features together from vector source


  1. I am trying to Edit and save features in openlayers. While doing so, I got stuck at one place where I want to get all modified features together from vector source. Is there any solution?

  2. Also suggest how can I implement feature audit functionality using openlayers, geoserver, postgis. Any solution available?


Solution

  • You have to listen to addfeature removefeature and changefeature events to get informed and store feature modifications.

    source.on ('changefeature', (e) => {
      // e.feature has changed
      // do something with it...
      e.feature._state = 'update';
    });
    

    Look at WFS-T and functions as writeTransaction to send modifications to server (https://openlayers.org/en/latest/apidoc/module-ol_format_WFS-WFS.html).