Ticket #359: permalink.2.patch
| File permalink.2.patch, 3.4 kB (added by crschmidt, 1 year ago) |
|---|
-
tests/Control/test_Permalink.html
old new 10 10 t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" ); 11 11 t.eq( control.displayClass, "olControlPermalink", "displayClass is correct" ); 12 12 } 13 14 function test_Control_Permalink_uncentered (t) { 15 t.plan( 1 ); 16 17 control = new OpenLayers.Control.Permalink('permalink'); 18 map = new OpenLayers.Map('map'); 19 map.addControl(control); 20 map.events.triggerEvent("changelayer", {}); 21 t.ok(true, "permalink didn't bomb out."); 22 } 23 13 24 function test_02_Control_Permalink_updateLinks (t) { 14 25 t.plan( 2 ); 15 26 16 27 control = new OpenLayers.Control.Permalink('permalink'); 17 t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );18 28 map = new OpenLayers.Map('map'); 19 29 layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}); 20 30 map.addLayer(layer); 31 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}); 32 map.addLayer(layer); 33 layer.setVisibility(true); 21 34 if (!map.getCenter()) map.zoomToMaxExtent(); 22 35 map.addControl(control); 23 36 map.pan(5, 0); 24 if (/MSIE/.test(navigator.userAgent)) {25 t.eq(OpenLayers.Util.getElement('permalink').href, "?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");26 } else {27 t.eq(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");28 }37 t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BT"), 'pan sets permalink'); 38 39 map.layers[1].setVisibility(false); 40 41 t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BF"), 'setVisibility sets permalink'); 29 42 } 30 43 function test_03_Control_Permalink_updateLinksBase (t) { 31 44 t.plan( 2 ); -
lib/OpenLayers/Control/Permalink.js
old new 96 96 this.div.appendChild(this.element); 97 97 } 98 98 this.map.events.register('moveend', this, this.updateLink); 99 this.map.events.register('changelayer', this, this.updateLink); 100 this.map.events.register('changebaselayer', this, this.updateLink); 99 101 return this.div; 100 102 }, 101 103 … … 104 106 */ 105 107 updateLink: function() { 106 108 var center = this.map.getCenter(); 109 110 // Map not initialized yet. Return null. 111 if (!center) { return null; } 112 107 113 var zoom = "zoom=" + this.map.getZoom(); 108 114 var lat = "lat=" + Math.round(center.lat*100000)/100000; 109 115 var lon = "lon=" + Math.round(center.lon*100000)/100000;
