【发布时间】:2012-05-22 09:53:47
【问题描述】:
我按照 github 上的说明安装了所有东西。 (Gmaps4Rails-github)
问题是地图是空白的,我从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 控制台中没有收到任何错误。我不知道我在这里做错了什么。
任何建议都会非常有帮助!谢谢!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 mongoid gmaps4rails