source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/wms-tree.js
@
76
Revision 76, 2.4 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /** |
2 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
3 | * |
4 | * Published under the BSD license. |
5 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
6 | * of the license. |
7 | */ |
8 | |
9 | /** api: example[wms-tree] |
10 | * WMS Capabilities Tree |
11 | * --------------------- |
12 | * Create a tree loader from WMS capabilities documents. |
13 | */ |
14 | var tree, mapPanel; |
15 | |
16 | Ext.onReady(function() { |
17 | |
18 | var root = new Ext.tree.AsyncTreeNode({ |
19 | text: 'GeoServer Demo WMS', |
20 | loader: new GeoExt.tree.WMSCapabilitiesLoader({ |
21 | url: 'data/wmscap.xml', |
22 | layerOptions: {buffer: 0, singleTile: true, ratio: 1}, |
23 | layerParams: {'TRANSPARENT': 'TRUE'}, |
24 | // customize the createNode method to add a checkbox to nodes |
25 | createNode: function(attr) { |
26 | attr.checked = attr.leaf ? false : undefined; |
27 | return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]); |
28 | } |
29 | }) |
30 | }); |
31 | |
32 | tree = new Ext.tree.TreePanel({ |
33 | root: root, |
34 | region: 'west', |
35 | width: 250, |
36 | listeners: { |
37 | // Add layers to the map when ckecked, remove when unchecked. |
38 | // Note that this does not take care of maintaining the layer |
39 | // order on the map. |
40 | 'checkchange': function(node, checked) { |
41 | if (checked === true) { |
42 | mapPanel.map.addLayer(node.attributes.layer); |
43 | } else { |
44 | mapPanel.map.removeLayer(node.attributes.layer); |
45 | } |
46 | } |
47 | } |
48 | }); |
49 | |
50 | mapPanel = new GeoExt.MapPanel({ |
51 | zoom: 2, |
52 | layers: [ |
53 | new OpenLayers.Layer.WMS("Global Imagery", |
54 | "http://maps.opengeo.org/geowebcache/service/wms", |
55 | {layers: "bluemarble"}, |
56 | {buffer: 0} |
57 | ) |
58 | ], |
59 | region: 'center' |
60 | }); |
61 | |
62 | new Ext.Viewport({ |
63 | layout: "fit", |
64 | hideBorders: true, |
65 | items: { |
66 | layout: "border", |
67 | deferredRender: false, |
68 | items: [mapPanel, tree, { |
69 | contentEl: "desc", |
70 | region: "east", |
71 | bodyStyle: {"padding": "5px"}, |
72 | collapsible: true, |
73 | collapseMode: "mini", |
74 | split: true, |
75 | width: 200, |
76 | title: "Description" |
77 | }] |
78 | } |
79 | }); |
80 | |
81 | }); |
Note: See TracBrowser
for help on using the repository browser.