OpenLayers OpenLayers

Changeset 1308

Show
Ignore:
Timestamp:
08/19/06 01:23:45 (2 years ago)
Author:
euzuro
Message:

allow google layer to be configured with min/max zoomLevels. update example.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.0/examples/google.html

    r1243 r1308  
    2424 
    2525        function init(){ 
    26             map = new OpenLayers.Map( $('map') ); 
     26            map = new OpenLayers.Map( $('map') ,  
     27            { controls: [new OpenLayers.Control.MouseDefaults()] }); 
    2728 
    28             var normal = new OpenLayers.Layer.Google( "Google" ); 
     29            var normal = new OpenLayers.Layer.Google( "Google", // ); 
     30             { minZoomLevel: 3, maxZoomLevel: 8  }); 
    2931            var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP }); 
    3032            var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP }); 
    3133 
    3234 
    33             map.addLayers([normal, satellite, hybrid]); 
     35            map.addLayers([satellite, normal, hybrid]); 
    3436 
    3537            markers = new OpenLayers.Layer.Markers("markers"); 
     
    3840            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
    3941            map.addControl( new OpenLayers.Control.LayerSwitcher() ); 
     42            map.addControl( new OpenLayers.Control.PanZoomBar() ); 
    4043 
    4144        } 
  • branches/openlayers/2.0/lib/OpenLayers/Layer/Google.js

    r1302 r1308  
    5050 
    5151    /** @type int */ 
    52     numZoomLevels: 16, 
     52    minZoomLevel: 0, 
     53     
     54    /** @type int */ 
     55    maxZoomLevel: 16, 
    5356 
    5457     
     
    6366            this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); 
    6467        } 
     68         
     69        this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; 
    6570    }, 
    6671     
     
    264269            var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); 
    265270            var gZoom = this.gmap.getBoundsZoomLevel(gBounds); 
     271 
     272            //make sure zoom is within bounds     
     273            var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),  
     274                                 this.maxZoomLevel); 
     275          
     276 
    266277            zoom = this.getOLZoomFromGZoom(gZoom); 
    267278        } 
     
    292303        var zoom = null; 
    293304        if (gZoom != null) { 
    294             zoom = gZoom
     305            zoom = gZoom - this.minZoomLevel
    295306        } 
    296307        return zoom; 
     
    307318        var zoom = null;  
    308319        if (olZoom != null) { 
    309             zoom = olZoom
     320            zoom = olZoom + this.minZoomLevel
    310321        } 
    311322        return zoom;