2011-11-16 38 views
2

我有一個顯示頁面,應該顯示業務的業務和Google地圖。我使用谷歌地圖API v3。我已經需要//= require gmaps4rails/googlemaps.jsapplication31.js,並加入以下行到模型(business.rb):使用Rails 3.1的Google Maps for Rails(gmaps4rails)「未定義Gmaps」

acts_as_gmappable 

    def gmaps4rails_address 
    "#{self.address}, #{self.city.name}, #{self.state.name}" 
    end 

樣式表還需要(包括在內)。我還將gem'gmaps4rails'包含到Gemfile中並捆綁在一起。我的模型具有數據庫中正確值的經度和緯度。

在我business_controller.rb我已經加入

def show 
    ... 
    @json = Business.find(params[:id]).to_gmaps4rails 
    ... 
end 

而且我已經加入

業務展示頁面
%div 
    = gmaps4rails(@json) 

頁腳包含

%footer 
    = yield :scripts 

現在看來谷歌地圖的框架但它是空的。以下是有關該錯誤的相關線路:

<footer> 
225 <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry"></script> 
226 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script> 
227 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script> 
228 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script> 
229 
230 <script type="text/javascript" charset="utf-8"> 
231 
232 Gmaps.map = new Gmaps4RailsGoogle(); 
233 Gmaps.load_map = function() { 
234 Gmaps.map.map_options.auto_adjust = true; 
235 Gmaps.map.initialize(); 
236 Gmaps.map.markers = [{"lng": "77.225", "lat": "28.6353"}]; 
237 Gmaps.map.markers_conf.do_clustering = true; 
238 Gmaps.map.create_markers(); 
239 Gmaps.map.adjustMapToBounds(); 
240 Gmaps.map.callback(); 
241 }; 
242 window.onload = function() { Gmaps.loadMaps(); }; 

的錯誤,現在是:

Gmaps is not defined" for line 232 

有誰知道它是什麼呢?我也安裝了geocoder,但我希望這不會產生任何問題。

謝謝!

+0

有地理編碼和gmaps4rails之間沒有衝突。這裏的問題很奇怪。 – apneadiving

+1

'application31.js'應該是什麼?它是由標準的'application.js'加載的嗎? – apneadiving

+0

你可能只是缺少一些JavaScript包含某處。你有沒有在模板中包含你的application-js? – phoet

回答

2

按我的意見,重新命名application31.jsapplication.js

相關問題