Я вроде застрял и было интересно, если кто-то может помочь, вот фрагмент моего кода:Как отобразить определенные имена в Google Maps InfoWindow маркер
function test(person,address)
{
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(43.761539, -79.411079),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow()
var marker, i;
var clatlng, clat, clng;
for (i = 0; i < address.length; i++) {
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address[i]}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
clat = results[0].geometry.location.lat();
clng = results[0].geometry.location.lng();
clatlng = new google.maps.LatLng(clat, clng);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
google.maps.event.addListener(marker, 'click', (function(marker) {
//cant add information here dont know why...
return function() {
infowindow.setContent(person[0].cName + "<br>" + results[0].formatted_address);
infowindow.open(map, marker);
}
})(marker));
}
});
}//for
}//function
Я передаю массив адресов и имена. Я пытаюсь получить каждый маркер, чтобы отобразить имя и адрес человека, щелкнув на значке маркера на карте. Вот где у меня проблемы, я решил проблему с адресом, просто используя результаты [0] .formatted_address, но не уверен, как отображать конкретного пользователя на этом маркере. Любые советы будут оценены.