尝试使用 gmaps4rails 时出现空白区域
所以我遵循了教程和截屏视频,但似乎无法让它发挥作用。我可以看到 div id 被称为地图容器和 gmaps4rails_map ,大概地图应该只是别的什么。
我在应用程序布局视图的页眉和页脚中放入了yield :head
和yield :script
以及@charger = Charger.all.to_gmaps4rails
(充电器是我的型号)在chargers_helper.html.erb 文件中(我想在用户显示视图中使用)。
我还将 <%= gmaps4rails(@charger) %>
放入 show.html.erb 视图中。
我该如何让它发挥作用?
-更新-
我刚刚让它工作。为了解决这个问题,我在助手的方法中放入了 @charger = ... 代码,并调用该方法而不是 @charger。
现在地图显示了,但我仍然看不到像截屏视频中那样插入新的标记代码 - 我的应用程序不需要它,但我很好奇它发生了什么。
So I followed the tutorial and screencast but can't seem to get this to work. I can see the div id's called map container and gmaps4rails_map where presumably, the map is supposed to be but nothing else.
I put in the yield :head
and yield :script
in the header and footer of the application layout view and @charger = Charger.all.to_gmaps4rails
(Charger is my model) in the chargers_helper.html.erb file (I want to use in User show view).
I also put <%= gmaps4rails(@charger) %>
in the show.html.erb view.
How do I get this to work?
-Update-
I just got it to work. To fix the problem I put in the @charger = ... code in a method in the helper and called the method instead of @charger.
Now the map shows up but I still cannot see the insert new marker code like in the screencast - I don't need it for my app but am curious as to what happened to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在截屏视频中,我使用脚手架生成器创建模型+控制器。这就是为什么我准备使用链接。
此外,我在截屏期间创建了按钮。没有任何幕后制作:整个应用程序是从头开始创建的:)
In the screencast, I create model + controller with a scaffold generator. That's why I have ready to use links.
Besides, I create buttons during the screencast. Nothing is made behind the scene: the whole app is created from scratch :)