Change the maximum zoom level of a Google map type


I need to set the maxZoomlevel google.maps.MapTypeId.HYBRIDto 21. Actually, he set 14 (checked using the firebug console).

Setting the object property to google.maps"maxZoom" in this case does not work, and I'm already trying to change the object google.maps.mapTypes, but to no avail.

var options = {
    center: new google.maps.LatLng(lat_centre,lng_centre),   
    zoom: 14, 
    maxZoom: 21,
    mapTypeId: google.maps.MapTypeId.TERRAIN,   
    panControl: true,
    zoomControl: true,
    mapTypeControl: false,
    scaleControl: false,
    streetViewControl: false,
    overviewMapControl: false,
    disableDoubleClickZoom: true,
    styles: [ 
        {featureType: "poi", stylers: [{visibility: "off"}]} 
        ]                   
    };

    map = new google.maps.Map(document.getElementById("map_container"),options);

and

google.maps.event.addListener(map, 'tilesloaded', function(event){

    var mapTypeRegistry = map.mapTypes;

    var currentMapTypeId = map.getMapTypeId();

    var mapType = mapTypeRegistry.get(currentMapTypeId);

    mapType.maxZoom = 21;
  });

So, is there a way to increase the zoom level of mapType HYBRID?

Thank.

+5
source share
1 answer

mapType (maxZoom, minZoom ..), , mapType. , mapType TERRAIN, TERRAIN maxZoom, maxZoom mapType (, ROADMAP, HYBRID ..). ) TERRAIN.

mapType maxZoom map map maxZoom. "maptypeid_changed", , maxZoom map:

google.maps.event.addListener(map, 'maptypeid_changed', function(event){
    if( map.getMapTypeId() === google.maps.MapTypeId.TERRAIN ){
        map.setOptions({maxZoom:/*For example*/5});
    }else 
    if( map.getMapTypeId() === google.maps.MapTypeId.ROADMAP ){
        map.setOptions({maxZoom:/*For example*/8});
    }//Etc...
    else{
        map.setOptions({maxZoom:/*For example*/21});
    }
});
+7

All Articles