javascript - 当水 visibility 关闭时,谷歌会在景观上绘制奇怪的多边形

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

我正在尝试使谷歌地图水背景透明,以便它显示网页背景。然而,当我关闭水的可见性时,非洲、欧洲和格陵兰岛的部分景观就会被奇怪的多边形包围。

这是该问题的有效 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>

下面是输出的屏幕截图。

enter image description here

这是在线测试谷歌地图样式的链接。 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/

相关文章:

javascript - React Native 属性未传递给子组件

linux - 无法打开: HTTP status was '403 Forbidden' - The "sensor" parameter specified in the request must be set to either "true" or "false"

javascript - 如何在 Google map API 上禁用使用箭头键平移

javascript - 在 JQuery 中使用 Google Maps Api 事件/监听器

javascript - Selenium + JS : driver. wait(until.elementLocated(By(), 2000)) 有时会卡住

javascript - Material-UI 中 IconButton 的悬停效果

asp.net - 如何控制重复的 Ajax 'post' 提交?

google-maps - 谷歌地图查找最近的公用事业

java - 如何通过hashmap向Google map API添加多个标记? - (安卓)

javascript - 谷歌地图 apiv3 'click' 和 'dragend' 单监听器