Autocomplete Google Maps Place by Cities

左心房为你撑大大i 提交于 2019-12-25 03:36:45

问题


I have a problem with the autocomplete places of Google maps, I want to restrict the results by cities such as Miami, and show only places from Miami, I try using longitude and latitude, but not every city has a regular area


回答1:


try by zipcode, get a list of zipcodes by city.. query the db for zipcodes within that city. then you could use a joined query to get the markers based on those zip codes.




回答2:


The docs for Autocomplete in the Places API indicates that there is a bounds option and says:

The results are biased towards, but not restricted to, Places contained within these bounds.

If that sort of biasing is acceptable, rather than an outright restriction to places in the city, then you can supply a bounds that covers most of the city or the city center or the city and surrounding area.



来源:https://stackoverflow.com/questions/8625056/autocomplete-google-maps-place-by-cities

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