带有Google地图搜索框的gmaps4rails [英] gmaps4rails with Google Maps searchbox

查看:156
本文介绍了带有Google地图搜索框的gmaps4rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Ruby-on-Rails 3和gmaps4rails gem编写地图应用程序。我有地图设置,一切正常,但我想有一个谷歌地图,如搜索框顶部的下拉列表可能的地方,如下所示:



< img src =https://i.stack.imgur.com/GmZNl.pngalt =在这里输入图片描述>



有没有简单的方法这样做还是一个插件,可以提供这种功能,而不需要太多的编码?



最好我想将搜索结果限制在只有一个国家(如果可能的话) p>

问候,
约翰

解决方案

类似的船。在过去,我的应用程序使用基于Google Maps API Version 2的自定义JavaScript实现了搜索,现在我正在升级。 然而,在Google Maps API Version 3 ,不再有enableGoogleBar选项。好消息是新的Places服务期待成为替代品。



您需要专门查看自动填充地点部分。这个例子非常精确地描述了你想要的东西。



我很快就开始了解这个。我会随时更新我所取得的进展。如果你不先打败我。

I'm writing a map applcication with Ruby-on-Rails 3 and gmaps4rails gem. I have the map setup and everything works fine but I would like to have a google maps like searchbox on the top with a dropdown list of possible places, like this:

Is there any easy way of doing this or a plugin that gives this functionality with not to much coding?

Preferably I would like to limit the search results to just one country if that is possible.

Regards, Johann

解决方案

I'm in a similar boat. In the past my application had search implemented with custom JavaScript based on Google Maps API Version 2, now I'm looking to upgrade.

However, in Google Maps API Version 3, there isn't a "enableGoogleBar" option anymore. The good news is that the new "Places" service looks to be the replacement.

You'll want to specifically look at the Places Autocomplete section. The example pretty much exactly describes what you want.

I'm getting into this myself soon. I'll keep you updated with progress I make. If you don't beat me to it first.

这篇关于带有Google地图搜索框的gmaps4rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆