Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails gmaps4rails上的Infowindow关闭事件侦听器_Ruby On Rails_Google Maps_Gmaps4rails - Fatal编程技术网

Ruby on rails gmaps4rails上的Infowindow关闭事件侦听器

Ruby on rails gmaps4rails上的Infowindow关闭事件侦听器,ruby-on-rails,google-maps,gmaps4rails,Ruby On Rails,Google Maps,Gmaps4rails,我有一些标记列表显示在谷歌地图上。现在我想在关闭信息窗口时做一些额外的事情 google.maps.event.addListener(Gmaps.map.visibleInfoWindow,'closeclick',function() { do_something(); }); 它似乎不起作用。请提供一些教程或代码块来实现这一点 您应该覆盖 大概是这样的: old_method = Gmaps4Rails.Google.Marker.prototype.createInfoWind

我有一些标记列表显示在谷歌地图上。现在我想在关闭信息窗口时做一些额外的事情

google.maps.event.addListener(Gmaps.map.visibleInfoWindow,'closeclick',function()
{
    do_something();
});
它似乎不起作用。请提供一些教程或代码块来实现这一点

您应该覆盖

大概是这样的:

old_method = Gmaps4Rails.Google.Marker.prototype.createInfoWindow

Gmaps4Rails.Google.Marker.prototype.createInfoWindow = function(){
  old_method();
  // then access the infowindow with: this.infowindow and add whatever you need
}


对于1.x,执行相同的操作,但使用:
Gmaps4RailsGoogle.prototype.createInfoWindow

当我运行此Gmaps4Rails.Google.Marker.prototype.createInfoWindow时,我收到类型错误:无法读取未定义的属性“Marker”。我使用gem版本:gmaps4rails(1.5.6)哦,好的,我必须检查这个版本