OpenLayers OpenLayers

Changeset 2231

Show
Ignore:
Timestamp:
02/16/07 15:24:56 (2 years ago)
Author:
euzuro
Message:

fix for #480 -- addition of 'viewRequestID' variable to map to keep track of the changing view requests so that images dont load when they are no longer needed. muchas gracias to senior woodall for his help getting this patch together

Files:

Legend:

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

    r2167 r2231  
    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 
     
    449461                // set new baselayer and make it visible 
    450462                this.baseLayer = newBaseLayer; 
     463                 
     464                // Increment viewRequestID since the baseLayer is  
     465                // changing. This is used by tiles to check if they should  
     466                // draw themselves. 
     467                this.viewRequestID++; 
    451468                this.baseLayer.setVisibility(true, noEvent); 
    452469 
     
    744761                    this.popups[i].updatePosition(); 
    745762                } 
     763 
     764                // zoom level has changed, increment viewRequestID. 
     765                this.viewRequestID++; 
    746766            }     
    747767             
  • trunk/openlayers/lib/OpenLayers/Tile/Image.js

    r2163 r2231  
    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 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r2229 r2231  
    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 
  • trunk/openlayers/tests/grid_inittiles.html

    r2206 r2231  
    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?",