[GIS] How to get line and polygon points from OpenLayers 3 drawing

javascriptopenlayers

I am working on drawing points/segments/polygons on a map that uses OpenLayers 3. The first part I have done draws points, lines and polygons. Now I am trying to retrieve the drawn coordinates in order to build them for other sessions.

I have been able to getting just coordinate for the point/image, but can't get coordinates for segment/polygon. Any ideas or help? I've included a JSfiddle below

https://jsfiddle.net/Lg8w71kv

Best Answer

What you're looking for is the drawend event that is fired by the ol.interaction.Draw object you created. If you hook into it, you will get back the feature that has been drawn. See the fiddle below:

https://jsfiddle.net/Lg8w71kv/1/

Related Question