如您所知,人口众多的大城市的所有名称都以较大的字体大小显示,小城镇的所有名称都以较小的字体大小显示。如何使用API Google地图在我的网站上隐藏地图上人口较少的小城镇的所有名称? 感谢
答案 0 :(得分:4)
来自styled map wizard,关闭"标签"邻里,地区和地块:
[
{
"featureType": "administrative.neighborhood",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "administrative.land_parcel",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "administrative.locality",
"elementType": "labels",
"stylers": [
{ "visibility": "off" }
]
},{
}
]
代码段:
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{
"featureType": "administrative.neighborhood",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.locality",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}, {}]
});
}
google.maps.event.addDomListener(window, "load", initialize);

html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}

<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map_canvas" style="border: 2px solid #3872ac;"></div>
&#13;