[Users] Add all geoserver layers automatically

Valiquette,Francois [Montreal] Francois.Valiquette at ec.gc.ca
Thu Apr 18 18:07:13 CEST 2013


Hello,

 

I tried your code with my WMS server and it does not work. The tree is empty.

 

Frank

 

De : Christoph Mayrhofer [mailto:christoph.mayrhofer at drei.at] 
Envoyé : 18 avril 2013 11:55
À : Valiquette,Francois [Montreal]
Cc : users at geoext.org
Objet : RE: [Users] Add all geoserver layers automatically

 

Hi François,

I just tried it with the following code, but there are no nodes listed in the tree.
Could the url parameter be the problem?: http://localhost:8080/geoserver/wms

var root = new Ext.tree.AsyncTreeNode({
   text: 'All Layers', 
   loader: new GeoExt.tree.WMSCapabilitiesLoader({
      url: 'http://localhost:8080/geoserver/wms', 
      layerOptions: {buffer: 0, singleTile: true, ratio: 1},
      layerParams: {'TRANSPARENT': 'TRUE'}, 
      // customize the createNode method to add a checkbox to nodes 
      createNode: function(attr) {
         attr.checked = attr.leaf ? false : undefined; 
         return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]); 
     } 
   }) 
});

tree = new Ext.tree.TreePanel({ 
   root: root,
   region: 'west',
   width: 250,
   listeners: { 
      // Add layers to the map when ckecked, remove when unchecked.
      // Note that this does not take care of maintaining the layer order on the map.
     'checkchange': function(node, checked) {
         if (checked === true) {
             mapPanel.map.addLayer(node.attributes.layer);
         } else {
             mapPanel.map.removeLayer(node.attributes.layer);
         }
      } 
   }
});

regards, Chris

On Thu, 18 Apr 2013 10:25:19 -0400, "Valiquette,Francois [Montreal]" <Francois.Valiquette at ec.gc.ca> wrote:

	Hello Chris,

	 

	Yes you can, you need to make a query on your server to get the GetCapabilities XML (a list of all the available layers and options).

	The GeoExt.data.WMSCapabilitiesStore can make the query for you by giving it an URL. Then, it will return you a set of records. Afterward with the records, you can generate manually a Tree for a greater flexibility.

	Otherwise, I think you can use GeoExt.tree.WMSCapabilitiesLoader to generate the Tree automatically for you. 

	 

	Here is an exemple of a valid XML file :

	http://api.geoext.org/1.1/examples/data/wmscap.xml

	
	François

	 

	 

	De : users-bounces at geoext.org [mailto:users-bounces at geoext.org] De la part de Christoph Mayrhofer
	Envoyé : 18 avril 2013 10:05
	À : users at geoext.org
	Objet : [Users] Add all geoserver layers automatically

	 

	Hi,

	I saw some examples that had a List of available layers and a button that you could click to add a selected layers to the map.
	Is it possible to have all layers on a Geoserver instance automatically added to the map.
	This would eliminate the need to change the JS code when a new layer is added to Geoserver.

	regards, Chris

	 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20130418/2b0a926e/attachment-0001.htm 


More information about the Users mailing list