2011-09-21 85 views
2

上次我注意到谷歌地圖集羣的問題。Rails,羣集gmaps4rails問題

我使用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) %> 

但我得到同樣的錯誤。

有沒有快速解決這個問題?

+0

我真的很抱歉,但我不明白這個問題:一個地圖+ 10個標記有什麼問題?禁用羣集時有什麼問題? – apneadiving

+0

是的,有一個地圖和10個標記有問題。當我禁用集羣時,我得到了同樣的錯誤。看起來像谷歌地圖API最後提交是'邪惡'。 :) –

+0

什麼是錯誤? :) – apneadiving

回答

1

這是由於谷歌更新導致不兼容。

現在沒問題。

1

快速解決方案。

下載這個文件:

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

把它放在:

公共/ Java腳本/ markerclusterer.js

而在90行改變代碼

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

包含文件應用程序/視圖/佈局/ 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.4

<%= 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 - no cluster appear - this.map_.mapTypes[this.map_.getMapTypeId()] is undefined markerclusterer.js:304

HTH

編輯 好了谷歌修復了問題,但我會離開他人的解決方案。