please could someone help me and bless me with an example of how to get coordinates from a polygon in OpenLayers?
3 Answers
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....
-
Please could you maybe give me an example of this as I am stuck. Commented Feb 7, 2012 at 14:22
-
-
@BlakeLoizides Aragon has it right. This is how you get coordinates from a polygon. In your comment on this question thought it seems like you're having trouble with deleting a polygon now? if so it's a separate question which would merit a new question entry. Commented Feb 7, 2012 at 21:20
This is how to retrieve vertices:
PolygonLayer.features[0].geometry.getVertices();
GetVertices()
returns Polygon
points coordinates
-
3Can you improve (edit) your answer with further details? Thanks. Commented Oct 25, 2013 at 9:17