问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/6809673/gmaps4rails-with-google-maps-searchbox