source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/mappanel-div.js
@
77
Revision 76, 1.7 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[mappanel-div] |
10 | * Map Panel |
11 | * --------- |
12 | * Render a map panel in any block level page element. |
13 | */ |
14 | |
15 | var mapPanel; |
16 | |
17 | Ext.onReady(function() { |
18 | Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); |
19 | var map = new OpenLayers.Map(); |
20 | var layer = new OpenLayers.Layer.WMS( |
21 | "Global Imagery", |
22 | "http://maps.opengeo.org/geowebcache/service/wms", |
23 | {layers: "bluemarble"} |
24 | ); |
25 | map.addLayer(layer); |
26 | |
27 | mapPanel = new GeoExt.MapPanel({ |
28 | title: "GeoExt MapPanel", |
29 | renderTo: "mappanel", |
30 | stateId: "mappanel", |
31 | height: 400, |
32 | width: 600, |
33 | map: map, |
34 | center: new OpenLayers.LonLat(5, 45), |
35 | zoom: 4, |
36 | // getState and applyState are overloaded so panel size |
37 | // can be stored and restored |
38 | getState: function() { |
39 | var state = GeoExt.MapPanel.prototype.getState.apply(this); |
40 | state.width = this.getSize().width; |
41 | state.height = this.getSize().height; |
42 | return state; |
43 | }, |
44 | applyState: function(state) { |
45 | GeoExt.MapPanel.prototype.applyState.apply(this, arguments); |
46 | this.width = state.width; |
47 | this.height = state.height; |
48 | } |
49 | }); |
50 | }); |
51 | |
52 | // functions for resizing the map panel |
53 | function mapSizeUp() { |
54 | var size = mapPanel.getSize(); |
55 | size.width += 40; |
56 | size.height += 40; |
57 | mapPanel.setSize(size); |
58 | } |
59 | function mapSizeDown() { |
60 | var size = mapPanel.getSize(); |
61 | size.width -= 40; |
62 | size.height -= 40; |
63 | mapPanel.setSize(size); |
64 | } |
65 |
Note: See TracBrowser
for help on using the repository browser.