javascript - map 上所有标记的事件处理程序 - Google map V3

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

是否可以将事件处理程序附加到标记、信息窗口等,而不指定单独分配的实际变量? 将为我节省大量代码,但我尚未在文档中找到解决方案。

最佳答案

这应该可行(将其添加到脚本中的某个位置):

  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/

相关文章:

javascript - 使用 jQuery 将页面顶部设置为距顶部 340px

javascript - 从 XMLHttpRequest 解析 JSON 文件

javascript - 如果没有提交按钮,如何检查单选按钮是否已选中?

javascript - 当输入为空警报不起作用时,如何选择和删除列表项

google-maps - 适用于V3的Google Maps V2的IBM Grails示例

javascript - 谷歌API反向地理编码

javascript - 具有固定列和标题的纯 CSS/HTML/Javascript 2D 可滚动表格

javascript - 即使页面刷新后,如何使用本地存储在本地存储输入文件状态?

javascript - JQuery 褪色问题

javascript - KML 图层未显示在 map 上