summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Control/Permalink.html
blob: 0b729da5bd9c1416317180ce7d54796258e91132 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<html>
<head>
  <script src="../OLLoader.js"></script>
  <script type="text/javascript">
    var map; 
    function test_Control_Permalink_constructor (t) {
        t.plan(42);
    
        control = new OpenLayers.Control.Permalink();
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink('permalink', 'test.html');
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, 'test.html', "base is correct");
        t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink('permalink');
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink({anchor: true});
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(control.element == null, "element is null");
        t.ok(control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink({anchor: false});
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink({});
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, document.location.href, "base is correct");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, 'test.html', "base is correct");
        t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
        t.ok(!control.anchor, "anchor is correct");
        control.destroy();

        control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
        t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
        t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
        t.eq(control.base, 'test.html', "base is correct");
        t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
        t.ok(control.anchor, "anchor is correct");
        control.destroy();
    }
    function test_Control_Permalink_uncentered (t) {
        t.plan( 1 );
    
        control = new OpenLayers.Control.Permalink('permalink');
        map = new OpenLayers.Map('map');
        map.addControl(control);
        map.events.triggerEvent("changelayer", {});
        t.ok(true, "permalink didn't bomb out.");
        map.destroy();
    }   
    function test_Control_Permalink_initwithelem (t) {
        t.plan( 1 );
    
        control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
        t.ok(true, "If the above line doesn't throw an error, we're safe."); 
        control.destroy();
    }
    function test_Control_Permalink_updateLinks (t) {
        t.plan( 3 );
    
        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);
        layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, {'isBaseLayer': false});
        map.addLayer(layer);
        layer.setVisibility(true);
        if (!map.getCenter())  map.zoomToMaxExtent();
        map.addControl(control);
        map.pan(5, 0, {animate:false});
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BT"), 'pan sets permalink');
        
        map.layers[1].setVisibility(false);
        
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
        map.destroy();
    }
    function test_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, {animate:false});
        OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
        t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
        map.destroy();
  }
  function test_Control_Permalink_noElement (t) {
        t.plan( 2 );
        control = new OpenLayers.Control.Permalink( );
        t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
        map = new OpenLayers.Map('map');
        map.addControl(control);
        t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
        map.destroy();
  }
  function test_Control_Permalink_base_with_query (t) {
      t.plan( 3 );
	
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar" );
      map = new OpenLayers.Map('map');
      layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" );
      map.addLayer(layer);
      if (!map.getCenter())  map.zoomToMaxExtent();
      map.addControl(control);
      map.pan(5, 0, {animate:false});
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html?foo=bar&zoom=2&lat=0&lon=1.75781&layers=B';
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring");
      
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar&" );
      map.addControl(control);
      map.pan(0, 0, {animate:false});
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '&'");
      
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html?" );
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
      map.addControl(control);
      map.pan(5, 0, {animate:false});
      map.pan(-5, 0, {animate:false});
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
      map.destroy();
  }

  function test_Control_Permalink_base_with_anchor (t) {
      t.plan( 4 );
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html#foo" );
      map = new OpenLayers.Map('map');
      layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" );
      map.addLayer(layer);
      if (!map.getCenter())  map.zoomToMaxExtent();
      map.addControl(control);
      map.pan(5, 0, {animate:false});
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B#foo';
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and anchor");
      
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html#" );
      map.addControl(control);
      map.pan(0, 0, {animate:false});
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B#';
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and an empty anchor");
      
      control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar#test" );
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html?foo=bar&zoom=2&lat=0&lon=1.75781&layers=B#test';
      map.addControl(control);
      map.pan(5, 0, {animate:false});
      map.pan(-5, 0, {animate:false});
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base, querystring and an anchor");
	  
	  control = new OpenLayers.Control.Permalink('permalink', "./edit.html#foo", {anchor : true} );
      map.addControl(control);
      map.pan(0, 0, {animate:false});
      OpenLayers.Util.getElement('edit_permalink').href = './edit.html#zoom=2&lat=0&lon=1.75781&layers=B';
      t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and an empty anchor");
  }

    function test_Control_Permalink_nonRepeating (t) {
        t.plan( 2 );
    
        control = new OpenLayers.Control.Permalink('permalink', "./edit.html?zoom=3" );
        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, {animate:false});
        OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
        t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
        map.destroy();
  }
  
    function test_Control_Permalink_customized(t) {
        t.plan(2);
      
        var argParserClass = OpenLayers.Class(OpenLayers.Control.ArgParser, {
            CLASS_NAME: "CustomArgParser"
        });
      
        control = new OpenLayers.Control.Permalink(null, "./edit.html", {
            argParserClass: argParserClass,
            createParams: function(center, zoom, layers) {
                var params = OpenLayers.Control.Permalink.prototype.createParams.apply(control, arguments);
                params.customParam = "foo";
                return params;
            }
        });
        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, {animate:false});
      
        t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
        t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
        map.destroy();
    }
    
    function test_Control_Permalink_createParams(t) {
        t.plan(18);

        var baseLayer = { 'isBaseLayer': true };

        var m = {
            'getCenter': function() { return null; }
        };
        
        var pl = {
            'map': m,
            'base': {}
        };

        old_getParameters = OpenLayers.Util.getParameters;
        OpenLayers.Util.getParameters = function(base) {
            t.ok(base == pl.base, "correct base sent in to Util.getParameters()");
            return g_Params;
        };
        
      //null center, null map.getCenter()
        g_Params = {};
        m.baseLayer = baseLayer;
        var returnParams = OpenLayers.Control.Permalink.prototype.createParams.apply(pl, []);
        t.ok(returnParams == g_Params, "correct params returned on null center");

      //valid center, zoom, layers
        g_Params = { 'test': {} };
        var center = { 'lon': 1.2345678901, 'lat': 9.8765432109 };
        var zoom = {};
        var layers = [
            { 'isBaseLayer': true },
            baseLayer,
            { 'isBaseLayer': false, 'getVisibility': function() { return true; } },
            { 'isBaseLayer': false, 'getVisibility': function() { return false; } }
        ];
        var returnParams = OpenLayers.Control.Permalink.prototype.createParams.apply(pl, [center, zoom, layers]);

        t.ok(returnParams.test == g_Params.test, "correct params returned from Util.getParameters() when valid center, zoom, layers");
        t.ok(returnParams.zoom == zoom, "params.zoom set correctly when valid center, zoom, layers");
        t.eq(returnParams.lon, 1.23457, "lon set and rounded correctly when valid center, zoom, layers");
        t.eq(returnParams.lat, 9.87654, "lat set and rounded correctly when valid center, zoom, layers");
        t.eq(returnParams.layers, "0BTF", "layers processed correctly when valid center, zoom, layers")


      //null center, zoom, layers, with displayProjection
        g_Params = { 'test': {} };
        g_Projection = {};
        m = {
            'baseLayer': baseLayer,
            'getProjectionObject':  function() { return g_Projection; },
            'center': { 'lon': {}, 'lat': {} },
            'getCenter': function() { return this.center; },
            'zoom': {},
            'getZoom': function() { return this.zoom; },
           'layers': [
                { 'isBaseLayer': false, 'getVisibility': function() { return true; } },
                baseLayer,
                { 'isBaseLayer': false, 'getVisibility': function() { return false; } },
                { 'isBaseLayer': true }
            ],
            'getLayers': function() { return this.layers; }
        };
        pl = { 
            'base': {},
            'map': m,
            'displayProjection': {}
        };
        
        old_transform = OpenLayers.Projection.transform;
        OpenLayers.Projection.transform = function(point, projObj, dispProj) {
            t.ok(point.x = m.center.lon, "correct x value passed into transform");
            t.ok(point.y = m.center.lat, "correct x value passed into transform");
            t.ok(projObj == g_Projection, "correct projection object from map passed into transform");
            t.ok(dispProj == pl.displayProjection, "correct displayProjection from control passed into transform");

            return { 'x': 9.8765432109, 'y': 1.2345678901 };
        };
        
        center = zoom = layers = null;

        var returnParams = OpenLayers.Control.Permalink.prototype.createParams.apply(pl, [center, zoom, layers]);
        t.ok(returnParams.test == g_Params.test, "correct params returned from Util.getParameters() when null center, zoom, layers, with displayProjection");
        t.ok(returnParams.zoom == m.zoom, "params.zoom set correctly when null center, zoom, layers, with displayProjection");
        t.eq(returnParams.lon, 9.87654, "lon set, transformed, and rounded correctly when null center, zoom, layers, with displayProjection");
        t.eq(returnParams.lat, 1.23457, "lat set, transformed, and rounded correctly when null center, zoom, layers, with displayProjection");
        t.eq(returnParams.layers, "TBF0", "layers processed correctly when null center, zoom, layers, with displayProjection");

        OpenLayers.Util.getParameters = old_getParameters;
        OpenLayers.Projection.transform = old_transform;
    }
    function test_Control_Permalink_Anchor (t) {
        t.plan(3);
    
        control = new OpenLayers.Control.Permalink({anchor: true});
        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);
        layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, {'isBaseLayer': false});
        map.addLayer(layer);
        layer.setVisibility(true);
        if (!map.getCenter())  map.zoomToMaxExtent();
        map.addControl(control);
        map.pan(5, 0, {animate:false});
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BT"), 'pan sets permalink');
        
        map.layers[1].setVisibility(false);
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
        map.destroy();
    }
    
    function test_Control_Permalink_AnchorBaseElement (t) {
        t.plan(3);
    
        control = new OpenLayers.Control.Permalink('permalink', document.location.href, {anchor: true});
        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);
        layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, {'isBaseLayer': false});
        map.addLayer(layer);
        layer.setVisibility(true);
        if (!map.getCenter())  map.zoomToMaxExtent();
        map.addControl(control);
        map.pan(5, 0, {animate:false});
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BT"), 'pan sets permalink');
        
        map.layers[1].setVisibility(false);
        t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
        map.destroy();
    }
    
    function test_center_from_map(t) {
        t.plan(7);

        var previous = window.location.hash;
        window.location.hash = "";

        var err;
        try {
            var map = new OpenLayers.Map({
                layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
                controls: [
                    new OpenLayers.Control.Permalink({anchor: true})
                ],
                center: [1, 2],
                zoom: 3
            });
        } catch (e) {
            err = e;
        }
        if (err) {
            t.fail("Map construction failure: " + err.message);
        } else {
            t.ok(true, "Map construction works");
        }
        
        // confirm that map center is correctly set
        var center = map.getCenter();
        t.eq(center.lon, 1, "map x");
        t.eq(center.lat, 2, "map y")
        t.eq(map.getZoom(), 3, "map z");

        // confirm that location from map options has been added to url
        var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
        t.eq(params.lon, "1", "url x");
        t.eq(params.lat, "2", "url y");
        t.eq(params.zoom, "3", "url z");
        
        map.destroy();
        window.location.hash = previous;
    }
    
    function test_center_from_url(t) {
        t.plan(6);

        // In cases where the location is specified in the URL and given in
        // the map options, we respect the location in the URL.
        var previous = window.location.hash;
        window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
        
        var map = new OpenLayers.Map({
            layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
            controls: [new OpenLayers.Control.Permalink({anchor: true})],
            center: [0, 0],
            zoom: 0
        });
        
        // confirm that map center is correctly set
        var center = map.getCenter();
        t.eq(center.lon, 4, "map x");
        t.eq(center.lat, 5, "map y")
        t.eq(map.getZoom(), 6, "map z");        
        
        var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
        t.eq(params.lon, "4", "x set");
        t.eq(params.lat, "5", "y set");
        t.eq(params.zoom, "6", "z set");
        
        map.destroy();
        window.location.hash = previous;
    }
    
  </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>