[OpenLayers-Users] DrawFeature and FeatureAdded event

Sture Dingsøyr candalt at online.no
Mon Nov 24 09:49:01 EST 2008


Hi all

Have made a control in OL that allows the user to draw a regular polygon. Have also added an event that uses the "featureadded" event.

But...when the user only click in the map..a small polygon is drawed, but the event trigger is not fired..

If the user draws a "larger" polygon the trigger fires just fine...

Any suggestions?

My ol code is this:

var myVector = new OpenLayers.Layer.Vector("My vector");
map.addLayer(myVector);

var findRectangle = new OpenLayers.Control.DrawFeature(
	myVector,
	OpenLayers.Handler.RegularPolygon,
	{
		id: 'defaultControl01',
		title: "Klikk eller dra ut firkant rundt objekt i kartet for å finne mer informasjon",
		handlerOptions: {sides: 4, irregular: true},
		displayClass: 'findRectangle'            		
	}
);

findRectangle.events.register('featureadded', findRectangle, findRectangleFeaturAadded);

function findRectangleFeaturAadded(feature) {               
alert(feature);
}


More information about the Users mailing list