如何将多个infowindows添加到谷歌地图标记

时间:2014-06-12 05:20:11

标签: javascript google-maps google-maps-markers infowindow

我尝试添加多个谷歌地图标记。我从谷歌地图文档中找到了这样做的方法。现在我想为这些标记添加infoWindows。这样做的方法是什么?有什么建议吗? 这就是我的尝试。

var beaches = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

function setMarkers(map, locations) {
var image = {
url: 'js/pin_blue.png',
};
  var shape = {
  coords: [1, 1, 1, 20, 18, 20, 18 , 1],
  type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    icon: image,
    shape: shape,
    title: beach[0],
    zIndex: beach[3]
});
}
}

0 个答案:

没有答案
相关问题