问题
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