[OpenLayers-Users] Selectfeature after DrawFeature

Tanel Dovnar tanel.dovnar at gmail.com
Tue Jan 8 05:36:38 PST 2013


Hi,

I've seen same behaviour - it appeared only with point features.
After debugging OL, I gave up and used ugly solution with setTimeout.
You may try (without guarantee for success):

setTimeout('drawControl.deactivate();', 100);



On Tue, Jan 8, 2013 at 3:23 PM, Alexandre Dubé <adube at mapgears.com> wrote:

> 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<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<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<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<http://lists.osgeo.org/mailman/listinfo/openlayers-users>
>>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
> ______________________________**_________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/openlayers-**users<http://lists.osgeo.org/mailman/listinfo/openlayers-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130108/41c5ed0a/attachment.html>


More information about the Users mailing list