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

gbrun gbrun at myopera.com
Thu Sep 8 14:15:44 CEST 2011


You're right! Wrong function!

I currently use this one:

toggleHandler: function (button, state){
	if (state == true){
	  ********
	}else{
	  ********
	}
}

Geoffrey


On Thu, 08 Sep 2011 14:06:32 +0200, Kai Volland <kaivolland at web.de> wrote:

> 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
>>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Users mailing list