Cyb*_*kie 0 javascript google-maps google-maps-api-2
是否可以默认打开所有信息窗口.我尝试了以下但它不起作用:
var infowindow = new google.maps.InfoWindow({
maxWidth: 160
});
// Add the markers and infowindows to the map
for (var 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: icons[iconCounter]
});
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
Run Code Online (Sandbox Code Playgroud)
geo*_*zip 10
您的代码只包含一个infowindow,如果您希望它们全部打开,您需要为每个标记创建一个infowindow.
更新:没有注意到我写这个问题时标记了这个问题google-maps-api-2.此答案仅适用于Google Maps Javascript API v3,不推荐使用的Google Maps Javascript API v2,一次只支持一个infowindow.
// Add the markers and infowindows to the map
for (var i = 0; i < locations.length; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: icons[iconCounter]
});
var infowindow = new google.maps.InfoWindow({
content: locations[i][0],
maxWidth: 160
});
infowindow.open(map, marker);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6821 次 |
| 最近记录: |