source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/layeropacityslider.js
@
77
Revision 76, 2.6 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 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[layeropacityslider] | |
10 | * Layer Opacity Slider | |
11 | * -------------------- | |
12 | * Use a slider to control layer opacity. | |
13 | */ | |
14 | ||
15 | var panel1, panel2, wms, slider; | |
16 | ||
17 | Ext.onReady(function() { | |
18 | ||
19 | wms = new OpenLayers.Layer.WMS( | |
20 | "Global Imagery", | |
21 | "http://maps.opengeo.org/geowebcache/service/wms", | |
22 | {layers: "bluemarble"} | |
23 | ); | |
24 | ||
25 | // create a map panel with an embedded slider | |
26 | panel1 = new GeoExt.MapPanel({ | |
27 | title: "Map 1", | |
28 | renderTo: "map1-container", | |
29 | height: 300, | |
30 | width: 400, | |
31 | map: { | |
32 | controls: [new OpenLayers.Control.Navigation()] | |
33 | }, | |
34 | layers: [wms], | |
35 | extent: [-5, 35, 15, 55], | |
36 | items: [{ | |
37 | xtype: "gx_opacityslider", | |
38 | layer: wms, | |
39 | vertical: true, | |
40 | height: 120, | |
41 | x: 10, | |
42 | y: 10, | |
43 | plugins: new GeoExt.LayerOpacitySliderTip({template: '<div>Opacity: {opacity}%</div>'}) | |
44 | }] | |
45 | }); | |
46 | // create a separate slider bound to the map but displayed elsewhere | |
47 | slider = new GeoExt.LayerOpacitySlider({ | |
48 | layer: wms, | |
49 | aggressive: true, | |
50 | width: 200, | |
51 | isFormField: true, | |
52 | inverse: true, | |
53 | fieldLabel: "opacity", | |
54 | renderTo: "slider", | |
55 | plugins: new GeoExt.LayerOpacitySliderTip({template: '<div>Transparency: {opacity}%</div>'}) | |
56 | }); | |
57 | ||
58 | var clone = wms.clone(); | |
59 | var wms2 = new OpenLayers.Layer.WMS( | |
60 | "OpenLayers WMS", | |
61 | "http://vmap0.tiles.osgeo.org/wms/vmap0", | |
62 | {layers: 'basic'} | |
63 | ); | |
64 | panel2 = new GeoExt.MapPanel({ | |
65 | title: "Map 2", | |
66 | renderTo: "map2-container", | |
67 | height: 300, | |
68 | width: 400, | |
69 | map: { | |
70 | controls: [new OpenLayers.Control.Navigation()] | |
71 | }, | |
72 | layers: [wms2, clone], | |
73 | extent: [-5, 35, 15, 55], | |
74 | items: [{ | |
75 | xtype: "gx_opacityslider", | |
76 | layer: clone, | |
77 | complementaryLayer: wms2, | |
78 | changeVisibility: true, | |
79 | aggressive: true, | |
80 | vertical: true, | |
81 | height: 120, | |
82 | x: 10, | |
83 | y: 10, | |
84 | plugins: new GeoExt.LayerOpacitySliderTip() | |
85 | }] | |
86 | }); | |
87 | ||
88 | var tree = new Ext.tree.TreePanel({ | |
89 | width: 145, | |
90 | height: 300, | |
91 | renderTo: "tree", | |
92 | root: new GeoExt.tree.LayerContainer({ | |
93 | layerStore: panel2.layers, | |
94 | expanded: true | |
95 | }) | |
96 | }); | |
97 | ||
98 | }); |
Note: See TracBrowser
for help on using the repository browser.