OpenLayers OpenLayers

Changeset 4228

Show
Ignore:
Timestamp:
09/11/07 23:26:35 (1 year ago)
Author:
euzuro
Message:

make sure permalink updates itself when layers change name/visibility or when a baselayer switch is made. (Closes #359)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/Permalink.js

    r4110 r4228  
    9494        } 
    9595        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); 
    9698        return this.div; 
    9799    }, 
     
    102104    updateLink: function() { 
    103105        var center = this.map.getCenter(); 
     106         
     107        // Map not initialized yet. Break out of this function. 
     108        if (!center) {  
     109            return;  
     110        } 
     111         
    104112        var zoom = "zoom=" + this.map.getZoom();  
    105113        var lat = "lat=" + Math.round(center.lat*100000)/100000; 
  • trunk/openlayers/tests/Control/test_Permalink.html

    r4059 r4228  
    1111        t.eq( control.displayClass,  "olControlPermalink", "displayClass is correct" ); 
    1212    } 
     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    }    
    1322    function test_02_Control_Permalink_updateLinks (t) { 
    14         t.plan( 2 ); 
     23        t.plan( 3 ); 
    1524     
    1625        control = new OpenLayers.Control.Permalink('permalink'); 
     
    1928        layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}); 
    2029        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); 
    2133        if (!map.getCenter())  map.zoomToMaxExtent(); 
    2234        map.addControl(control); 
    2335        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'); 
    2541    } 
    2642    function test_03_Control_Permalink_updateLinksBase (t) {