source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/permalink.js
@
77
Revision 76, 1.5 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /** |
2 | * Copyright (c) 2008-2009 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[permalink] |
10 | * Permalink |
11 | * --------- |
12 | * Display a permalink each time the map changes position. |
13 | */ |
14 | |
15 | var permalinkProvider; |
16 | |
17 | Ext.onReady(function() { |
18 | |
19 | // set a permalink provider |
20 | permalinkProvider = new GeoExt.state.PermalinkProvider({encodeType: false}); |
21 | Ext.state.Manager.setProvider(permalinkProvider); |
22 | |
23 | var map = new OpenLayers.Map(); |
24 | map.addLayers([ |
25 | new OpenLayers.Layer.WMS( |
26 | "Imagery", |
27 | "http://maps.opengeo.org/geowebcache/service/wms", |
28 | {layers: "bluemarble"} |
29 | ), |
30 | new OpenLayers.Layer.WMS( |
31 | "OSM", |
32 | "http://maps.opengeo.org/geowebcache/service/wms", |
33 | {layers: "openstreetmap"} |
34 | ) |
35 | ]); |
36 | map.addControl(new OpenLayers.Control.LayerSwitcher()); |
37 | |
38 | var mapPanel = new GeoExt.MapPanel({ |
39 | title: "GeoExt MapPanel", |
40 | renderTo: "mappanel", |
41 | height: 400, |
42 | width: 600, |
43 | map: map, |
44 | center: new OpenLayers.LonLat(5, 45), |
45 | zoom: 4, |
46 | stateId: "map", |
47 | prettyStateKeys: true |
48 | }); |
49 | |
50 | // update link when state chnages |
51 | var onStatechange = function(provider) { |
52 | var l = provider.getLink(); |
53 | Ext.get("permalink").update("<a href=" + l + ">" + l + "</a>"); |
54 | }; |
55 | permalinkProvider.on({statechange: onStatechange}); |
56 | }); |
Note: See TracBrowser
for help on using the repository browser.