Changeset 4228
- Timestamp:
- 09/11/07 23:26:35 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Control/Permalink.js (modified) (2 diffs)
- trunk/openlayers/tests/Control/test_Permalink.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/Permalink.js
r4110 r4228 94 94 } 95 95 this.map.events.register('moveend', this, this.updateLink); 96 this.map.events.register('changelayer', this, this.updateLink); 97 this.map.events.register('changebaselayer', this, this.updateLink); 96 98 return this.div; 97 99 }, … … 102 104 updateLink: function() { 103 105 var center = this.map.getCenter(); 106 107 // Map not initialized yet. Break out of this function. 108 if (!center) { 109 return; 110 } 111 104 112 var zoom = "zoom=" + this.map.getZoom(); 105 113 var lat = "lat=" + Math.round(center.lat*100000)/100000; trunk/openlayers/tests/Control/test_Permalink.html
r4059 r4228 11 11 t.eq( control.displayClass, "olControlPermalink", "displayClass is correct" ); 12 12 } 13 function test_Control_Permalink_uncentered (t) { 14 t.plan( 1 ); 15 16 control = new OpenLayers.Control.Permalink('permalink'); 17 map = new OpenLayers.Map('map'); 18 map.addControl(control); 19 map.events.triggerEvent("changelayer", {}); 20 t.ok(true, "permalink didn't bomb out."); 21 } 13 22 function test_02_Control_Permalink_updateLinks (t) { 14 t.plan( 2);23 t.plan( 3 ); 15 24 16 25 control = new OpenLayers.Control.Permalink('permalink'); … … 19 28 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 29 map.addLayer(layer); 30 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}); 31 map.addLayer(layer); 32 layer.setVisibility(true); 21 33 if (!map.getCenter()) map.zoomToMaxExtent(); 22 34 map.addControl(control); 23 35 map.pan(5, 0); 24 t.eq(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink"); 36 t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BT"), 'pan sets permalink'); 37 38 map.layers[1].setVisibility(false); 39 40 t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=BF"), 'setVisibility sets permalink'); 25 41 } 26 42 function test_03_Control_Permalink_updateLinksBase (t) {
