[GIS] How to programatically initiate LineString Draw in OpenLayers 3

openlayers

I am trying to activate draw and place the first point when a action is clicked on a feature. This will then create a single line string to the next point where the marker will move to.

However I am having issues initiating the draw feature start point programatically so that my next click would be the second and final point of the line string.

I have tried implementing using:

 function startmove(coords) {

 interaction = new ol.interaction.Draw({
                        type: 'LineString',
                        createFeature: coords,
                        source: source
                    });
  map.addInteraction(interaction);

 }

Does anyone have any ideas on how to achieve this?

Best Answer

Have a look for ol3 example for creating and editing feature