Worldwide location (country, region, city) select plugin for Rails, jQuery or Google Maps API?

风格不统一 提交于 2019-12-04 10:50:02

问题


Is there any plugin which will help to create a dropdown menus for countries, regions and cities? At first user chooses country, then he has his region dropdown menu updated according to which country he has chosen, he chooses region and after that from 3rd menu a city.

Plugin can be either for Ruby on Rails, jQuery or maybe javascript solution through google maps api?


回答1:


The Freebase Suggest jQuery plug-in provides pretty slick auto-complete functionality that provides suggestions in a drop-down, complete with Freebase/Wiki-style context info on mouseover. You can limit their suggestions to countries, cities, US states, etc.

Done properly, this might even avoid the need for three separate dropdowns. Of course, this would require using Freebase's particular geographic ontology -- their hierarchical view of countries, states and cities.

I'm not sure of any pre-built plugins, but other gazetteers (Yahoo! GeoPlanet, GeoNames) may be useful if you need a particular level of detail in your modeling of countries, states and cities.




回答2:


One gem is for countries and states is 'carmen'. It provides all countries and states for just over a dozen countries. I'd recommend using a text input for cities (many databases are incomplete).



来源:https://stackoverflow.com/questions/3508903/worldwide-location-country-region-city-select-plugin-for-rails-jquery-or-go

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!