0

我正在使用 gmaps4rails gem 生成一张地图,其中包含我大学校园内的几个建筑位置。

但是,我似乎无法显示地图。出现了一个空框,仅此而已。

型号:(仅包括与 gmaps4rails 功能相关的行)

  acts_as_gmappable

  def gmaps4rails_address
    "#{self.name}, CA, Berkeley" 
  end

看法:

<%= stylesheet_link_tag 'gmaps4rails' %>

<%= gmaps4rails(@json) %>

控制器:

  def map
     @json = Hall.all.to_gmaps4rails
  end

应用程序.js:

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require ./gmaps4rails/googlemaps.js
//= require jquery
//= require jquery_ujs
//= require_tree .

我也尝试包括<%= stylesheet_link_tag 'gmaps4rails' %>在视图中。没运气。

我当前的屏幕如下所示:http: //i50.tinypic.com/2q1z7dw.jpg

@json当我查看它时,它的内容似乎是正确的。地图只是因为某种原因没有显示出来。

在这里待了几个小时。我似乎无法弄清楚问题所在。查看了似乎与此问题相关的多个过去问题。

编辑:它可能是宝石的版本吗?我的是 1.5.6 我注意到有一个 2.0.0.pre ...不知道那是什么。

Edit2:呃......不知道如何检查。一种小疙瘩。我创建了一个 heroku 应用程序并尝试将我的代码推送到那里。undefined local variable or method acts_as_gmappable for #<Class:0x00000002fd2c10>当我尝试为数据库播种时,我现在得到了。想知道这是否与我的其他问题有关。

编辑3:我相信是的。我也浏览了很多帖子,似乎一切都正确。再说一次,也许我错过了一些东西......仍在调查它。开始让我发疯。

(哦,我也在使用 JQuery Mobile。我发现这个过去的问题gmaps4rails on jQueryMobile don't work。我是把脚本放在 application.html.erb 还是 mobile.html.erb 中?另外,<%= gmaps4rails(@json, false, false) %>似乎没有工作。不会接受 3 个参数。

至于 的一部分<div class="page" data-role="page" id="gmaps">,我应该<%= gmaps4rails(@json, false, false) %>在这个 div 中插入吗?

4

0 回答 0