Changeset 1674

Show
Ignore:
Timestamp:
02/10/09 14:26:53 (4 years ago)
Author:
alex
Message:

added recenterOnGeometry(), recenterOnBbox() + some styling improvements

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/MapFish/client/mfbase/mapfish/widgets/recenter/Base.js

    r1340 r1674  
    175175                    fieldLabel: OpenLayers.i18n('mf.print.scale'), 
    176176                    typeAhead: false, 
     177                    value: this.scales[this.defaultZoom] || this.scales[0], 
    177178                    mode: 'local', 
    178179                    id: 'scale_' + this.getId(), 
     
    209210        // use default zoom level if provided in widget config,  
    210211        // else keep current zoom level 
    211         zoom = zoom || this.defaultZoom || this.map.getZoom(); 
     212        if (typeof(zoom) == 'undefined') { 
     213            zoom = (typeof(this.defaultZoom) != 'undefined')  
     214                   ? this.defaultZoom : this.map.getZoom() 
     215        } 
    212216 
    213217        if (this.showCenter) { 
     
    215219            this.showCenterMark(x, y); 
    216220        } 
    217          
     221 
    218222        this.map.setCenter(new OpenLayers.LonLat(x, y), zoom); 
     223    }, 
     224 
     225    /**  
     226     * Method: recenterOnBbox  
     227     * Recenters on given bounds  
     228     *  
     229     * Parameters:  
     230     * bbox - {<OpenLayers.Bounds>}  
     231     */  
     232    recenterOnBbox: function(bbox) {  
     233        if (this.showCenter) {  
     234            // display a symbol on the center point of the bbox  
     235            var lonlat = bbox.getCenterLonLat();  
     236            this.showCenterMark(lonlat.lon, lonlat.lat);  
     237        }    
     238   
     239        this.map.zoomToExtent(bbox);  
     240    }, 
     241 
     242    /** 
     243     * Method: recenterOnGeometry 
     244     * Recenters on given geometry 
     245     * 
     246     * Parameters: 
     247     * geometry - {<OpenLayers.Geometry>} 
     248     */ 
     249    recenterOnGeometry: function(geometry) { 
     250        if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 
     251            this.recenterOnCoords(geometry.x, geometry.y); 
     252        } else { 
     253            this.recenterOnBbox(geometry.getBounds()); 
     254        } 
    219255    }, 
    220256     
     
    233269            new OpenLayers.Feature.Vector( 
    234270                new OpenLayers.Geometry.Point(x, y), 
    235                 { type: 'cross' } 
     271                { type: this.symbol || 'cross' } 
    236272            ) 
    237273        ]; 
     
    250286        } else { 
    251287            var styles = new OpenLayers.StyleMap({ 
    252                 "default": { 
     288                "default": OpenLayers.Util.extend({ 
    253289                    graphicName: "${type}", // retrieved from symbol type attribute 
    254290                    pointRadius: 10, 
    255291                    fillColor: "red", 
    256292                    fillOpacity: 1 
    257                 } 
     293                }, this.centerMarkStyles) 
    258294            }); 
    259295