1
이벤트 리스너를 여러 레이어에 적용 (예 : 번호가 지정된 레이어 1에서 레이어 8)하고 배열을 시도했지만 작동하지 않습니다. KMLlayers는 배열을 켜는 경우에만 실행되므로 배열은 올바른 방법은 아니지만 다른 방법은 확실하지 않을 수 있습니다.Google 리더의 여러 KMLlayers에 이벤트 리스너 적용
if (document.mapControlBox.checkbox1.checked) {
/* Load the layer */
var layer1 = new google.maps.KmlLayer('theURL', {suppressInfoWindows: true});
layer1.setMap(map);
layer1.set('preserveViewport', true);
};
/* repeat, repeat... */
/* try to select all layers */
for (var i = 1; i < layer.length; i++) {
var layers = layer[i];
google.maps.event.addListener(layers, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showContentWindow(text);
});
}
/*default function from Gmap example */
function showContentWindow(text) {
var sidediv = document.getElementById('content_window');
sidediv.innerHTML = text;
};
연관된 HTML : http://www.wolfpil.de/v3/kml-shapes.html
그러나 그럼에도 불구하고 내 버전 내 문제는 내가해야한다고했다 :
<form name="mapControlBox">
<ul>
<li>
<input type="checkbox" name="checkbox1" value="checkbox1" onclick="displayMaps();" />
<label class="mapoption">Checkbox1<label>
</li>
/*etc etc*/
</ul>