我为我的Rails应用程序安装了gmaps4rails,运行了生成器,并在我的application.js文件中要求像这样的两个文件,以及underscore.js
//= require underscore
//= require gmaps4rails/gmaps4rails.base
//= require gmaps4rails/gmaps4rails.googlemaps按照github https://github.com/apneadiving/Google-Maps-for-Rails的指示,在layout.html.erb中添加这些依赖项
<script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&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>当我试图用这段代码从github页面创建演示地图时,我发现了一个错误,即对象没有build方法。
Uncaught : Object #没有“构建”方法
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers([
{
"lat": 0,
"lng": 0,
"picture": {
"url": "https://addons.cdn.mozilla.net/img/uploads/addon_icons/13/13028-64.png",
"width": 36,
"height": 36
},
"infowindow": "hello!"
}
]);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});实际上,当我查看清单文件中所需的base文件时,该对象没有build方法。
如何在新版本的gmaps4rails中创建映射?
更新gmaps的github帐户是这样要求gmaps的,但是当我这样做时,“无法找到文件”gmaps/google“
//= require underscore
//= require gmaps/google发布于 2013-11-01 22:16:04
您应该在资产管道中使用这些要求。
//= require underscore
//= require gmaps/google请记住,您需要手动添加underscore.js或使用gem才能使用它。
发布于 2013-11-06 12:56:36
对于错误:
couldn't find file 'gmaps/google'我发现我只需要做一个包更新gmaps4rails,因为我一直在使用v1.5.6而不是最近的2.0.4。
发布于 2013-11-04 08:37:03
在您的应用程序目录中使用
rails g gmaps4rails:copy_js或
rails g gmaps4rails:copy_coffeehttps://stackoverflow.com/questions/19735964
复制相似问题