Sample code displaying a new permalink each time the map is moved.
// create permalink provider
var permalinkProvider = new GeoExt.state.PermalinkProvider();
// set it in the state manager
Ext.state.Manager.setProvider(permalinkProvider);
// create a map panel, and make it stateful
var mapPanel = new GeoExt.MapPanel({
renderTo: "map",
layers: [
new OpenLayers.Layer.WMS(
"Global Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{layers: "bluemarble"}
)
],
stateId: "map",
prettyStateKeys: true // for pretty permalinks
});
// display permalink each time state is changed
permalinkProvider.on({
statechanged: function(provider, name, value) {
alert(provider.getLink());
}
});
Configuration properties in addition to those listed for Ext.state.Provider.
Public methods in addition to those listed for Ext.state.Provider.
Parameter: | base – String The base URL, optional. |
---|---|
Returns: | String The permalink. |
Return the permalink corresponding to the current state.