如何使用 Google Maps Javascript V3 API 从谷歌地图中删除 MapType?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4321606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove a MapType from google map using Google Maps Javascript V3 API?
提问by Anand
Here is the snippet I am using to display Google map on my app using their V3 Javascript API.
这是我用来使用他们的 V3 Javascript API 在我的应用程序上显示谷歌地图的片段。
var myOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
But the map shows terrain, hybrid and satellite which I don't want. How do I remove those controls from the map.
但是地图显示了我不想要的地形、混合和卫星。如何从地图中删除这些控件。
回答by Argiropoulos Stavros
You can remove all the default UI
您可以删除所有默认 UI
var mapOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
And then you can add your own controls
然后你可以添加自己的控件
Or you can just add mapTypeControl: false
或者你可以添加 mapTypeControl: false
回答by August Lilleaas
The Google Maps v3 API docis great.
In it, you'll find that MapOptionshave a property, "mapTypeControl", which is a boolean. Set it to false
to disable it for your map.
在其中,您会发现MapOptions有一个属性“mapTypeControl”,它是一个布尔值。将其设置false
为为您的地图禁用它。
回答by cbmtrx
So there's no URL attribute for disabling the satellite/terrain maps from Google's own embed code?
所以没有用于从 Google 自己的嵌入代码禁用卫星/地形图的 URL 属性?
回答by Jean-Luc Barat
To disable only map control, use this option in Gmap3 documentation:
要仅禁用地图控制,请在Gmap3 文档中使用此选项:
mapTypeControl
Type: booleanThe initial enabled/disabled state of the Map type control.
mapTypeControl
类型:布尔型地图类型控件的初始启用/禁用状态。
example:
例子:
var options = {
// ...
mapTypeControl: false
}
var map = new google.maps.Map(document.getElementById("map"), options);