2

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
DevDevDev
  • 5,107
  • 7
  • 55
  • 87
  • 1
    Is there any reason why you can't try geocoding everything, and then use Local Search for those that fail with code 602 or 603? – Mike Williams Jan 06 '10 at 04:03

2 Answers2

2

The first thing that comes to mind would be a regular expression that looks for a street address, but the important question is how your system would qualify an address.

It's reasonable enough to match something that is going to be fairly consistent in format like a fully qualified street address, but when it's something like "18th Street" how do you know they don't actually want a restaurant called "18th Street"? What you might consider is a regular expression that loosely attempts to match a street address and, if it finds one, call the Geocoding. In the event no results are returned by Geocoding, then default to a Local Search.

Nathan Taylor
  • 24,423
  • 19
  • 99
  • 156
  • Thanks a lot for your comment, as 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. – DevDevDev Jan 06 '10 at 19:23
1

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
DevDevDev
  • 5,107
  • 7
  • 55
  • 87