Search code examples
stringgoogle-mapsgeocodinggoogle-local-search

Smart ways to determine if a search request is an address or a business for use in Google APIS?


Here is the problem, I have an app with a search bar, the user can input something like "18th Street" or "Starbucks" and it uses the Google Geocoding and Local Search APIs respectively to get results.

I'm wondering is there a smart way to determine whether or not a given input string is an address that needs to be Geocoded, or a business name that needs to use Local Search.

Obviously I could try and handroll something, but I'm wondering if someone has already done this or Google provides such functionality themselves.

Cheers.


Solution

  • It turns out Local Search by default does this and processes Geocodes and business searches. There is some coarseness to it, but I guess that is to be expected

    You can change this behaviour by specifying

    mrt? This optional argument specifies which type of listing the user is interested in. Valid values include:

    * blended - request KML, Local Business Listings, and Geocode results
    * kmlonly - request KML and Geocode results
    * localonly - request Local Business Listings and Geocode results