Google 地图和 Rails 3
我当时使用 geokit 和 y4mr-gm 在 Rails 2.3x 上构建了一个应用程序。
我现在正在构建一个应用程序和 Rails 3,并且很好奇是否有更好的解决方案。
基本上我有一个有地址的模型企业。当用户搜索或浏览企业时,我希望底部有一个地图,显示每个企业的标记。
我可以通过 geokit 和 y4mr-gm 来做到这一点(尽管我听说 Rails 3 可能存在一些问题),但我希望有一个更优雅的解决方案。最近有什么我可以使用的吗?
谢谢!
I built an app back in the day on rails 2.3x using geokit and y4mr-gm.
I am now building an app and Rails 3 and curious if there are any better solutions.
Basically I have a model Business that has an address. When a user searches for or browses the Businesses I want to have a map at the bottom that displays a marker for each business.
I could do this via geokit and y4mr-gm (though I hear there can be some trouble with Rails 3) but I am hoping for a more elegant solution. Is there anything recent I could use?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我对 Geocoder 非常满意。它的维护非常活跃并且非常简单。在保存模型之前,我要求提供街道地址并让地理编码器填写纬度/经度字段。实施起来真的很轻松。
当涉及到在地图上显示内容时,我仍然自己编写 JS,但使用 jQuery 来完成。如果您正在寻找 JS 与 jQuery 的工作示例,您可以在此处查看我的示例。
I have been really happy with Geocoder. Its actively maintained and very simple. I ask for a street address and get geocoder to fill in the lat/lng fields before I save my model. It's really painless to implement.
When it comes to displaying the stuff on a map, I am still writing the JS myself, but using jQuery to do it. If you are looking for a working example of the JS with jQuery you can see mine here.
我想说的是,拧紧插件,直接使用 Google Maps API v3 中的 javascript...它真的没有那么多代码,而且 G 有非常准确的地理编码器。只需在您的视图中创建一个 js 企业数组,然后使用一些 js 加载地图和标记即可。
未经测试的代码,但它应该非常接近:
当然,您可以变得更奇特,但这应该为您提供您正在寻找的基本功能。谷歌地理编码器限制是每天 1000 个,但那是客户端,所以这应该不是问题。
I would say screw the plugins and just use straight up javascript from Google Maps API v3... its really not that much code and G has very accurate geocoder. Just create a js array of businesses in your view and use the some js to load the map and markers.
UNTESTED code, but it should be pretty close:
Of course you can get alot fancier, but this should give you the basic functionality you are looking for. The google geocoder limit is 1000 a day, but that is client-side, so that should not be a problem.
您应该查看以下内容:
https://github.com/apneadiving/Google-Maps- for-Rails
Here's one you should check out:
https://github.com/apneadiving/Google-Maps-for-Rails
好吧,你有几个选择, ruby 工具箱 可以提供帮助,但看起来没有最新。
我建议 https://github.com/joshuamiller/cartographer
玩得开心
Well, you have several options, ruby tool box can help, but it doesn't looks up to date.
I suggest https://github.com/joshuamiller/cartographer
have fun