Jump to content

Default to state or city field if only state or city is entered in search


jmdundon

Recommended Posts

If you only enter the name of a US state in the address input for a search, google will pick a single point that it thinks represents that state. However, this will return an incomplete set of results because it will try to show lisitngs within xx radius miles of that point.

 

Example:

 

I have a listing in San Francisco and another in Los Angeles. Both are in california but are hundreds of miles apart. If I just type "California" or "CA" in the address input on the search, both listings will not show up.

 

Likewise for cities, if I type in "Chicago" and have a radius of five miles selected, and Chicago itself has a radius of greater than five miles, listings that are in fact within 5 miles of Chicago (or even inside Chicago city limits) will not show up in results if they happen to be more than 5 miles from what Google considers to be the actual lat/lon of "Chicago".

 

Now, it should not take too long to code this with Javascript so that if you enter only the name or abbreviation of a US state it will not try to geocode it and instead run the search based off of the jr_state field and return all results that match that state (thus negating the radius field completely).

 

However, for cities this becomes more difficult, because listings with the city "Burbank", which is right on the edge of Los Angeles, would not show up for a search within xx miles of Los Angeles if you defaulted to the jr_city field when only the name of a US city, or combination of City and State is entered.

 

Any ideas?

Link to comment
×
×
  • Create New...