是否可以将事件处理程序附加到标记、信息窗口等,而不指定单独分配的实际变量? 将为我节省大量代码,但我尚未在文档中找到解决方案。
最佳答案
这应该可行(将其添加到脚本中的某个位置):
google.maps.Marker_=function(opts){
this.clickHandler = google.maps.event.addListener(this,'click',function(){
alert('click on a marker')
});
this.setOptions(opts)
};
google.maps.Marker_.prototype = google.maps.Marker.prototype;
google.maps.Marker = google.maps.Marker_;
关于javascript - map 上所有标记的事件处理程序 - Google map V3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21057559/