我想从我的谷歌地图中删除街道和建筑物的名称,我认为它应该看起来像这样,但我不知道该把它放在哪里。 https://jsfiddle.net/russiandobby/jyppxbqb/2/
var styles = [
{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "landscape",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "transit",
"stylers": [
{ "visibility": "off" }
]
}
]
;
答案 0 :(得分:0)
根据documentation,有两种方法可以设置地图的样式:
要修改默认地图类型的样式(标签和道路的更改也会影响地形和卫星地图),请在构建时或通过调用setOptions在地图的MapOptions中设置样式数组。 / p>
var map = new google.maps.Map(document.getElementById('map-canvas'), {
disableDoubleClickZoom: true,
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
draggable: false,
zoom: 17,
center: new google.maps.LatLng(34.239415, -118.529339),
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{
"featureType": "poi",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "landscape",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "transit",
"stylers": [{
"visibility": "off"
}]
}]
});
var styles = [{
"featureType": "poi",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "landscape",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "transit",
"stylers": [{
"visibility": "off"
}]
}];
map.setOptions({styles: styles});