Changeset 1261

Show
Ignore:
Timestamp:
10/30/08 14:04:57 (2 months ago)
Author:
alex
Message:

added support of bbox recentering

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/MapFishAeai/client/mfbase/mapfish/widgets/recenter/Base.js

    r1236 r1261  
    166166        if (this.showCenter) { 
    167167            // display a symbol on the new center point 
    168  
    169             this.prepareVectorLayer(); 
    170  
    171             var features = [ 
    172                 new OpenLayers.Feature.Vector( 
    173                     new OpenLayers.Geometry.Point(x, y), { 
    174                         type: 'cross' 
    175                     } 
    176                 ) 
    177             ]; 
    178  
    179             this.vectorLayer.addFeatures(features); 
     168            this.showCenter(x, y); 
    180169        } 
    181170         
    182171        this.map.setCenter(new OpenLayers.LonLat(x, y), zoom); 
     172    }, 
     173 
     174    /** 
     175     * Method: recenterOnBbox 
     176     * Recenters on given bounds 
     177     * 
     178     * Parameters: 
     179     * {<OpenLayers.Bounds>} - bbox 
     180     */ 
     181    recenterOnBbox: function(bbox) { 
     182        if (this.showCenter) { 
     183            // display a symbol on the center point of the bbox 
     184            var lonlat = bbox.getCenterLonLat(); 
     185            this.showCenter(lonlat.lon, lonlat.lat); 
     186        } 
     187 
     188        this.map.zoomToExtent(bbox, true); 
     189    }, 
     190 
     191    /** 
     192     * Method: showCenter 
     193     * Materializes new center with a cross 
     194     * 
     195     * Parameters: 
     196     * {Float} - easting coordinate 
     197     * {Float} - northing coordinate 
     198     */ 
     199    showCenter: function(x, y) { 
     200        this.prepareVectorLayer(); 
     201 
     202        var features = [ 
     203            new OpenLayers.Feature.Vector( 
     204                new OpenLayers.Geometry.Point(x, y), { 
     205                    type: 'cross' 
     206                } 
     207            ) 
     208        ]; 
     209 
     210        this.vectorLayer.addFeatures(features); 
    183211    }, 
    184212