我正在使用Google Maps API样式化地图向导(http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html?utm_medium=twitter)来自定义我想要使用的地图的外观,该地图放大到街道级别(缩放:16)。我基本上想要摆脱所有标签,文字或图标。我到达那里大约95%,但仍然是某些标签,即:正方形的名称,仍然存在。
到目前为止,我还没有找到隐藏这些标签的方法。虽然我怀疑Google地图(或此工具)的自定义功能存在错误,但我想询问是否有人遇到过同样的问题?有人有关于如何处理甚至解决这个问题的任何提示吗?
下面的屏幕截图说明了这个问题。 欢迎任何提示。谢谢!
function initialize() {
var mapStyles = [
{
"featureType": "administrative",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "road",
"elementType": "labels",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "road",
"elementType": "geometry.stroke",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{ "visibility": "on" },
{ "color": "#ffffff" }
]
},{
"featureType": "transit",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.attraction",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.business",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.government",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.medical",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.park",
"elementType": "labels",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.place_of_worship",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.school",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "poi.sports_complex",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "landscape.man_made",
"stylers": [
{ "visibility": "on" },
{ "color": "#fce8f0" }
]
},{
"featureType": "landscape.natural",
"elementType": "labels",
"stylers": [ { "visibility": "off" } ]
},{
"featureType": "landscape.natural",
"elementType": "geometry",
"stylers": [
{ "color": "#fce8f0" },
{ "visibility": "on" }
]
},{
"featureType": "water",
"elementType": "labels",
"stylers": [ { "visibility": "off" } ] },
{ }
];
var mapOptions = {
center: { lat: 52.519772, lng: 13.399022},
zoom: 16,
scrollwheel: false,
mapTypeControl: false,
panControl: false,
zoomControl: false,
scaleControl: false,
streetViewControl: false,
styles: mapStyles
};
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
答案 0 :(得分:4)
如果您想要删除所有文字标签,请将它们全部关闭:
var mapStyles = [{
featureType: "all",
elementType: "labels.text",
stylers: [{
visibility: "off"
}]
}];
如果您想要删除所有标签,elementType: "labels"
将同时适用于labels.text
和labels.icon
等。这同样适用于要素类型。
var mapStyles = [{
featureType: "all",
elementType: "labels",
stylers: [{
visibility: "off"
}]
}];
从documentation:注意,父功能可能包含一些未包含在其子功能类型中的其他功能。