0

I have a polygon from a select feature event. I can see the polygon using firebug but I'm getting an error saying Type Error: getCentroid is not a function. Can anyone help please?

var poly = event.feature;
polyCentroid = poly.getCentroid();

1 Answer 1

1

Just try

poly.geometry.getCentroid() 

instead of

poly.getCentroid()

The "getCentroid()"-method is part of the feature geometry, not of the feature itself:

http://dev.openlayers.org/docs/files/OpenLayers/Geometry-js.html#OpenLayers.Geometry

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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