javascript 如何从谷歌地图中删除所有内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8406636/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:21:12  来源:igfitidea点击:

How to remove all from google map

javascriptgoogle-mapsgoogle-maps-api-3

提问by 1110

I need google map to have only street names. I wan't to remove things like marked buss stations, hospitals etc.
What command can I use to remove this things?

我需要谷歌地图只有街道名称。我不想删除标记的公交车站、医院等
东西。我可以使用什么命令来删除这些东西?

回答by Mike Jeffrey

You can style the base map as described here:

您可以按照此处所述设置基本地图的样式:

http://code.google.com/apis/maps/documentation/javascript/styling.html

http://code.google.com/apis/maps/documentation/javascript/styling.html

For example, to hide everything but roads:

例如,要隐藏除道路以外的所有内容:

var styleArray = [
  {
    featureType: "all",
    stylers: [
      { visibility: "off" }
    ]
  },
  {
    featureType: "road",
    stylers: [
      { visibility: "on" }
    ]
  }
];

map.setOptions({styles: styleArray});

The full list of features that can be styled is here: http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeStyleFeatureType

可以设置样式的功能的完整列表在这里:http: //code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeStyleFeatureType

You may want to turn parksback on, for example.

例如,您可能想要重新打开parks

回答by ccuesta

You can used the Styled Maps in v3 of the Google Maps API to remove items on the map you don't want.

您可以使用 Google Maps API v3 中的样式化地图来删除地图上您不想要的项目。

Try it out here on the Styled Maps Wizard

在 Styled Maps Wizard 上尝试一下

http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

回答by Francisco Valdez

Actually you only can use 4 types of maps, Satellite, Hybrid, Terrain and Roadmap. I recommend you to use the roapmap, it is the simplest map it has the street names and by default it doesn't has anything else, like the transit overlay.

实际上你只能使用 4 种类型的地图,卫星、混合、地形和路线图。我建议你使用 roapmap,它是最简单的地图,它有街道名称,默认情况下它没有其他任何东西,比如交通覆盖。

In other words you can't remove just some items from the maps, you only can add new layers of your own data.

换句话说,您不能只从地图中删除一些项目,您只能添加自己数据的新图层。

UPDATE:

更新:

Look at @Mike Jeffrey answer

看看@Mike Jeffrey 的回答