Page 1 of 1
zip code/location implementation
Posted: Sun Oct 14, 2007 10:06 pm
by webcornea
hello,
i am building a php based site and need to have search based on zip code and locations. what is the best possible solution for doing this?
i want to do searches like search within XX miles of zip code xxxxx
please help
thank you
Posted: Sun Oct 14, 2007 10:21 pm
by Kieran Huggins
I would use the Google Geocoding API to resolve the ZIP code to LAT/LON points, then pythagorize the SQL search against known LAT/LON points of interest.
Hint: Do the math in your query, SQL engines are waaayyyy more optimized than runtimes.
Posted: Sun Oct 14, 2007 11:39 pm
by Christopher
I will second Kieran's suggestion. I tend to do the Google geocode lookup when the record is added and save the longitude/latitude in the record for use by searches.
Posted: Mon Oct 15, 2007 12:09 am
by Kieran Huggins
I should mention that some DB engines have spatial functions for calculating distance, etc... but I have a feeling they're not installed by default.
There is a limit of 50,000 geocode requests per day per Maps
Posted: Mon Oct 15, 2007 12:11 am
by webcornea
There is a limit of 50,000 geocode requests per day per Maps API key.
we expect our site to be very high traffic and 50,000 will be exhausted pretty fast. any other suggestions you guys may have or is there a way to go around this issue? please help
i also wanted to clarify that i only want to implement search based on location like myspace.com or ebay.com where people can search for products and users within a certain area based on zip code
please help
thank you
Posted: Mon Oct 15, 2007 12:28 am
by Kieran Huggins
First of all, it's not a hard limit, it's a request rate of 50,000 requests per day. that works out to about 1 request every 2 seconds.
Second of all, it's not a limit per se, they just ask you to notify them of the traffic hit if you plan to exceed that rate.
Finally, (and most importantly!) I highly doubt you'll need more than 50,000 requests per day. Why would you need to geocode that many points every day? I would have to guess it's because you're not caching them locally, which would preclude your "proximity" search entirely. It would also make your service hella slow.
Also, check out the Google Maps API documentation - I'm fairly certain they've exposed "local search" as an API.
Anywho, build it first. Worry about being too successful later.
Posted: Mon Oct 15, 2007 10:46 am
by webcornea
the google api is too fancy to do a simple search based on zip codes like myspace , dont you think?
Posted: Mon Oct 15, 2007 2:58 pm
by Kieran Huggins
nope - it's exactly perfect, IMO.
If you feel the syntax is heavy, you can use an abstraction library.
Posted: Mon Oct 15, 2007 3:55 pm
by RobertGonzalez
Have you coded anything yet?
Posted: Mon Oct 15, 2007 4:02 pm
by Luke
Interesting... I'm building an application that needs to do the same thing. I'll have to remember this.
