2

上次我注意到谷歌地图集群有问题。

我使用 gmaps4rails 插件(我尝试了 0.8.6 和 1.1.5 版本,两者都存在问题)。

带有一个标记的简单地图可以正确显示。

但是,如果我有 10 个标记,则不会显示地图(许多标记创建一个簇)。

我用萤火虫检查了这个问题并返回

e.b.mapTypes[e.b.getMapTypeId()] is undefined

此错误来自文件-> https://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_compiled.js

此外,我尝试使用选项禁用集群

<%= gmaps({"markers" => { "data" => @json }, "map_options" => {"do_clustering" => false}}, true, true) %>

但我得到了同样的错误。

有没有快速解决这个问题的方法??

4

2 回答 2

1

这是由于来自 google 的更新导致不兼容。

现在好了。

于 2011-09-22T15:17:13.470 回答
1

快速解决。

下载此文件:

http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer.js

放进去:

公共/javascripts/markerclusterer.js

并将第 90 行的代码更改为

  var maxZoom = 18; //that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom;

在 app/views/layouts/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.xx

 <%= javascript_include_tag "gmaps4rails.base.js" %>
 <%= javascript_include_tag "gmaps4rails.googlemaps.js" %>

之后,您必须使用:

 <%= gmaps4rails(@json, true, false) %>

或者

 <%= gmaps({ "markers" => { "data" => @json } },true, false) %>

不从默认位置下载谷歌地图 JS 文件。

来源:

https://github.com/apneadiving/Google-Maps-for-Rails/wiki/View-helper

ClusterMarkerer - 没有出现集群 - this.map_.mapTypes[this.map_.getMapTypeId()] 是未定义的 markerclusterer.js:304

高温高压

编辑 好吧谷歌解决了这个问题,但我会把解决方案留给其他人。

于 2011-09-23T10:26:05.863 回答