Add PermaLink control. Add test for permalink control. This control will automatically center and zoom the map to lat/lon/zoom args, and allows you to set an <a> element whose href is modified when the map moves. controls.html implements an example.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@846 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-07-01 02:14:03 +00:00
parent 72e44d6638
commit 9f0a77aa92
5 changed files with 108 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var map;
function test_01_Control_Permalink_constructor (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink();
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
}
function test_02_Control_Permalink_updateLinks (t) {
t.plan( 2 );
control = new OpenLayers.Control.Permalink($('permalink'));
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
map = new OpenLayers.Map($('map'));
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
map.addLayer(layer);
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
}
function test_03_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );
control = new OpenLayers.Control.Permalink($('permalink'), "./edit.html" );
t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
map = new OpenLayers.Map($('map'));
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
map.addLayer(layer);
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
$('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2';
t.eq($('permalink').href, $('edit_permalink').href, "Panning sets permalink with base");
}
// -->
</script>
</head>
<body>
<a id="permalink" href="">Permalink</a> <br />
<a id="edit_permalink" href="">Edit</a> <br />
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>