Hi,
Using Firebug, try putting a breakpoint on your first line of you
"added" function. You'll see that the "feature" argument is not a
feature, but rather an event containing your feature. Try :
added = function (event) {
var feature = event.feature;
var center=feature.geometry.getCentroid();
alert(center.x);
};
Regards,
Alexandre
On 11-01-05 01:52 PM, MightTower wrote:
Hello,
i try to get the center of a just drawn regular Polygon with the follwing
code:
added =function (feature)
{
var center=feature.geometry.getCentroid();
alert(center.x);
};
controls = {
regular: new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.RegularPolygon,
{eventListeners:{"featureadded":added},handlerOptions: {sides: 40}}),
drag: new OpenLayers.Control.DragFeature(vectors)
};
but the alert doesnt activate so there is a error. I think the argument
"feature" has not the type OpenLayers. Feature, but i cant find what exact
type feature has.
Is there perhaps a different way to get the center of the regular polygon?
Thanks a lot.
Marc
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users