Modify the max zoom level of a Google Map Type

后端 未结 1 854
一向
一向 2021-01-12 00:42


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).

相关标签:
1条回答
  • 2021-01-12 00:57

    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});
        }else 
        if( map.getMapTypeId() === google.maps.MapTypeId.ROADMAP ){
            map.setOptions({maxZoom:/*For example*/8});
        }//Etc...
        else{
            map.setOptions({maxZoom:/*For example*/21});
        }
    });
    
    0 讨论(0)
提交回复
热议问题