[Users] GeoExt.Action (Button) to show/hide Layer

Kai Volland kaivolland at web.de
Thu Sep 8 14:06:32 CEST 2011


Thx Geoffrey!

Problem 1 and 2 are solved.
But the third one still doesn't work. Is this function with "toggled" 
the right way?

Kai


Am 08.09.2011 13:20, schrieb gbrun:
> You try to use a GeoExt action. For this, you need to define an OpenLayers
> control. That's why you received this 'undefined' message.
>
> Instead of GeoExt action, try to use a classic Ext button and it should
> work (only if you don't have any OpenLayers control). For the "checked"
> problem, I think you can use "pressed" instead.
>
> Geoffrey
>
>
> On Thu, 08 Sep 2011 12:05:44 +0200, Kai Volland<kaivolland at web.de>  wrote:
>
>> Hi Users,
>>
>> i've some issues with using a Button to show/hide a Layer in my map.
>>
>> 1. "checked:true" doesn't work
>> 2. I get an error whne first check and uncheck the button:
>>               this.control is undefined
>>                    this.control.activate();
>>               this.control is undefined
>>                    this.control.deactivate();
>>
>> 3. Afterwards the button seems to work, but unchecking it doesn't affect
>> the Layer (it stays visible).
>>
>> CODE:
>>       var action1 = new GeoExt.Action({
>>           text: 'Sites',
>>           map: map,
>>           tooltip: 'NESPOS - SITES',
>>           enableToggle: true,
>>           handler: function(toggled){
>>               if (toggled) {
>>                   nespos.setVisibility(true);
>>               } else {
>>                   nespos.setVisibility(false);
>>               }
>>           },
>>           checked: true
>>       });
>>       actions["Sites"] = action1;
>>       toolbarItems.push(action1);
>>       toolbarItems.push("-");
>>
>>
>> Kind regards,
>>
>> Kai
>



More information about the Users mailing list