OpenLayers OpenLayers

Changeset 2234

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

Pullups for 2.3:
svn merge svn.openlayers.org/trunk/openlayers/@2230 svn.openlayers.org/trunk/openlayers/@2233 svn.openlayers.org/branches/openlayers/2.3/
#480 Grid funkiness
#491 improper URL encoding of LAYERS list in WMS GetMap request
#500 layer.destroy() should remove itself from the map but not set new baselayer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.3/lib/OpenLayers/Layer.js

    r2230 r2234  
    138138     * Destroy is a destructor: this is to alleviate cyclic references which 
    139139     * the Javascript garbage cleaner can not take care of on its own. 
    140      */ 
    141     destroy: function() { 
     140     *  
     141     * @param {Boolean} setNewBaseLayer Should a new baselayer be selected when 
     142     *                                  this has been removed? 
     143     *                                  Default is true 
     144     */ 
     145    destroy: function(setNewBaseLayer) { 
     146        if (setNewBaseLayer == null) { 
     147            setNewBaseLayer = true; 
     148        } 
    142149        if (this.map != null) { 
    143             this.map.removeLayer(this); 
     150            this.map.removeLayer(this, setNewBaseLayer); 
    144151        } 
    145152        this.map = null; 
  • branches/openlayers/2.3/lib/OpenLayers/Map.js

    r2181 r2234  
    7777    /** @type int */ 
    7878    zoom: 0,     
     79 
     80    /** Used to store a unique identifier that changes when the map view  
     81     * changes. viewRequestID should be used when adding data asynchronously  
     82     * to the map: viewRequestID is incremented when you initiate your  
     83     * request (right now during changing of baselayers and changing of zooms).  
     84     * It is stored here in the map and also in the data that will be coming  
     85     * back asynchronously. Before displaying this data on request completion,  
     86     * we check that the viewRequestID of the data is still the same as that  
     87     * of the map. Fix for #480 
     88     *  
     89     * @type String */ 
     90    viewRequestID: 0, 
    7991 
    8092  // Options 
     
    202214        if (this.layers != null) { 
    203215            for(var i=0; i< this.layers.length; i++) { 
    204                 this.layers[i].destroy(); 
     216                //pass 'false' to destroy so that map wont try to set a new  
     217                // baselayer after each baselayer is removed 
     218                this.layers[i].destroy(false); 
    205219            }  
    206220            this.layers = null; 
     
    345359     *  
    346360     * @param {OpenLayers.Layer} layer 
    347      */ 
    348     removeLayer: function(layer) { 
     361     * @param {Boolean} setNewBaseLayer Default is true 
     362     */ 
     363    removeLayer: function(layer, setNewBaseLayer) { 
     364        if (setNewBaseLayer == null) { 
     365            setNewBaseLayer = true; 
     366        } 
     367 
    349368        if (layer.isFixed) { 
    350369            this.viewPortDiv.removeChild(layer.div); 
     
    356375 
    357376        // if we removed the base layer, need to set a new one 
    358         if (this.baseLayer == layer) { 
     377        if (setNewBaseLayer && (this.baseLayer == layer)) { 
    359378            this.baseLayer = null; 
    360379            for(i=0; i < this.layers.length; i++) { 
     
    449468                // set new baselayer and make it visible 
    450469                this.baseLayer = newBaseLayer; 
     470                 
     471                // Increment viewRequestID since the baseLayer is  
     472                // changing. This is used by tiles to check if they should  
     473                // draw themselves. 
     474                this.viewRequestID++; 
    451475                this.baseLayer.setVisibility(true, noEvent); 
    452476 
     
    744768                    this.popups[i].updatePosition(); 
    745769                } 
     770 
     771                // zoom level has changed, increment viewRequestID. 
     772                this.viewRequestID++; 
    746773            }     
    747774             
  • branches/openlayers/2.3/lib/OpenLayers/Tile/Image.js

    r2181 r2234  
    3535        if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.layer.div)) { 
    3636            this.layer.div.removeChild(this.imgDiv); 
     37            this.imgDiv.map = null; 
    3738        } 
    3839        this.imgDiv = null; 
     
    5354            this.initImgDiv(); 
    5455        } 
     56 
     57        this.imgDiv.viewRequestID = this.layer.map.viewRequestID; 
    5558         
    5659        this.url = this.layer.getURL(this.bounds); 
     
    133136                                             this.layer.opacity); 
    134137        } 
     138 
     139        // we need this reference to check back the viewRequestID 
     140        this.imgDiv.map = this.layer.map; 
     141 
    135142    }, 
    136143 
  • branches/openlayers/2.3/lib/OpenLayers/Util.js

    r2230 r2234  
    218218 
    219219OpenLayers.Util.onImageLoad = function() { 
    220     this.style.backgroundColor = null; 
    221     this.style.display = "";   
     220    // The complex check here is to solve issues described in #480. 
     221    // Every time a map view changes, it increments the 'viewRequestID'  
     222    // property. As the requests for the images for the new map view are sent 
     223    // out, they are tagged with this unique viewRequestID.  
     224    //  
     225    // If an image has no viewRequestID property set, we display it regardless,  
     226    // but if it does have a viewRequestID property, we check that it matches  
     227    // the viewRequestID set on the map. 
     228    //  
     229    // If the viewRequestID on the map has changed, that means that the user 
     230    // has changed the map view since this specific request was sent out, and 
     231    // therefore this tile does not need to be displayed (so we do not execute 
     232    // this code that turns its display on). 
     233    // 
     234    if (!this.viewRequestID || 
     235        (this.viewRequestID == this.map.viewRequestID)) {  
     236        this.style.backgroundColor = null; 
     237        this.style.display = "";   
     238    } 
    222239}; 
    223240 
     
    378395*    http parameter notation.  
    379396*    (ex. <i>"key1=value1&key2=value2&key3=value3"</i>) 
     397*    If a parameter is actually a list, that parameter will then 
     398*    be set to a comma-seperated list of values (foo,bar) instead 
     399*    of being URL escaped (foo%3Abar).  
    380400* @type String 
    381401*/ 
     
    384404     
    385405    for (var key in params) { 
    386         var value = params[key]; 
    387         if ((value != null) && (typeof value != 'function')) { 
    388             paramsArray.push(encodeURIComponent(key) + "=" + 
    389                              encodeURIComponent(value)); 
    390         } 
     406      var value = params[key]; 
     407      if ((value != null) && (typeof value != 'function')) { 
     408        var encodedValue; 
     409        if (typeof value == 'object' && value.constructor == Array) { 
     410          /* value is an array; encode items and separate with "," */ 
     411          var encodedItemArray = new Array(); 
     412          for (var itemIndex=0; itemIndex<value.length; itemIndex++) { 
     413            encodedItemArray.push(encodeURIComponent(value[itemIndex])); 
     414          } 
     415          encodedValue = encodedItemArray.join(","); 
     416        } 
     417        else { 
     418          /* value is a string; simply encode */ 
     419          encodedValue = encodeURIComponent(value); 
     420        } 
     421        paramsArray.push(encodeURIComponent(key) + "=" + encodedValue); 
     422      } 
    391423    } 
    392424     
  • branches/openlayers/2.3/tests/grid_inittiles.html

    r2230 r2234  
    1212        <!-- 
    1313        function init(){ 
    14             map = new OpenLayers.Map('map', {'maxResolution': 1.40625/2, tileSize: new OpenLayers.Size(256,256)}); 
     14            var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/2, tileSize: new OpenLayers.Size(256,256)}); 
    1515            ww = new OpenLayers.Layer.WMS( "Basic",  
    1616            "http://labs.metacarta.com/wms-c/Basic.py?",  
  • branches/openlayers/2.3/tests/test_Util.html

    r2181 r2234  
    178178 
    179179    function test_07_Util_getParameterString(t) { 
    180         t.plan( 2 ); 
     180        t.plan( 4 ); 
    181181 
    182182        var params = { foo: "bar", 
     
    186186        t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly");     
    187187        t.eq( OpenLayers.Util.getParameterString({'a:':'b='}), "a%3A=b%3D", "getParameterString returns correctly with non-ascii keys/values");     
     188         
     189 
     190        // Parameters which are a list should end up being a comma-seperated 
     191        // list of the URL encoded strings 
     192        var params = { foo: ["bar,baz"] }; 
     193        t.eq( OpenLayers.Util.getParameterString(params), "foo=bar%2Cbaz", "getParameterString encodes , correctly in arrays");     
     194         
     195        var params = { foo: ["bar","baz,"] }; 
     196        t.eq( OpenLayers.Util.getParameterString(params), "foo=bar,baz%2C", "getParameterString returns with list of CSVs when given a list. ");     
    188197    } 
    189198