我正在尝试使谷歌地图水背景透明,以便它显示网页背景。然而,当我关闭水的可见性时,非洲、欧洲和格陵兰岛的部分景观就会被奇怪的多边形包围。
这是该问题的有效 JS Fiddle 链接。
https://jsfiddle.net/kgo81ec8/1/
下面是重现该问题的相同代码。
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<style>
body{
background-color:black;
}
#map{
height:100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
testMe = function () {
var styles = [{
"elementType": "water",
"stylers": [{
"visibility": "off",
}]
}, {
"featureType": "landscape.natural.landcover",
"stylers": [{
"visibility": "on"
}]
}];
var mapOptions = {
zoom : 1,
center : new google.maps.LatLng(40, -3),
styles : styles,
zoomControl : true,
zoomControlOptions : {
style : google.maps.ZoomControlStyle.LARGE,
position : google.maps.ControlPosition.TOP_LEFT
},
backgroundColor:"blue"
};
new google.maps.Map(document.getElementById('map'), mapOptions);
}
testMe();
</script>
</body>
</html>
下面是输出的屏幕截图。
这是在线测试谷歌地图样式的链接。 http://googlemaps.github.io/js-samples/styledmaps/wizard/index.html
感谢您的帮助,我已经在这个简单的问题上工作了几个小时了。
最佳答案
这看起来像是 Google Maps Javascript API v3 StyledMaps 中的错误。
问题跟踪器中的问题:Issue 6217: Bug: Basic Layerstyle option create artefact for Africa and Groenland
(“星标”该问题以获取更新并表示有兴趣修复该问题)
关于javascript - 当水 visibility 关闭时,谷歌会在景观上绘制奇怪的多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368364/