Skip to content Skip to sidebar Skip to footer

Modify The Max Zoom Level Of A Google Map Type

I need to set the maxZoom level of the google.maps.MapTypeId.HYBRID to 21. Actually, he's set to 14 (inspected with the firebug console). Set the property of the google.maps objec

Solution 1:

If you changed mapType object's property ( maxZoom, minZoom, etc... ), the changed effect will take a place ONLY AFTER the map's type will be changed to that mapType. For example , if current mapType is TERRAIN, and you changed TERRAIN's maxZoom, maxZoom will work only after changing mapType to another type (e.g. ROADMAP,HYBRID,etc..) and back to TERRAIN.

Instead of setting mapType's maxZoom option,use core map's maxZoom option. Add listener for "maptypeid_changed" event, and when event occurs, change maxZoom option of map:

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

Post a Comment for "Modify The Max Zoom Level Of A Google Map Type"