검색 결과에 따라 마커 수가있는 google maps (api v3)를 만들었습니다. 마커를 클릭하면 정보 창이 열립니다. 정보창에 마커와 관련된 정보를 표시하는 가장 좋은 방법은 무엇입니까? 모든 마커와 관련된 정보는 아약스 요청에서받은 json 객체에 있습니다.마커 특정 infowindow에 내용을 표시하는 방법?
for (i=0; i < result.point.length; i++) {
var latLng = new google.maps.LatLng(result.proint[i].Latitude,result.point[i].Longitude);
var marker = new google.maps.Marker({
position: latLng,
title: i.toString()
//map: map
});
markersArray.push(marker);
var infowindow = new google.maps.InfoWindow({
content: 'specific information associated to the marker clicked'
});
google.maps.event.addListener(markersArray[i], 'click', function(event) {
infowindow.open(map, this);
});
링크 이미 테스트를 작동 가치가있을 것입니다. – andresf
여러 정보 창을 원하나요 아니면 하나만 원하십니까? 코드가 지금과 같은 방식으로 각 마커에 대해 새로운 정보창이 만들어 지지만 마지막으로 생성 된 하나만 표시됩니다. 당신의 의도가 하나뿐이라면, for 루프에서 그것의 생성을 옮겨야한다. – puckhead
나는 더 많은 코드가 도움이 될 것이라는 점에 동의한다. 적어도 JSON 객체는 도움이 될 것이다. – puckhead