![](/img/trans.png)
[英]How do I make a single event handler for all markers in Google Maps V3?
[英]Event handler on all markers on a map - Google maps V3
是否可以將事件處理程序附加到標記,信息窗口等中,而無需指定已單獨分配的實際變量? 會為我節省很多代碼,而我在文檔中還沒有找到解決方案。
這應該可以工作(將其添加到腳本中的某個位置):
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_;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.