Is there a way to show/hide all the UI controls from google map after initialised?

╄→гoц情女王★ 提交于 2019-12-11 08:12:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!