问题
There is an option on Google Maps disableDefaultUI set to false before loading google Maps.
function initMap(){
var mapVar = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: -33, lng: 151},
disableDefaultUI: true
});
}
Is there any way to hide all the controls using my mapVar variable once the map is rendered?
Removing all controls from a google map - This question is about hiding the map on load.
回答1:
There is a method to hide controls dynamically.
mapVar.setOptions({disableDefaultUI:true});
In case if we want to hide a single option mapVar.setOptions({zoomControl:false});
来源:https://stackoverflow.com/questions/48980654/is-there-a-way-to-show-hide-all-the-ui-controls-from-google-map-after-initialise