<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi,<br>
<br>
I just tested your code and modified a bit<br>
<br>
Ext.each(mapPanel.map.layers, function(layer) {<br>
if ((layer)&&(!layer.isBaseLayer)){<br>
mapPanel.map.removeLayer(layer);<br>
}<br>
});<br>
<br>
In my case this works well.<br>
<br>
Best regards,<br>
Chris<br>
<br>
<br>
Am 02.04.2011 08:17, schrieb Morper-Busch, Lucia:
<blockquote
cite="mid:7506863B0141334AA8B9FAAAC6D703B001F6B49D@MAIL2.plus.sbg.ac.at"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">Hello GeoExt users,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">I want to remove all layers from a
map/layertree, that are no base layers. <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">This is a listeners/select function of a </span><span
style="font-family: "Courier New";" lang="EN-US">combobox</span><span
lang="EN-US">. The combobox is located in the </span><span
style="font-family: "Courier New";" lang="EN-US">bbar</span><span
lang="EN-US"> of a </span><span style="font-family:
"Courier New";" lang="EN-US">gridpanel</span><span
lang="EN-US">. 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.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">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.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">When the function is executed by a button in a
</span><span style="font-family: "Courier New";"
lang="EN-US">treepanel</span><span lang="EN-US">, there’s no
problem. (</span><span style="font-family: "Courier
New";" lang="EN-US">node.layer</span><span lang="EN-US">)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">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 </span><span
style="font-family: "Courier New";" lang="EN-US">mapPanel.layers.</span><span
lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
lang="EN-US">Both</span><span style="font-family:
"Courier New";" lang="EN-US"> tree.layerStore</span><span
lang="EN-US"> or </span><span style="font-family:
"Courier New";" lang="EN-US">mapPanel.layers</span><span
lang="EN-US"> exist and are countable, so how do I loop
through the layer list and point to each layer when the
listener/handler is outside?<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";" lang="EN-US">Ext.each(tree.layerStore,
<b><i><span style="color: rgb(0, 32, 96);">function</span></i></b>(layer)
{<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";" lang="EN-US">
<b><i><span style="color: rgb(0, 32, 96);">if</span></i></b><span
style="color: rgb(0, 32, 96);"> </span>((layer)<b>&&</b>(!layer.isBaseLayer)){<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";" lang="EN-US">
mapPanel.map.removeLayer(layer);<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";" lang="EN-US">
</span><span style="font-family: "Courier New";">}<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-family: "Courier New";">})<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 1pt;">Thank you for
suggestions.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 1pt;">Lucia<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><b><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: rgb(54,
95, 145);" lang="EN-US">Dipl.-Geogr. Lucia Morper-Busch</span></b><b><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: rgb(31,
73, 125);" lang="EN-US"> | </span></b><b><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color:
rgb(192, 0, 0);" lang="EN-US">Researcher</span></b><b><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: rgb(31,
73, 125);" lang="EN-US"><o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: gray;"
lang="EN-US">University of Salzburg | Centre for
Geoinformatics - Z_GIS<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 1pt;"><span
style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: gray;"
lang="EN-US">Schillerstr.30 | Techno-Z, Block 15, 3rd floor
| 5020 Salzburg, Austria<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family:
"Verdana","sans-serif"; color: gray;"
lang="EN-US">Phone +43 (0)662 8044 5298 | Fax +43 (0)662
8044 5260<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size: 8pt;
font-family: "Verdana","sans-serif";
color: gray;" lang="EN-US">> <a
moz-do-not-send="true"
href="http://www.zgis.at/research"><span style="color:
gray; text-decoration: none;">Z_GIS…experts for the
spatial view</span></a><o:p></o:p></span></i></b></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0cm 0cm;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif";" lang="DE">Von:</span></b><span
style="font-size: 10pt; font-family:
"Tahoma","sans-serif";" lang="DE">
<a class="moz-txt-link-abbreviated" href="mailto:users-bounces@geoext.org">users-bounces@geoext.org</a>
[<a class="moz-txt-link-freetext" href="mailto:users-bounces@geoext.org">mailto:users-bounces@geoext.org</a>] <b>Im Auftrag von </b>Vidal,
Antoni<br>
<b>Gesendet:</b> Freitag, 01. April 2011 15:30<br>
<b>An:</b> <a class="moz-txt-link-abbreviated" href="mailto:users@geoext.org">users@geoext.org</a><br>
<b>Betreff:</b> [Users] Use of setActiveItem<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="CA">Hello list,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">I cannot get the object to
reference setActiveItem of Ext.Viewport layout property in
order to expand an item.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">My Ext.Viewport code:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">
new Ext.Viewport({<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> layout:
"border",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> items: [{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
title: App.layout.titleLang,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
region: "center",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> xtype:
"gx_mappanel",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
id: "mappanel",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> map:
map,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> layers:
layerStore,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> zoom:
11,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
tbar: createTbarItems(map)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
},{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> title:
"<img src=\"img/transparent22.png\"/>",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> region:
"west",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> id:
'west-panel',<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> split:
true,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> width:
190,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
minSize: 190,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
maxSize: 300,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
collapsible: true,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
margins: '0 0 0 5',<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> layout:
'accordion',<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
layoutConfig:{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA">
animate: true<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> },<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"> items:
[{...<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">I’ve tryed to get wit
Ext.getCmp(‘mappanel’); but it doesn’t work.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">Any idea?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CA">Thanks in advance<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family: "Arial","sans-serif";
color: rgb(13, 13, 13);" lang="CA">Antoni Vidal</span></b><span
style="color: rgb(13, 13, 13);" lang="CA"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; color: gray;"
lang="CA">Unitat d'Aplicacions SIG-WEB<br>
<a moz-do-not-send="true"
href="http://mercuri.icc.cat/website/mob_nf/mob1/mob2/inici2.htm?CONSULTA=Institut%20Cartogr%25E0fic%20de%20Catalunya&XYADDRESS=429486:4580392"><span
style="color: gray;">Institut Cartogràfic de Catalunya</span></a><br>
Parc de Montjuïc, E-08038 Barcelona<br>
Tel. (+34) 93 567 15 00 (ext. 3228)<br>
<a moz-do-not-send="true" href="http://www.icc.cat/">www.icc.cat</a></span><span
style="color: rgb(31, 73, 125);" lang="CA"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CA"><o:p> </o:p></span></p>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@geoext.org">Users@geoext.org</a>
<a class="moz-txt-link-freetext" href="http://www.geoext.org/cgi-bin/mailman/listinfo/users">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
</body>
</html>