2015-01-04 65 views
0

在一个简单的页面上,我显示一个标记的谷歌地图。Heroku制作:Gmaps没有定义 - 在当地工作

在当地,万物完美的作品,但在Heroku我得到了在控制台的错误:

Uncaught ReferenceError: Gmaps is not defined 

这是关系到

handler = Gmaps.build('Google'); //and some other stuff 

Localy,这是工作。但是当我在heroku上部署它时,就像无法加载JS一样。

这是对我的文件

<script src="//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;libraries=geometry"type="text/javascript"></script> 
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'type='text/javascript'></script> 
<script src='//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js' type='text/javascript'></script> 

的顶部和application.js

//= require underscore 
//= require gmaps/google 

I'ts可能是一个简单的错误,可能与预编译的资产,但我不是一个真正的这方面的专家

回答

2

其实,我解决我的问题:

我的控制台告诉我,JQuery没有定义。我没有真正关注它。但这是问题。所以我application.js改变的顺序要求我把gmaps在顶部

//= require gmaps/google 
//= require jQuery.headroom.min.js 
//= require headroom.min.js  
//= require underscore 
//= require template.js 

所以在文件的顶部,当jQuery是宣告未定义,这并没有阻止gmaps到gmaps加载。 所以,现在我必须修复jQuery问题,但是这个gmaps问题已经解决了

1

当您在本地系统中运行rails服务器时,请始终使用命令“rails s -e production”来检查站点在heroku中的工作方式。您应该添加

// = require_tree。

您的application.js。请查看以下链接:

gmaps4rails: Uncaught ReferenceError: Gmaps is not defined

如果您已经通过在.html.erb文件中使用标准<script>得到了错误,那么这是你如何包含JavaScript你.html.erb否则文件可能显示错误

<%= javascript_include_tag "http://YourJavascriptFileLink.js" %>

+0

我在application.js的末尾添加了这个,但没有任何变化。 但实际上,我没有真正使用gmaps4rails,我使用Gmaps(来自脚本),我不认为这是来自application.js,它似乎好像heroku不会加载这些3脚本googlemaps顶部我的文件 – F4Ke 2015-01-04 17:06:10

+0

可以分享链接到你的仓库?我将运行并检查它在我的本地轨道服务器上。也许我可以帮忙。 – 2015-01-04 17:26:00

+0

在你的html.erb文件中使用这一行,而不是正常的html用法..也许这就是问题所在。 '<%= javascript_include_tag“https://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js”%> – 2015-01-04 17:33:37

相关问题