myLats, (위도) myLngs (경도) 및 myLocs (주소 문자열)의 배열이 세 개 있습니다. 예 : . myLats [0] = 53.3534751, myLngs [0] = -2.5682085, myLocs [0] = Longwood Rd Appleton Warrington. 따라서 각 배열의 요소는 모두 서로 숫자로 일치합니다.마커를 클릭하면 Google지도 InfoWindow가 표시되지 않습니다.
내 initialize() 함수에서지도를 만들 때 여러 좌표를 올바른 좌표에 배치하기 위해이 루프를 반복합니다. 클릭 할 때 정보창이있는 각 표식을 표시하려고합니다. 마커는 단순히 나타나지 않습니다. 이것에 대한 어떤 도움도 크게 감사 할 것입니다.
코드 :
하나 개 이상의 마커를 다루는 일반적인 문제입니다function initialize() {
var myOptions = {
center: new google.maps.LatLng(54.00366, -2.547855),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var marker, infowindow, i;
for (i = 0; i <= myLats.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(myLats[i], myLngs[i]),
map: map,
clickable: true,
icon: '". url::base() ."resources/icons/accident.png',
});
infowindow = new google.maps.InfoWindow({
content: myLocs[i],
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
}