3

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

1

3 Answers 3

4

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

3
  • Please could you maybe give me an example of this as I am stuck. Feb 7, 2012 at 14:22
  • @CaptDragon Question asked. lol. Feb 7, 2012 at 21:15
  • @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.
    – CaptDragon
    Feb 7, 2012 at 21:20
0

XXX.geometry.getVertices();

getVertices() returns the polygon POINT coordinates..

0

This is how to retrieve vertices:

PolygonLayer.features[0].geometry.getVertices();

GetVertices() returns Polygon points coordinates

1
  • 3
    Can you improve (edit) your answer with further details? Thanks. Oct 25, 2013 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.