views:

192

answers:

2

Hi, I have to use proximity search with postcode for Australia. Going through some links like http://www.randommouse.com/rms/about/product/FNDRY/docs/tutorial/08/how-to-add-google-maps-to-your-review-site-intro.html

I found that I have to manage the the post codes with latitude and longitude if I am not mistaken. But i could not find how to implement this. Can anyone suggest me how to do this with php or give some links so that i could see more on this.

Thanks in advance.

Edited:

I have edited my question:

Can I use google api for this i.e. to get the post codes within given range. I have found a link that is for the drupal. So can I use google api just to get postcodes. The link have followed is http://svendecabooter.be/blog/implementing-location-proximity-search-for-belgium-with-drupal-and-google-maps

+1  A: 

You'll need to find a database that has the longitude and latitude of each postal code. Once you have the longitude and latitude you'll use the havesine formula (http://www.codecodex.com/wiki/Calculate_Distance_Between_Two_Points_on_a_Globe) to calculate the distance between points. To do a proximity search you'll have to calculate the distance from your starting point to all the points in your dataset. You may also consider using a bounding box and then searching for points inside that bounding box. A geo spatial database like PostGIS has built in functions that can help with all this.

andrew
Thank you Andrew :). One thing is that when we store all the postcodes of Australia in our database i think it will make site slow. Can we use google api for this. Thanks again.
You're welcome. It shouldn't slow your site down all that much. You'll want to keep it on the server and only load the data you need.
andrew
A: 

You might also want to look at GeoHash as a way to speed up searching for a long/lat within an area (proximity). There are 'plugins' in various languages eg. GeoHash in Ruby is very easy to use.

Kris