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

Alexandre Dube adube at mapgears.com
Tue Sep 1 08:10:36 EDT 2009


Hi Max,

  Here's an old demo that could help you for some of your needs :

  http://dev4.mapgears.com/bdga/bdgaWFS-T.html

  Simply click on a feature.  This demonstrate a way to edit feature's 
attributes in a form.  If your data is stored in a DB, you don't need to 
take care of the id manually.  The DB will automatically generate one.

  The example is using WFS-T to TinyOWS connected to a PostGIS DB.

Best of luck,

Alexandre

Max Stephan wrote:
> 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
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list