[OpenLayers-Users] DrawFeature and FeatureAdded event

Eric Lemoine eric.c2c at gmail.com
Tue Nov 25 01:34:28 EST 2008


Mika,

Sture registers a listener on the draw feature control's featureadded
event, not on the layer's. The former is triggered only when a feature
is added as a result of feature drawn by the user through the draw
feature control. The latter is triggered every time a feature is added
to the layer, whatever the way the feature was created.

Eric

2008/11/24, Lehtonen, Mika <mika at digikartta.net>:
> Hej Sture,
>
> I have a little bit similar application and I am using the following
> event handler. It seems to be working just fine.
> vlayer.events.on({"featureadded": offBuffer, "featureunselected":
> offBuffer});
> vlayer is the vector layer, offBuffer function for added feature event
> (+ for unselected feature).
>
> - mika -
>
> Sture Dingsøyr kirjoitti:
>> 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);
>> }
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>


More information about the Users mailing list