OpenLayers OpenLayers

Ticket #795: redraw.3.patch

File redraw.3.patch, 3.9 kB (added by euzuro, 1 year ago)

fix the conflict with Markers layer instead of magic wizardry, just move the extant "redraw" logic to the moveTo function (where it gets called from). Then we can just erase the redraw function completely from Markers, since it will inherit it from Layer.js and have the exact same functionality (that was hard to figure out).

  • lib/OpenLayers/Layer.js

    old new  
    335335    }, 
    336336 
    337337    /** 
     338     * APIMethod: redraw 
     339     * Redraws the layer  
     340     */ 
     341    redraw: function() { 
     342        if (this.map) { 
     343 
     344            // min/max Range may have changed 
     345            this.inRange = this.calculateInRange(); 
     346 
     347            // map's center might not yet be set 
     348            var extent = this.getExtent(); 
     349 
     350            if (extent && this.inRange && this.visibility) { 
     351                this.moveTo(extent, true, false); 
     352            } 
     353        } 
     354    }, 
     355 
     356    /** 
    338357     * Method: moveTo 
    339358     *  
    340359     * Parameters: 
     
    451470        if (visibility != this.visibility) { 
    452471            this.visibility = visibility; 
    453472            this.display(visibility); 
    454             if (visibility && this.map != null) { 
    455                 var extent = this.map.getExtent(); 
    456                 if (extent != null) { 
    457                     this.moveTo(extent, true); 
    458                 } 
    459             } 
     473            this.redraw(); 
    460474            if ((this.map != null) &&  
    461475                ((noEvent == null) || (noEvent == false))) { 
    462476                this.map.events.triggerEvent("changelayer"); 
  • lib/OpenLayers/Map.js

    old new  
    518518                layer.setVisibility(false); 
    519519            } 
    520520        } else { 
    521             if (this.getCenter() != null) { 
    522                 layer.moveTo(this.getExtent(), true);    
    523             } 
     521            layer.redraw(); 
    524522        } 
    525523 
    526524        this.events.triggerEvent("addlayer"); 
  • lib/OpenLayers/Layer/Markers.js

    old new  
    7272        OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 
    7373 
    7474        if (zoomChanged || !this.drawn) { 
    75             this.redraw(); 
     75            for(i=0; i < this.markers.length; i++) { 
     76                this.drawMarker(this.markers[i]); 
     77            } 
    7678            this.drawn = true; 
    7779        } 
    7880    }, 
     
    116118        } 
    117119    }, 
    118120 
    119     /** 
    120      * APIMethod: redraw 
    121      * Clear all the marker div's from the layer and then redraw all of them. 
    122      *    Use the map to recalculate new placement of markers. 
    123      */ 
    124     redraw: function() { 
    125         for(i=0; i < this.markers.length; i++) { 
    126             this.drawMarker(this.markers[i]); 
    127         } 
    128     }, 
    129  
    130121    /**  
    131122     * Method: drawMarker 
    132123     * Calculate the pixel location for the marker, create it, and  
  • lib/OpenLayers/Layer/MapServer/Untiled.js

    old new  
    254254    mergeNewParams:function(newParams) { 
    255255        OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,  
    256256                                                                 [newParams]); 
    257         //redraw 
    258         this.moveTo(null, true); 
     257        this.redraw(); 
    259258    }, 
    260259     
    261260    /**  
  • lib/OpenLayers/Layer/WMS/Untiled.js

    old new  
    272272        var newArguments = [upperParams]; 
    273273        OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,  
    274274                                                                 newArguments); 
    275         //redraw 
    276         this.moveTo(null, true); 
     275        this.redraw(); 
    277276    }, 
    278277     
    279278    /**