Sunday 21 April 2019

javascript - Openlayers get coordinates from polygon



please could someone help me and bless me with an example of how to get coordinates from a polygon in OpenLayers?



Answer



you can get the coordinates of your shape as below code:


vectorLayer.features[i].geometry.getBounds();

and also you can get covered area, centroid of your shape, vertices of ypur shape, length or geodesic area.


if you want specific feature bounds, you can write order of your feature [i] place like this:


vectorLayer.features[3].geometry.getBounds();

and below code will give all bounds of your features example :



var ft = vectorLayer.features;
for(var i=0; i< ft.length; i++){
console.log(vectorLayer.features[i].geometry.getBounds());
};

I hope that will be useful for you....


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...