I need to get the nearest neighbor state based on the IP address of the current state. I have done some research and found Geo plugin, which gives the state information based on the IP address. So now i need the States nearer to that IP address.How can i do it in PHP..? can any one suggest me..

Thank you.

3 Years
Discussion Span
Last Post by cereal

Mine is more an idea than a solution: you will probably need the position (in coordinates) inside the state, in order to evaluate the nearest border. For example, in MySQL, having the coordinates of each city, you can query and get the result for the cities in a defined range, the first of the result set outside the national border will be in the nearest state.

But the IP is not always the correct source city, a part proxies, sometimes you get the IP of a Tier 2 (or 3) node, for example if you check for italians IPs those can be matched to cities distant up to 800km from the real user location, depending on the node that will send the request out.

The Geolocation API can probably be more accurate, check for:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.