如何删除谷歌地图Api v3中的道路标签?

时间:2016-08-29 14:54:23

标签: javascript google-maps google-maps-api-3

我想删除蓝色道路标签.... Api v3怎么可能?

我用这个:

    var mapDiv = document.getElementById('map_canvas');
    var myOptions = {
        zoom: 11,
        center: new google.maps.LatLng(42.705,13.25),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControl: true,
        zoomControl: true
    };
    map = new google.maps.Map(mapDiv, myOptions);           

enter image description here

1 个答案:

答案 0 :(得分:2)

您应该可以通过执行以下代码来停用Google地图上的道路标签:

map.setOptions({
        styles: [
                {"featureType": "road.highway",elementType: "labels",stylers:[{visibility: "off"}]}, //turns off highway labels
                {"featureType": "road.arterial",elementType: "labels",stylers: [{visibility: "off"}]}, //turns off arterial roads labels
                {"featureType": "road.local",elementType: "labels",stylers: [{visibility: "off"}]}  //turns off local roads labels
         ]
});

有关详细信息,请参阅Google Maps Styles Reference。此外,在使用地图样式时,此wizard会很有用,因为您只需将生成的JSON复制到代码中即可。