2012-05-22 39 views
0

我按照github上的指示安裝一切。 (Gmaps4Rails-githubRails3:gem Gmap4rails與mongoid不顯示地圖

問題是地圖是空白的,我只能看到來自css的地圖邊界。

型號:

class Recipe 
    include Mongoid::Document 
    include Gmaps4rails::ActsAsGmappable 
    acts_as_gmappable 

    field :name, :type => String 
    field :city, :type => String 
    field :country, :type => String 
    field :latitude, :type => Float 
    field :longitude, :type => Float 
    field :gmaps, :type => Boolean 

    def gmaps4rails_address 
    "#{self.city}, #{self.country}" 
    end 
end 

控制器:

class RecipesController < ApplicationController 
    def index 
    @location = Recipe.all.to_gmaps4rails 
    end 
end 

檢視:

= gmaps4rails(@location) 

@location具有以陣列lat和LNG等

[{"lat":13.055363,"lng":47.811886},{"lat":13.055363,"lng":47.811886}] 

所要求JS和CSS文件也越來越加載: gmaps4rails.base.js,gmaps4rails.googlemaps.js,gmaps4rails.bing.js,gmaps4rails.mapquest.js,gmaps4rails.openlayers.js,gmaps4rails.css

我沒有在服務器日誌或JS控制檯中發現任何錯誤。我不知道我在這裏做錯了什麼。

任何建議將非常有幫助!謝謝!

回答

1

我看不到任何提及:

<%= yield :scripts %> 

在你的代碼在這裏。儘管這是強制性的!

+0

非常感謝!我認爲這足以通過Rails資產管道加載所需的js文件。 –