OpenLayers OpenLayers

Changeset 2335

Show
Ignore:
Timestamp:
03/05/07 14:34:04 (2 years ago)
Author:
euzuro
Message:

updating extendBounds patch and comment

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js

    r2320 r2335  
    471471     
    472472    /** 
    473      * Extend the bounds to include the box specificated. 
    474      * Can be used to extend the bounds to a point as well 
    475      * using extendBounds(x,y). 
     473     * Extend the bounds to include the point, lonlat, or bounds specified. 
     474     *  
    476475     * This function assumes that left<right and bottom<top. 
    477      * @param {OpenLayers.LonLat}  
     476     *  
     477     * @param {OpenLayers.Bounds|OpenLayers.LonLat|OpenLayers.Geometry.Point} object 
    478478     */ 
    479     extendBounds:function(geometry){ 
     479    extendBounds:function(object) { 
     480        var bounds = null; 
    480481        switch(geometry.CLASS_NAME) { 
    481482            case "OpenLayers.Geometry.Point": 
    482483            case "OpenLayers.LonLat":     
    483                 var left = geometry.lon; 
    484                 var bottom = geometry.lat; 
    485                 this.left = (left < this.left) ? left : this.left; 
    486                 this.bottom = (bottom < this.bottom) ? bottom : this.bottom; 
    487                 this.right = (left > this.right) ? left : this.right; 
    488                 this.top = (bottom > this.top) ? bottom : this.top; 
    489                 break;     
     484                bounds = new OpenLayers.Bounds(geometry.lon, geometry.lat, 
     485                                                geometry.lon, geometry.lat); 
     486                break; 
     487                 
    490488            case "OpenLayers.Bounds":     
    491                this.left = (geometry.left < this.left) ? geometry.left : this.left; 
    492                this.bottom = (geometry.bottom < this.bottom) ? bottom : this.bottom; 
    493                this.right = (geometry.right > this.right) ? geometry.right : this.right; 
    494                this.top = (geometry.top > this.top) ? top : this.top; 
     489                bounds = object; 
    495490               break; 
    496                 
     491        } 
     492 
     493        if (bounds) { 
     494           this.left = (bounds.left < this.left) ? bounds.left  
     495                                                 : this.left; 
     496           this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom  
     497                                                       : this.bottom; 
     498           this.right = (bounds.right > this.right) ? bounds.right  
     499                                                    : this.right; 
     500           this.top = (bounds.top > this.top) ? bounds.top  
     501                                              : this.top; 
    497502        } 
    498503    },