如何使用Javascript添加多个标记和infowindow

时间:2013-10-11 06:54:18

标签: javascript google-maps-api-3

我使用Google地图API V3绘制路线。我正在使用LatLng'数组和我循环这个数组在map上绘制路线。我还需要为每个地址添加标记和infowindow。我在地图上得到标记,但信息窗口不起作用,这是我的代码。

for(i=0;i<s[0].length;i++)
{
marker[count] = new google.maps.Marker({
                    position: s[0][i]["location"],
                    map: map
                });



marker[count].info = new google.maps.InfoWindow({
          content: '<b>Speed:</b> '
        });

 google.maps.event.addListener(marker[count], 'click', function() 
  {
     marker[count].info.open(map, marker[count]);
  });

count++;

}

1 个答案:

答案 0 :(得分:1)

而不是

marker[count].info.open(map, marker[count]);

你可以

this.info.open(map, this);

以下是multiple makers with infowindow.

的教程
相关问题