【问题标题】:Google map api v3 multiple markers - problem with scrollbar and infowindowGoogle map api v3 多个标记 - 滚动条和信息窗口的问题
【发布时间】:2011-03-28 19:56:12
【问题描述】:

我正在尝试制作一个包含大约 200 个标记的地图,并且每个标记都有一个信息窗口。 我用两个标记对其进行了测试。 这是网站:http://www.bau-berater-kdr.de/pages/bauberater-karte.php

代码

<!DOCTYPE html>
 <html>
   <head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" 
      type="text/javascript"></script>
   </head> 

<body>
    <div id="map" style="width: 650px; height: 550px;"></div>

  <script type="text/javascript">
var locations = [
  ['Koehn, Andrej<br>Dipl. Ing. Architektur<br>', 52.5299, 13.4149, 2],
  ['List, Walter, Dipl. Ing. (FH)<br>Büro für Baubiologie u. Grundstücksbewertung<br><a href="http://www.Baubiologie-Mitteldeutschland.de">www.Baubiologie-Mitteldeutschland.de</a>', 51.4233, 12.2992, 1]
];

var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 6,
  center: new google.maps.LatLng(52.5299, 13.4149),
  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>
</body>

有一个主要问题,我没有找到解决方案: 当您单击标记时,您会看到 2 个垂直滚动条.. 只需要一个,我认为窗口会自动调整大小。想增加高度。有谁知道解决方案?

如果有人知道如何让这么多的标记变得更容易,我将不胜感激!

【问题讨论】:

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


【解决方案1】:

Handling Large Amounts of Markers in Google Maps
我已经成功地在具有数千个标记的地图上使用了 MarkerClusterer 选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 2011-02-02
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多