我正在尝试实现带有显示地址的 infowindows .. 下面是我的代码
$('#citiesdata').empty();
var listFavourite = [];
$(responce).find("favorite").each(function() {
var name = $(this).find("name").text();
var address = $(this).find("address").text();
var phoneNo = $(this).find("phoneNo").text();
var lattitude = $(this).find("lattitude").text();
var longitude = $(this).find("longitude").text();
var favouriteObject = new Object();
favouriteObject.name = name;
favouriteObject.address = address;
favouriteObject.lattitude = lattitude;
favouriteObject.longitude = longitude;
listFavourite.push(favouriteObject);
$('#citiesdata').append('<tr><td><b>'+name+'</b></td></tr>');
$('#citiesdata').append('<tr><td>'+address+'</td></tr>');
$('#citiesdata').append('<tr><td>'+phoneNo+'</td></tr>');
});
//call map service to load map with marker
//method name(listFavourite);
var content = "<div id='tabs'>"+
"<form id='button'>"+
"<div>"+
"<input type='button' value='click me' onclick='alert(\"infoWindow\")'>"+
"</div>"+
"</form>"+
"</div>";
var map = new google.maps.Map(document.getElementById("map_canvas"), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false
});
var infowindow = new google.maps.InfoWindow({
//content: content
});
for (var n = 0 ; n <listFavourite.length ; n++)
addMarker(listFavourite[n]);
}
function addMarker(data) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(data.lattitude, data.longitude),
map: map,
title: data.address
});
google.maps.event.addListener(marker, "click", function() {
infowindow.setContent(data.address);
infowindow.open(map, marker);
});
};
在这里,我从数组列表中获取数据(地址)..我想在 infowindows 中显示该地址..谢谢