【发布时间】:2015-11-16 16:43:21
【问题描述】:
【问题讨论】:
标签: javascript google-maps google-maps-api-3 google-maps-markers
【问题讨论】:
标签: javascript google-maps google-maps-api-3 google-maps-markers
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 42.367112, lng: -71.080964},
zoom: 16,
styles: [
{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
}
]
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
</body>
</html>
只需转到 Google 地图样式向导,然后关闭兴趣点可见性,然后将 JSON 用于您的地图样式。
在您的地图构造函数中,指定:
styles: [
{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
}
]
【讨论】:
是的,这可以在 Google Maps API 中使用以下代码。
[
{
featureType: 'all',
elementType: 'labels',
stylers: [{
visibility: 'off'
}]
}
]
另请查看StyleWizard,了解有关设置地图样式的所有信息。
【讨论】: