[OpenLayers-Users] how to deactivate editingtoolbar after featureadded

G. Allegri giohappy at gmail.com
Wed Jan 28 13:04:15 EST 2009


SOLUTION:

OpenLayers.Control.EditingToolbar.prototype.onClick = function (ctrl, evt) {
        	 <REDEFINED METHOD>
    		};
var panel = new OpenLayers.Control.EditingToolbar(vettoriale);

. Maybe there's a cleaner way... but now it works as expected


2009/1/28 G. Allegri <giohappy at gmail.com>:
> My last guess has been:
>
> var panel = new OpenLayers.Control.EditingToolbar(vettoriale);
> OpenLayers.Util.extend(panel,{
>                onClick: function (ctrl, evt) {
>                alert('ohoh');
>                }
>        });
>
> but still the original behaviour happens...
>
> 2009/1/28 G. Allegri <giohappy at gmail.com>:
>> Thansk Alexandre for the reply. This is not exatcly what I need to achieve.
>> A first step is:
>>
>>    OpenLayers.Event.stopObservingElement(panel.controls[i+1].panel_div);
>>
>> but the true behaviour I want is something like this:
>>
>>    panel.onClick = function fn(c,e){alert('only one feature admitted');}
>>
>> but this way to overload the panel's onClick method doesn't work....
>>
>>
>>
>>
>>
>>
>> 2009/1/28 Alexandre Dube <adube at mapgears.com>:
>>> Hi,
>>>
>>> Take a look at this example (1). Zoom in and out the map. You will see that
>>> the buttons completely disappear. That could be an other option to your
>>> issue.
>>>
>>> (1) http://dev4.mapgears.com/bdga/bdgaWFS-T.html
>>>
>>> Regards,
>>>
>>> Alexandre
>>>
>>> G. Allegri wrote:
>>>>
>>>> Sorry, I've sent too fast the solution. It works, but how can I
>>>> overload the onClick event on the control to alert the user with "a
>>>> feature has been already added"?
>>>> In this case I don't have to stop observing the click but I need to
>>>> handle it in a custom way...
>>>>
>>>> 2009/1/28 G. Allegri <giohappy at gmail.com>:
>>>>
>>>>>
>>>>> Solved (somehow...):
>>>>>
>>>>>      function locAdded(feature){
>>>>>               for(i=0;i<3;i++){
>>>>>                       panel.controls[i+1].deactivate();
>>>>>
>>>>> OpenLayers.Event.stopObservingElement(panel.controls[i+1].panel_div);
>>>>>               }
>>>>>       }
>>>>>
>>>>> giovanni
>>>>>
>>>>> 2009/1/28 G. Allegri <giohappy at gmail.com>:
>>>>>
>>>>>>
>>>>>> Hello list,
>>>>>> I'm using the editingtoolbar control panel. I need to disable it after
>>>>>> any feature has been added (point, line or polygon), and reactivate it
>>>>>> if the feature gets deleted.
>>>>>> I've seen that calling:
>>>>>>
>>>>>> function locAdded(feature){
>>>>>>               panel.controls[1].deactivate();
>>>>>>               panel.controls[2].deactivate();
>>>>>>               panel.controls[3].deactivate();
>>>>>> }
>>>>>>
>>>>>> deactivate the controls unitl the user click on the panel again...
>>>>>> this is not what I need. In fact the panel control has an onClick
>>>>>> handler that activate the control on which the onClick event has
>>>>>> happened (line 212 in Panel.js).
>>>>>> I've tried deactivating directly the panel, but the panel gets deleted.
>>>>>>
>>>>>> I need the panel to remain visible but "unclickable", until the unique
>>>>>> feature has been deleted from the layer.
>>>>>>
>>>>>> I've tried to overload the onClick panel's method, but I couldn't get
>>>>>> it to work...
>>>>>> Thanks for any hint.
>>>>>>
>>>>>> giovanni
>>>>>>
>>>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>>
>>>
>>>
>>> --
>>> Alexandre Dubé
>>> Mapgears
>>> www.mapgears.com
>>>
>>>
>>
>



More information about the Users mailing list