0

我设法实现了显示多个标记的 Google Maps Api,但 Maps Div 总是显示一些不当行为,如下图所示(阴影不正确,“vienna”标题下有一个波浪(?!),并且左侧的控制按钮丢失)。

谷歌地图不当行为

我在 mac 上使用 chrome,已经重新启动了我的 mac 几次,它可以在 firefox 和 safari 上重现。

我的代码如下所示:

<head>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&sensor=false"></script>
</head>

<div id="map" style="width:500px;height:500px;"></div>

<script type="text/javascript"> 
                    var locations = [
                      ['Vienna',48.2144203,16.383573,1]
                      ['Test',48.53234,16.32367,2]
                    ];

                    var map = new google.maps.Map(document.getElementById('map'), {
                      zoom: 13,
                      center: new google.maps.LatLng(48.2144203,16.383573),
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                    });

                    var infowindow = new google.maps.InfoWindow();

                    var marker, i;

                    for (i = 0; i < locations.length; i++) {  
                      marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                        map: map
                      });

                      google.maps.event.addListener(marker, 'click', (function(marker, i) {
                        return function() {
                          infowindow.setContent(locations[i][0]);
                          infowindow.open(map, marker);
                        }
                      })(marker, i));
                    }
</script> 
4

1 回答 1

1

这个问题通常来自引导程序。只需使用 max-width:none 在您的 gmaps 页面中添加内联样式;它将被修复。

<style>
       img {max-width: none !important;}
</style>
于 2013-08-11T14:27:15.090 回答