OpenLayers OpenLayers

Changeset 2237

Show
Ignore:
Timestamp:
02/17/07 10:00:05 (2 years ago)
Author:
crschmidt
Message:

the mergeNewParams function does not reinitialize the tiles for layers
other than WMS. It should do this for any Grid layer. Ticket #496 includes
a patch for this: it adds a mergeNewParams call at the Layer.Grid level,
(subclassing Layer.HTTPRequest) which reinits the tile grid. This commit
also includes tests for this functionality. Since testing directly
on the Grid layer doesn't work (it's meant to be subclassed), we need to
instead pick a second layer to test -- in this case, ka-Map. Thanks to
Bill Woodall for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Layer/Grid.js

    r2091 r2237  
    352352    }, 
    353353 
     354    /** 
     355     * Once params have been changed, we will need to re-init our tiles 
     356     * 
     357     * @param {Object} newParams Hashtable of new params to use 
     358     */ 
     359    mergeNewParams:function(newArguments) { 
     360        OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, 
     361                                                                [newArguments]); 
     362 
     363        if (this.map != null) { 
     364            this._initTiles(); 
     365        } 
     366    }, 
     367 
    354368     
    355369    /** go through and remove all tiles from the grid, calling 
  • trunk/openlayers/lib/OpenLayers/Layer/WMS.js

    r1721 r2237  
    127127        OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,  
    128128                                                             newArguments); 
    129  
    130         if (this.map != null) { 
    131             this._initTiles(); 
    132         } 
    133129    }, 
    134130 
  • trunk/openlayers/tests/test_Layer_KaMap.html

    r1624 r2237  
    102102        t.eq( zoom, 2, "getZoomForExtent() returns correct value"); 
    103103    }    
     104     
     105    function test_06_Layer_kaMap_mergeNewParams (t) { 
     106        t.plan( 5 ); 
     107 
     108        var map = new OpenLayers.Map("map"); 
     109        var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
     110        layer = new OpenLayers.Layer.KaMap(name, url, params); 
     111         
     112        var newParams = { layers: 'sooper',  
     113                          chickpeas: 'image/png'}; 
     114 
     115        map.addLayer(layer); 
     116        map.zoomToMaxExtent(); 
     117        t.ok( !layer.grid[0][0].url.match("chickpeas"), "chickpeas is not in URL of first tile in grid" ); 
     118 
     119        layer.mergeNewParams(newParams); 
     120         
     121        t.eq( layer.params.layers, "sooper", "mergeNewParams() overwrites well"); 
     122        t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well"); 
     123        t.ok( layer.grid[0][0].url.match("chickpeas"), "CHICKPEAS is in URL of first tile in grid" ); 
     124 
     125        newParams.chickpeas = 151; 
     126 
     127        t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hashtable"); 
     128    } 
    104129 
    105130 
  • trunk/openlayers/tests/test_Layer_WMS.html

    r2123 r2237  
    121121 
    122122    function test_06_Layer_WMS_mergeNewParams (t) { 
    123         t.plan( 3 ); 
    124  
     123        t.plan( 5 ); 
     124 
     125        var map = new OpenLayers.Map("map"); 
    125126        var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
    126127        layer = new OpenLayers.Layer.WMS(name, url, params); 
     
    129130                          chickpeas: 'image/png'}; 
    130131 
     132        map.addLayer(layer); 
     133        map.zoomToMaxExtent(); 
     134        t.ok( !layer.grid[0][0].url.match("CHICKPEAS"), "CHICKPEAS is not in URL of first tile in grid" ); 
     135 
    131136        layer.mergeNewParams(newParams); 
    132137         
    133138        t.eq( layer.params.LAYERS, "sooper", "mergeNewParams() overwrites well"); 
    134139        t.eq( layer.params.CHICKPEAS, "image/png", "mergeNewParams() adds well"); 
     140        t.ok( layer.grid[0][0].url.match("CHICKPEAS"), "CHICKPEAS is in URL of first tile in grid" ); 
    135141 
    136142        newParams.CHICKPEAS = 151;