OpenLayers OpenLayers

Ticket #937: patch-#937-r5350-A0.diff

File patch-#937-r5350-A0.diff, 4.1 kB (added by pgiraud, 1 year ago)
  • lib/OpenLayers/Layer.js

    old new  
    359359        if (this.map) { 
    360360 
    361361            // min/max Range may have changed 
    362             this.inRange = this.calculateInRange(); 
     362            this.calculateInRange(); 
    363363 
    364364            // map's center might not yet be set 
    365365            var extent = this.getExtent(); 
     
    415415            this.initResolutions(); 
    416416             
    417417            if (!this.isBaseLayer) { 
    418                 this.inRange = this.calculateInRange(); 
     418                this.calculateInRange(); 
    419419                var show = ((this.visibility) && (this.inRange)); 
    420420                this.div.style.display = show ? "" : "none"; 
    421421            } 
     
    531531 
    532532    /** 
    533533     * Method: calculateInRange 
     534     * Checks if layer is layer minResolution and maxResolution matches the 
     535     *     current map resolution, and sets inRange property. 
     536     *     If inRange value changes, also triggers the changelayer map event 
     537     *     and shows/hides the layer if not in range 
    534538     *  
    535539     * Returns: 
    536540     * {Boolean} The layer is displayable at the current map's current 
    537541     *     resolution. 
    538542     */ 
    539543    calculateInRange: function() { 
    540         var inRange = false; 
     544        var prevInRange = this.inRange; 
    541545        if (this.map) { 
    542546            var resolution = this.map.getResolution(); 
    543             inRange = ( (resolution >= this.minResolution) && 
     547            this.inRange = ( (resolution >= this.minResolution) && 
    544548                        (resolution <= this.maxResolution) ); 
     549        } else { 
     550            this.inRange = false; 
    545551        } 
    546         return inRange; 
     552        // if inRange value changes, trigger changerlayer event, 
     553        // and show/hide the layer (ie. change div element display) 
     554        if (prevInRange != this.inRange) { 
     555            this.map.events.triggerEvent("changelayer"); 
     556            this.display(this.inRange); 
     557        } 
    547558    }, 
    548559 
    549560    /**  
  • lib/OpenLayers/Map.js

    old new  
    11521152            for (var i = 0; i < this.layers.length; i++) { 
    11531153                var layer = this.layers[i]; 
    11541154                if (!layer.isBaseLayer) { 
    1155                      
    1156                     var moveLayer; 
    1157                     var inRange = layer.calculateInRange(); 
    1158                     if (layer.inRange != inRange) { 
    1159                         // Layer property has changed. We are going  
    1160                         // to call moveLayer so that the layer can be turned 
    1161                         // off or on.    
    1162                         layer.inRange = inRange; 
    1163                         moveLayer = true; 
    1164                         this.events.triggerEvent("changelayer"); 
    1165                     } else { 
    1166                         // If nothing has changed, then we only move the layer 
    1167                         // if it is visible and inrange. 
    1168                         moveLayer = (layer.visibility && layer.inRange); 
    1169                     } 
    1170  
    1171                     if (moveLayer) { 
     1155                    // we only move the layer if it is visible and inrange. 
     1156                    layer.calculateInRange(); 
     1157                    if (layer.visibility && layer.inRange) { 
    11721158                        layer.moveTo(bounds, zoomChanged, dragging); 
    11731159                    } 
    11741160                }                 
  • lib/OpenLayers/Layer/WFS.js

    old new  
    209209        var outOfBounds = (!firstRendering && 
    210210                           !this.tile.bounds.containsBounds(bounds)); 
    211211 
    212         if ( (zoomChanged || firstRendering || (!dragging && outOfBounds)) 
    213              && this.inRange) { 
     212        if (zoomChanged || firstRendering || (!dragging && outOfBounds)) { 
    214213            //determine new tile bounds 
    215214            var center = bounds.getCenterLonLat(); 
    216215            var tileWidth = bounds.getWidth() * this.ratio;