Rail Search Geocoding

I used some location-based search queries using the Google Maps API (more structural problem at my end than any api display criticism)

For example, if a user searches for “Victoria, Canada,” he, as expected, will return results for “Victoria, Canada.” However, if the user searches for "Canada", google returns the longitude and latitude for the middle of the country, which is necessary for the correct centering of the map. However, it will not show any results since the closest location is too far from the location returned by Google. I am filtering out results that are about 20 miles away.

Can the Google Maps API return anything I could use to indicate if a user entered a country or country name? If not, did anyone develop a solution to work?

Ideally, I would like to avoid just sorting the results by the nearest location. I don’t want the items for “Spain” to appear at the bottom of the list when a user searches for “United States”. I would try to determine if the request is a state or a country before starting the search, but this seems to be a very difficult task, given the various possible spelling of the names of countries and regions. If I expected only English words, it would be much easier.

+4
source share
1 answer

Assuming that this is a form on a site where the controller processes the form and sends a request to the Google APIs, you can break the form into elements of the form, city, state and country (if necessary), then the address and city fields.

I am doing a similar approach with the site that I create using the Google Places API, and it seems to work for me.

0
source

All Articles