我正在尝试在地标上添加事件,但收到错误“文档未定义”。当我尝试提醒地标名称时,它们可以正常工作,那么为什么不显示事件呢?
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var geoXml = new geoXML3.parser({
map: this.map,
singleInfoWindow:true,
afterParse: this.useTheData
});
geoXml.parseKmlString(<my kml string>);
google.maps.event.addListener(this.map, "bounds_changed", RefreshMap);
google.maps.event.addListener(this.map, "center_changed", RefreshMap);
google.maps.event.addListener(this.map, "zoom_changed", RefreshMap);
},
useTheData: function(doc) {
for (var i = 0; i < doc[0].placemarks.length; i++) {
docs[0].placemarks[i].events.add("click", function () {alert("event!!");});
//alert(docs[0].placemarks[i].name);
}
}