php - How to implement a "search within X amount of miles" -


not technical problem having know how implement "search within 8 miles of city"

im looking search on autotrader site

are there online services (maybe google maps api?) or built developer.

here steps take implement this:

assuming allowing user search cities within 8 miles, matching records table a, has address or city field.

  1. step 1: when adding new record table a, used searching against later on, via google map api can save latitude/longitude of address or city in each row of table.

  2. step 2: when user types in city keyword, again use google map api fetch latitude longitude of search keyword city.

  3. step 3: armed keyword lat/long match against table records lat/long, use query harvensine formula "having" statement fetch necessary records.

the formula , mysql query on how this, is described here
google map api use in google documentation

one thing note though, suppose enter city name, "los angeles". incorrect assume los angeles "dot" on map...its city shape. suppose results within 5 miles of los angeles...the question ambiguous because 1 might ask - end of los angeles? reason, google api return multiple sets of coordinates against same city, define bounding poly line of location. if want results accurate, don't consider 5 miles centre, take other coords consideration too, , use union of results.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -