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.

I have basic WMS layer and vector layer in openlayers. Using EditingToolbar i can draw some features as shown below

enter image description here

Then I want to get some information (like distance and extent) of drawn features in any format.At the movement I stuck on above point. Pls give me some tips or sample code or some links.

Thanks for your valuable time

share|improve this question

2 Answers 2

up vote 0 down vote accepted

you can get vector layer extent:

vector.getDataExtent();

for getting features:

vector.features;

for getting first feature geometry:

vector.features[0].geometry.x
vector.features[0].geometry.y

for getting centroid of your first feature:

vector.features[0].geometry.getCentroid();

for getting first feature coordinate as string:

vector.features[0].geometry.toString();

for getting distance one point to another (it cant give geodetic result):

var p1 =   new OpenLayers.Geometry.Point(10,20);
var p2 =   new OpenLayers.Geometry.Point(30,40);

var distance = p1.distanceTo(p2)

i hope it helps you...

share|improve this answer

Use a SelectFeature control, and listen to featureselected events on the layer. The listener can use event.feature.geometry.getArea() to get the selected polygon's area, for example.

share|improve this answer
    
Yes ,Thanks for answer,can u give some sample codes or some links –  sacprasanna May 6 '12 at 16:05

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.