我能够在谷歌地图上显示多个标记,但我的信息窗口没有出现,也无法显示折线......谁能帮我写代码,这是我的代码示例,它适用于标记,但不适用于折线和信息窗口。 ..
我正在从表格的行和列中获取地址...
var t= document.getElementById('map_table');
var latlng = new google.maps.LatLng(12.97160, 77.59456);
var map = new google.maps.Map(document.getElementById('map_selected'),
{
zoom:12,
center:latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var address = [];
var mark=[];
var info = [];
var pathMap =[];
for(var i=0; i<t.rows.length; i++)
{
address[i] = t.rows[i+1].cells[2].innerHTML + "," + t.rows[i+1].cells[3].innerHTML;
var gc = new google.maps.Geocoder();
gc.geocode({'address': address[i]}, function (res, status)
{
mark[i]=new google.maps.Marker({
position: res[0].geometry.location,
map: map
});
info[i] = new google.maps.InfoWindow({
content:address[i]
});
google.maps.event.addListener(mark[i], 'click', function() {
info[i].open(map,mark[i]);
});
pathMap.push(res[0].geometry.location);
if (pathMap.length == t.rows.length)
{
var routePath = new google.maps.Polyline({
path: pathMap,
strokeColor: "#FF0000",
strokeOpacity: 0.50,
strokeWeight: 2
});
pathMap.setMap(map);
}});
}