上一次我注意到谷歌地图集群的问题。
我使用gmaps4rails插件(我尝试了0.8.6和1.1.5版本,这两个版本都存在问题)。
带有一个标记的简单地图可以正确显示。
但是如果我得到了10个标记,那么地图就不会显示出来(许多标记会创建一个簇)。
我用firebug检查了这个问题,它返回
e.b.mapTypes[e.b.getMapTypeId()] is undefined此外,我还尝试使用选项禁用集群
<%= gmaps({"markers" => { "data" => @json }, "map_options" => {"do_clustering" => false}}, true, true) %>但是我得到了同样的错误。
有没有快速解决这个问题的办法??
发布于 2011-09-22 23:17:13
这是因为google的更新导致了不兼容。
现在好了。
发布于 2011-09-23 18:26:06
快速解决方案。
下载此文件:
将其放入:
public/javascripts/markerclusterer.js
并将第90行的代码更改为
var maxZoom = 18; //that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom;在app/views/layout/applications.html.erb中包含文件
<%= javascript_include_tag "https://maps.google.com/maps/api/js?sensor=false&libraries=geometry" %>
<%= javascript_include_tag "markerclusterer_compiled.js" %>和0.8.x版本
<%= javascript_include_tag "gmaps4rails.js" %>对于1.x.x
<%= javascript_include_tag "gmaps4rails.base.js" %>
<%= javascript_include_tag "gmaps4rails.googlemaps.js" %>在此之后,您必须使用:
<%= gmaps4rails(@json, true, false) %>或
<%= gmaps({ "markers" => { "data" => @json } },true, false) %>不从默认位置下载google地图JS文件。
来源:
https://github.com/apneadiving/Google-Maps-for-Rails/wiki/View-helper
HTH
编辑 Ok谷歌解决了这个问题,但我会把解决方案留给其他人。
https://stackoverflow.com/questions/7497975
复制相似问题