Set limits of zoom controller
Description
Setting of limitation with zoom level, changes MapType.maxZoom and MapType.minZoom properties. You can get MapType from Map.mapTypes(), which is MapTypeRegistry. In the document, it doesn't mention that MapTypeRegistry has get method, but it's extended MVCObject, so
you can use get method.
Then set limits to MapType.maxZoom and MapType.minZoom properties.
<script type='text/javascript'>
var mapCanvas;
function initialize() {
var initPos = new google.maps.LatLng(40.803, -74.097);
var myOptions = {
center : initPos,
zoom : 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
mapCanvas = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//Changes zoom levels when the projection is available.
google.maps.event.addListenerOnce(mapCanvas, "projection_changed", function(){
mapCanvas.setMapTypeId(google.maps.MapTypeId.HYBRID); //Changes the MapTypeId in short time.
setZoomLimit(mapCanvas, google.maps.MapTypeId.ROADMAP);
setZoomLimit(mapCanvas, google.maps.MapTypeId.HYBRID);
setZoomLimit(mapCanvas, google.maps.MapTypeId.SATELLITE);
setZoomLimit(mapCanvas, google.maps.MapTypeId.TERRAIN);
mapCanvas.setMapTypeId(google.maps.MapTypeId.ROADMAP); //Sets the MapTypeId to original.
});
}
function setZoomLimit(map, mapTypeId){
//Gets MapTypeRegistry
var mapTypeRegistry = map.mapTypes;
//Gets the specified MapType
var mapType = mapTypeRegistry.get(mapTypeId);
//Sets limits to MapType
mapType.maxZoom = 15; //It doesn't work with SATELLITE and HYBRID maptypes.
mapType.minZoom = 10;
}
google.maps.event.addDomListener(window, "load", initialize);
</script>



