簡體   English   中英

使用api v2在Google Map上添加多個標記

[英]Adding Multiple Markers on Google Map using api v2

我有一個包含緯度和經度值的數據庫。 我一次只能顯示一個標記。 我想同時顯示多個標記。 我該怎么做?

這是一個非常基本的例子:

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp"
          type="text/javascript"></script>
</head> 
<body>
  <div id="map" style="width: 500px; height: 400px;"></div>

  <script type="text/javascript">
    var locations = [
      ['Bondi Beach',    -33.890542, 151.274856],
      ['Coogee Beach',   -33.923036, 151.259052],
      ['Cronulla Beach', -34.028249, 151.157507],
      ['Manly Beach',    -33.800128, 151.282085],
      ['Maroubra Beach', -33.950198, 151.259302]
    ];

    var map = new GMap2(document.getElementById('map'));
    var i;

    map.setCenter(new GLatLng(-33.92, 151.25), 10);

    for (i = 0; i < locations.length; i++) {  
      map.addOverlay(
        new GMarker(new GLatLng(locations[i][1], locations[i][2]))
      );
    }
  </script>
</body>
</html>

截圖:

使用api v2在Google Map上添加多個標記

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM