Google Maps API v3 - 并非显示所有标记

时间:2014-02-04 15:12:13

标签: api google-maps

我在使用某些代码在Google地图中显示标记时遇到问题。我在代码中定义了8个标记,但只有6个会显示。这是我正在使用的代码,它是未显示的位置中的最后两个项目。

    var locations = [


      ['', 45.382, -75.6704, 1, 'properties_detail.php?propertyID=16'], 
      ['', 45.4009, -75.7009, 1, 'properties_detail.php?propertyID=17'],    
      ['', 45.4041, -75.7017, 1, 'properties_detail.php?propertyID=18'],    
      ['', 45.4135, -75.6977, 1, 'properties_detail.php?propertyID=19'],    
      ['', 45.4176, -75.6928, 1, 'properties_detail.php?propertyID=20'],        
  ['', 45.3268, -75.8217, 1, 'properties_detail.php?propertyID=22'],    
      ['', 45.4179, -75.6928, 1, 'properties_detail.php?propertyID=23'],    
      ['', 45.3908, 75.7236, 1, 'properties_detail.php?propertyID=25']           
  ];




function initialize() {
    var mapOptions = {

      center: new google.maps.LatLng(45.392769, -75.719140),
      zoom: 11,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

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

var marker, i;

var iconBase = '';



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
    ,icon: iconBase + 'tagg_map.png'
    ,url: locations[i][4]
  });

  google.maps.event.addListener(marker, 'click', function() {
        window.location.href = this.url;
   });

1 个答案:

答案 0 :(得分:1)

在您的测试用例中,所有8个标记都在那里。你错过了最后一个点的lng的减号,所以它在你的范围之外绘制了一条距离,其中两个非常接近(5和7具有相同的lng)所以在你放大之前出现在同一个地方。 / p>

相关问题