Monday 26 June 2017

polygon - OpenLayers: Get Coordinates of drawn features



Can someone help in finding coordinates of drawn features? I am using this example OpenLayers website. I need to be able to export drawn objects as set of coordinates.


Posting the code from the resource, although it can be found here.





Snap Interaction






















Answer



The drawn feature are added to the layer named vector. See draw interactions constructors.


// Get the array of features
var features = vector.getSource().getFeatures();


// Go through this array and get coordinates of their geometry.
features.forEach(function(feature) {
console.log(feature.getGeometry().getCoordinates());
});

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...