Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
possible duplicate of Openlayers get coordinates of a circle vector after draw –  iant Feb 7 '12 at 12:16
add comment

3 Answers

up vote 4 down vote accepted

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

share|improve this answer
    
Please could you maybe give me an example of this as I am stuck. –  Blake Loizides Feb 7 '12 at 14:22
    
@CaptDragon Question asked. lol. –  Blake Loizides Feb 7 '12 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 '12 at 21:20
add comment

XXX.geometry.getVertices();

GetVertices returns the polygon POINT coordinates..

share|improve this answer
add comment
PolygonLayer.features[0].geometry.getVertices();

GetVertices() returns Polygon points coordinates

share|improve this answer
3  
Can you improve (edit) your answer with further details? Thanks. –  afalciano Oct 25 '13 at 9:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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