[Users] Add all geoserver layers automatically
Christoph Mayrhofer
christoph.mayrhofer at drei.at
Thu Apr 18 17:54:59 CEST 2013
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]" 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/49b804e7/attachment.htm
More information about the Users
mailing list