[OpenLayers-Users] Selectfeature after DrawFeature

Alexandre Dubé adube at mapgears.com
Tue Jan 8 05:23:48 PST 2013


Hello Marco,

   Here's an old 2009 demo featuring the behaviour I explained (click on 
the image to see the live demo) :
     http://labs.mapgears.com/en/archive/bdga-wfst

   Select the (+) button and draw a line.  Once completed, you'll see 
that the draw control gets deactivated and the select control gets 
activated and selects the newly drawn feature.  See the source code, 
search for "roadFeatureAdded" :
   http://dev4.mapgears.com/bdga/bdgaRoads.js

   I'd be glad if that could help you.

Cheers,

Alexandre


On 13-01-08 05:41 AM, Marco Scheuble wrote:
> Hi Alexandre,
>
> I tried your solution, but unfortunately it doesn't work for me ( OL 2.12 ).
> Indeed, the feature will be selected, but somehow afterwards it will be
> automatically unselected.
> In my code-example both alerts will be run: "selected" and "unselected"
>
> cheers, Marco
> --------------------------------------------------------
> selectControl = new OpenLayers.Control.SelectFeature( pois, { onSelect:
> onFeatureSelect, onUnselect: onFeatureUnselect } );
>
> drawControl = new OpenLayers.Control.DrawFeature( pois,
> OpenLayers.Handler.Point);
> drawControl.events.on( {'featureadded': onFeatureAdded, scope: this });
>
> function onFeatureAdded( addedFeature ){
>    addedFeature.feature.state = OpenLayers.State.INSERT;
>    selectControl.activate();
>    drawControl.deactivate();
>    selectControl.select( addedFeature.feature );
> }
>
> function onFeatureSelect( feature ) { alert( "selected" ); }
> function onFeatureUnselect( feature ) { alert( "unselected" ); }
> --------------------------------------------------------
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Selectfeature-after-DrawFeature-tp5018519p5026116.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users


-- 
Alexandre Dubé
Mapgears
www.mapgears.com



More information about the Users mailing list