OpenLayers OpenLayers

Ticket #99: layersdisplay.patch

File layersdisplay.patch, 2.6 kB (added by euzuro, 2 years ago)

adding one small if clause to keep from calling calculateInRange() on layer initialization if the layer is a baselayer -- that has no sense

  • lib/OpenLayers/Layer.js

    old new  
    191191     * @param {Boolean} dragging 
    192192     */ 
    193193    moveTo:function(bounds, zoomChanged, dragging) { 
    194         this.display(this.visibility && this.inRange); 
     194        var display = this.visibility; 
     195        if (!this.isBaseLayer) { 
     196            display = display && this.inRange; 
     197        } 
     198        this.display(display); 
    195199    }, 
    196200 
    197201    /** Set the map property for the layer. This is done through an accessor 
     
    208212         
    209213        this.initResolutions(); 
    210214         
    211         this.inRange = this.calculateInRange(); 
    212          
     215        if (!this.isBaseLayer) { 
     216            this.inRange = this.calculateInRange(); 
     217        }     
    213218    }, 
    214219   
    215220    /** 
  • lib/OpenLayers/Map.js

    old new  
    703703                } 
    704704            }     
    705705             
     706            var bounds = this.getExtent(); 
     707             
    706708            //send the move call to the baselayer and all the overlays     
    707             var bounds = this.getExtent(); 
     709            this.baseLayer.moveTo(bounds, zoomChanged, dragging); 
    708710            for (var i = 0; i < this.layers.length; i++) { 
    709711                var layer = this.layers[i]; 
    710                  
    711                 var inRange = layer.calculateInRange(); 
    712                 if (layer.inRange != inRange) { 
    713                     layer.inRange = inRange; 
    714                     layer.display(layer.visibility && layer.inRange); 
    715                     this.events.triggerEvent("changelayer"); 
    716                 } 
    717                  
    718                 if (layer.visibility && layer.inRange) { 
    719                     layer.moveTo(bounds, zoomChanged, dragging); 
    720                 } 
     712                if (!layer.isBaseLayer) { 
     713                     
     714                    var moveLayer; 
     715                    var inRange = layer.calculateInRange(); 
     716                    if (layer.inRange != inRange) { 
     717                        layer.inRange = inRange; 
     718                        moveLayer = true; 
     719                        this.events.triggerEvent("changelayer"); 
     720                    } else { 
     721                        moveLayer = (layer.visibility && layer.inRange); 
     722                    } 
     723 
     724                    if (moveLayer) { 
     725                        layer.moveTo(bounds, zoomChanged, dragging); 
     726                    } 
     727                }                 
    721728            } 
    722729             
    723730            this.events.triggerEvent("move");