OpenLayers OpenLayers

Ticket #937: patch-937-r5542-B0.diff

File patch-937-r5542-B0.diff, 4.8 kB (added by elemoine, 1 year ago)
  • lib/OpenLayers/Map.js

    old new  
    13081308            for (var i = 0; i < this.layers.length; i++) { 
    13091309                var layer = this.layers[i]; 
    13101310                if (!layer.isBaseLayer) { 
    1311                      
    1312                     var moveLayer; 
    1313                     var inRange = layer.calculateInRange(); 
    1314                     if (layer.inRange != inRange) { 
    1315                         // Layer property has changed. We are going  
    1316                         // to call moveLayer so that the layer can be turned 
    1317                         // off or on.    
    1318                         layer.inRange = inRange; 
    1319                         moveLayer = true; 
    1320                         this.events.triggerEvent("changelayer"); 
    1321                     } else { 
    1322                         // If nothing has changed, then we only move the layer 
    1323                         // if it is visible and inrange. 
    1324                         moveLayer = (layer.visibility && layer.inRange); 
    1325                     } 
    1326  
    1327                     if (moveLayer) { 
     1311                    // we only move the layer if it is visible and inrange. 
     1312                    if (layer.calculateInRange() && layer.visibility) { 
    13281313                        layer.moveTo(bounds, zoomChanged, dragging); 
    13291314                    } 
    13301315                }                 
  • lib/OpenLayers/Layer.js

    old new  
    369369        if (this.map) { 
    370370 
    371371            // min/max Range may have changed 
    372             this.inRange = this.calculateInRange(); 
     372            var inRange = this.calculateInRange(); 
    373373 
    374374            // map's center might not yet be set 
    375375            var extent = this.getExtent(); 
    376376 
    377             if (extent && this.inRange && this.visibility) { 
     377            if (extent && inRange && this.visibility) { 
    378378                this.moveTo(extent, true, false); 
    379379                redrawn = true; 
    380380            } 
     
    392392     * dragging - {Boolean} 
    393393     */ 
    394394    moveTo:function(bounds, zoomChanged, dragging) { 
    395         var display = this.visibility; 
    396         if (!this.isBaseLayer) { 
    397             display = display && this.inRange; 
    398         } 
    399         this.display(display); 
     395        //to be overridden by subclasses 
    400396    }, 
    401397 
    402398    /** 
     
    433429            this.initResolutions(); 
    434430             
    435431            if (!this.isBaseLayer) { 
    436                 this.inRange = this.calculateInRange(); 
    437                 var show = ((this.visibility) && (this.inRange)); 
     432                var inRange = this.calculateInRange(); 
     433                var show = (this.visibility && inRange); 
    438434                this.div.style.display = show ? "" : "none"; 
    439435            } 
    440436             
     
    549545 
    550546    /** 
    551547     * Method: calculateInRange 
     548     * Checks if layer is layer minResolution and maxResolution matches the 
     549     *     current map resolution, and sets inRange property. If inRange 
     550     *     value changes, also triggers the changelayer map event and 
     551     *     shows/hides the layer. 
    552552     *  
    553553     * Returns: 
    554554     * {Boolean} The layer is displayable at the current map's current 
    555555     *     resolution. 
    556556     */ 
    557557    calculateInRange: function() { 
    558         var inRange = false
     558        var inRange
    559559        if (this.map) { 
    560560            var resolution = this.map.getResolution(); 
    561             inRange = ( (resolution >= this.minResolution) && 
    562                         (resolution <= this.maxResolution) ); 
     561            inRange = (resolution >= this.minResolution) && 
     562                      (resolution <= this.maxResolution); 
     563        } else { 
     564            inRange = false; 
    563565        } 
     566        // if inRange value changes, trigger changerlayer event, 
     567        // and show/hide the layer (ie. change div element display) 
     568        // also change the inRange property 
     569        if (this.inRange != inRange) { 
     570            this.inRange = inRange; 
     571            this.map.events.triggerEvent("changelayer"); 
     572            this.display(inRange); 
     573        } 
    564574        return inRange; 
    565575    }, 
    566576 
  • 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;