[Users] WMSCapabilities from Geoserver - solved

Morper-Busch, Lucia Lucia.Morper-Busch at sbg.ac.at
Tue Apr 5 17:10:24 CEST 2011


Hi Alexandre,

thank you very much for your help. My problem removing the layers was
very simple. I marked it with red. When I don't check if the layer
exists, there appear errors (undefined, property or method not supported
etc.) I don't know why.

This is a part of my code of the Combobox-listeners-select function:
(with the combobox the user select a Geoserver (WMSCapabilitiesStore)
and the store is added to the LayerTreeBuilder)

Best regards

Lucia

 

//remove all layers from the map except of the base layers, but also the
markers layer. 

//Markers layer is to be added afterwards in order to keep it topmost

for (var i = map.layers.length; i>=0; i--) {

     var layer = map.layers[i];

     if (layer){

          if (!layer.isBaseLayer)//&&(layer.displayInLayerSwitcher ==
true)) 

          {

                map.removeLayer(layer);

          }

     }

};

//the layernodes are removed automatically with the layers, 

//empty group nodes remain, they are to be removed seperately

//I do not look for empty group nodes in general, but I remove all nodes
except of "Base layers" and the node to be added (= tag)

var childNodes = tree.getRootNode().childNodes;

for (var i=childNodes.length; i>=0; i--) {

     var child = childNodes[i];

     if ((child)&&(child.text != "Base layers")&&(child.text != tag)){

          tree.getRootNode().removeChild(child, true);

     }

};

//add layers from selected geoserver (WMSstore is a WMSCapabilitiesStore
with url: 

//http://myHost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&n
amespace=myWorkspace)

//to do: add polyline and point feature type layers topmost


var array = WMSstore.getRange();          

for(var i = 0 ; i < array.length ;i++){

     var record = array[i];

     var copy = record.copy();

     copy.data["layer"] = record.getLayer();

     copy.getLayer().mergeNewParams({

          format: "image/png",

          transparent: "true",

          tiled: "true"

     });

     copy.getLayer().visibility = false;

     // adding only layers with a keyword (=group in LayerTreeBuilder)

     // e.g. keywords="Testarea/Subfolder"

     if(record.get("keywords").length !== 0){

          var keywords = record.get("keywords")[0];

          copy.getLayer().options.group = keywords;

          var firstKeyword = keywords.split("/")[0];

          //tag = test area to show

          if (firstKeyword == tag){

                mapPanel.layers.add(copy);     

          }

     }

}

//to keep the markers layer topmost

map.addLayer(markers);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110405/6687f73f/attachment-0001.htm 


More information about the Users mailing list