地图上所有标记的事件处理程序 - Google maps V3

时间:2014-01-11 01:47:02

标签: javascript jquery google-maps google-maps-api-3

是否可以将事件处理程序一般性地附加到标记,信息窗口等,而无需指定单独分配的实际变量? WOuld为我保存了很多代码,我还没有在文档中找到解决方案。

1 个答案:

答案 0 :(得分:0)

这应该可行(将其添加到脚本的某处):

  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_;
相关问题