I'm trying to incorporate a modify feature where the user will move a point and any underlying geometry is also modified. Currently to draw a route on a map I'm taking points from a database and creating a Feature for each(ol.geom.Point) and then pushing the same coordinates into an array for the underlying linestring. All of these are added to a Feature Collection so if there were 28 points in the database, there will be a feature collection with 29 items(28 points and a linestring).

The Select and Modify interactions are set to multi:true and this seems to occasionally allow me to select both the waypoint and the vertex point beneath but it's really hit and miss.

These are sample Modify Start/End functions:

session.interactions.modify.on('modifystart', function (e) {
        session.selectedFeatures = session.activeRoute.Layers[0].getSource().getFeatures();
        session.testArray = e.features.getArray();
        for (var p = 0; p < session.testArray.length; p++) {
             session.modifiedGuid = session.testArray[p].get('Guid');
             session.originalCoordinates = session.testArray[p].getGeometry().getCoordinates();

  session.interactions.modify.on('modifyend', function (e) {
         session.selectedFeatures = session.activeRoute.Layers[0].getSource().getFeatures();
         var lsRoute = session.selectedFeatures[session.selectedFeatures.length - 1];
                for (var p = 0; p < session.testArray.length; p++) {
                    session.modifiedCoordinates = session.testArray[p].getGeometry().getCoordinates();
                    updateModifiedGeom(session.modifiedGuid, session.originalCoordinates, session.modifiedCoordinates);

The updateModifiedGeom function was logging to the console the Guid, original, and modified coordinates but since I specified multi: true on the modify interaction it's no longer picking up these details, only the linestring array beneath.

I'm sorry if this seems a little garbled but I've been struggling for months to be able to display rich data points on a linestring and this is the only way I've been able to resolve it to any degree.

I'd previously posted this question which received no responses and I've managed to get this far but hopefully someone can tell me where I'm going wrong. I can't post a fiddle as it would take far too long to adapt the code to work in a stand-alone way.

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.