다음 코드가 있습니다. 마커 중 하나를 클릭 할 때마다 첫 번째 정보 창이 나타납니다. 나는 181 개의 정보원과 181 개의 마커를 가지고있다. 어떤 도움을 주셔서 감사합니다.Google지도 - 왜 항상 첫 번째 정보창을 얻고 있는지 잘 모르겠습니다
var i=0;
$.each(in_locations,function(k,v){
console.log(v);
var marker_latlng = new google.maps.LatLng(v.latitude, v.longitude);
markers[i] = new google.maps.Marker({
position: marker_latlng,
map: map,
title:"here is my title" + v.id
});
infowindows[i] = new google.maps.InfoWindow({
content: "here is some content string" + v.id,
});
google.maps.event.addListener(markers[i], 'click', function() {
alert('number of infowindows: ' + infowindows.length + ' and value is: ' + i);
infowindows[i].open(map,markers[i]);
});
i++;
});
들으
의의 addListener는에 발사되지 이. 내가 잡을 수없는 보조 문제가있을 수 있습니다. 이것 좀 더 살펴 보도록하겠습니다. 대답 – timpone
은 –
thx aSeptik으로 업데이트되었습니다.이 변수는 i 변수를 사용하여 다른 답변을했기 때문에 다른 답변을 선택했습니다. 내가 막 갇혔을 때 정말 고마워. 나는 다른 문제가있을 것이고 기꺼이 받아 들일 것이라고 확신한다. 그들은 매우 가까이에있다. – timpone