[OpenLayers-Users] How to call a function that sets attributes for features added by drawfeature-control

Max Stephan x.zam at gmx.net
Tue Sep 1 06:18:55 EDT 2009


Hi list,

I´m actually implementing a drawfeature-control for my web-GIS. Everything´s
working fine so far but now I want to add a little more functionality:
- the user should be able to specify the appearance of the features he´s
adding. This shall only have an effect on the features he´s adding after
specifying the style (so a change of the general vectorlayer-Style is not
useful)
- each feature should get a unique ID whose format I´d like to specify and
which is generated by a script-wide counter for example

For both of this cases I thought of the event featureadded. But I´m having
some trouble with it. Here´s what I tried:

1. event-listener on the layer to which the features are added:

example: vectorLayer.events.register('featureadded', vectorlayer,
testFunction);

2. event-listener on the handler for drawfeature-control (same as above but
with vectorLayer being replaced by the drawfeature-control)

3. event-listener in this form:

vectorLayer.events.on("featureadded": testFunction, ...);

The testFunction is meant to specify the attributes like style, id etc. on
the feature that was added. The function is executed (tested it with an
alert).

The problem is that it´s not possible to select features on this layer (the
other vectorlayers are still working) when using the featureadded-listener.
But I need to be able to select features to modify it´s attributes later on
or to clear them via a form.

I also thought of using the create-callback of the point-handler but don´t
know how to implement it.

Any ideas and help is appreciated.
Thx in advance
Max Stephan
-- 
View this message in context: http://n2.nabble.com/How-to-call-a-function-that-sets-attributes-for-features-added-by-drawfeature-control-tp3559596p3559596.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list