[Users] LayerOpacitySlider: setLayer() does not work from ComboBox select event

Daniel Behr daniel.behr at hzg.de
Fri Aug 19 14:39:24 CEST 2011


Hello Everyone !

I'm having problems setting a new layer on the GeoExt LayerOpacitySlider 
with its setLayer method.

I have a ComboBox configured like this:

***
layerComboBox = new Ext.form.ComboBox({
     mode: "local",
     store: new GeoExt.data.LayerStore({
	layers: getVisibleLayersArray()
     }),
     listeners: {
	scope: map, // or: this
	select: function(combo,record){
  	    opacitySlider.setLayer(record.getLayer().params.ID)
	    })
	}
     },
     displayField: 'title',
     title: 'Transparency'
});
***

On the select event of this ComboBox I want to change the layer of this 
opacitySlider:

***
var opacitySlider = new GeoExt.LayerOpacitySlider({
         layer: null,
         aggressive: true,
         width: 150,
         inverse: true,
         plugins: new GeoExt.LayerOpacitySliderTip({
             template: "<div>{opacity}% transparent</div>"
         })
});
***

Both components work fine on their own and if I assign the setLayer() 
method to the maps zoomend or some other event, the slider layer is 
actually updated!

My guess is, that this is related to the GeoExt setLayer() function and 
the scope it is executed in.
I did some trial and error, without success.

I hope someone can shed some light on this...

thanks in advance!
Daniel
Helmholtz-Zentrum Geesthacht 
Zentrum für Material- und Küstenforschung GmbH 
Max-Planck-Straße 1 I 21502 Geesthacht I Deutschland/Germany 

Geschäftsführer/Board of Management: Prof. Dr. Wolfgang Kaysser, Dipl.-Ing. Michael Ganß 
Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board: MinDirig Wilfried Kraus 
Amtsgericht Lübeck HRB 285 GE (Register Court) 
Internet: http://www.hzg.de  


More information about the Users mailing list