[Users] Remove layers from outside (not within a layertreepanel)

Morper-Busch, Lucia Lucia.Morper-Busch at sbg.ac.at
Sat Apr 2 08:17:13 CEST 2011


Hello GeoExt users,

 

I want to remove all layers from a map/layertree, that are no base layers. 

This is a listeners/select function of a combobox. The combobox is located in the bbar of a gridpanel. Afterwards I add some of the layers of a gridpanel (WMSCapabilitiesStore). That is fine (according to a example which adds layers from a gridpanel to the map). So the combobox must stay with the gridpanel.

But when the user selects another record of the combobox, I want to add other layers and remove all before added. I thought the easiest way is to remove all layers first and add the new ones.

When the function is executed by a button in a treepanel, there's no problem. (node.layer)

But from outside I get no access to the layers. The code below is my last of many trials, but to error says: Type mismatch. or Object doesn't support this property or method. I tried it also with mapPanel.layers.

Both tree.layerStore or mapPanel.layers  exist and are countable, so how do I loop through the layer list and point to each layer when the listener/handler is outside?

 

Ext.each(tree.layerStore, function(layer) {

     if ((layer)&&(!layer.isBaseLayer)){

          mapPanel.map.removeLayer(layer);

     }

})

 

Thank you for suggestions.

Lucia

 

Dipl.-Geogr. Lucia Morper-Busch | Researcher

University of Salzburg | Centre for Geoinformatics - Z_GIS

Schillerstr.30 | Techno-Z, Block 15, 3rd floor | 5020 Salzburg, Austria

Phone +43 (0)662 8044 5298 | Fax +43 (0)662 8044 5260

> Z_GIS...experts for the spatial view <http://www.zgis.at/research> 

 

Von: users-bounces at geoext.org [mailto:users-bounces at geoext.org] Im Auftrag von Vidal, Antoni
Gesendet: Freitag, 01. April 2011 15:30
An: users at geoext.org
Betreff: [Users] Use of setActiveItem

 

Hello list,

 

I cannot get the object to reference setActiveItem of Ext.Viewport layout property in order to expand an item.

 

My Ext.Viewport code:

 

                                               new Ext.Viewport({

                layout: "border",

                items: [{

                                                                              title: App.layout.titleLang,

                                                                              region: "center",

                    xtype: "gx_mappanel",

                                                                              id: "mappanel",

                    map: map,

                    layers: layerStore,

                    zoom: 11,

                                                                              tbar: createTbarItems(map)

                                                                              },{

                    title: "<img src=\"img/transparent22.png\"/>",

                    region: "west",

                    id: 'west-panel',

                    split: true,

                    width: 190,

                    minSize: 190,

                    maxSize: 300,

                    collapsible: true,

                    margins: '0 0 0 5',

                    layout: 'accordion',

                    layoutConfig:{

                        animate: true

                    },

                    items: [{...

 

I've tryed to get wit Ext.getCmp('mappanel'); but it doesn't work.

 

Any idea?

 

Thanks in advance

 

Antoni Vidal

Unitat d'Aplicacions SIG-WEB
Institut Cartogràfic de Catalunya <http://mercuri.icc.cat/website/mob_nf/mob1/mob2/inici2.htm?CONSULTA=Institut%20Cartogr%25E0fic%20de%20Catalunya&XYADDRESS=429486:4580392> 
Parc de Montjuïc, E-08038 Barcelona
Tel. (+34) 93 567 15 00 (ext. 3228)
www.icc.cat <http://www.icc.cat/> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110402/22e24d55/attachment-0001.htm 


More information about the Users mailing list