# How to get nearbylocation?

How to get nearbylocation using ip address? i want to retrieve the nearbylocation in kilometer range ,based on current location. any one suggests me solution to do

Use an IP-to-location database to get the user’s current latitude and longitude. To retrieve the nearby locations, assuming you also have the latitude and longitude for each location, is just math.

Great-circle distance - Wikipedia, the free encyclopedia

thanks Dan Grossman

there is two type of database ,geolitecity and geoipcity , is free database will be
useful to me or have to purchase geoipcity.

is there any option to get the current location using the any google api, i tried place search api it show request denied . which method is best google api or through php database

You may also want to consider using JavaScript’s new GeoLocation API to get the user’s latitude and longitude directly from the browser, depending on your target audience.

I recently did a blog post that talked about calculating distances between two points given as lat/lon, and briefly touched on GeoLocation at the end. You may find it helpful. I provide the math formulas, and sample implementation functions. Zaemis: Geolocation Search

Good luck.

thank you very much tboronczyk
now i got some idea to calculate the distance , by getting km or miles as input and using the current location i have to list out the nearest locations.i didnt have any database. guide me to solve this problem

help to find how to get nearest location with the help of ip address

Well you need a database then! As Dan has suggested, there is Maxmind as a commercial option. You might also consider My IP Address Lookup and GeoTargeting which was suggested by the thread topic, http://www.sitepoint.com/forums/php-34/turn-ip-into-lat-long-567851.html

Hi Dan Grossman

i get the current location using ip address with the help of maxmind,but how to nearby city using that ,help me to solve this issue

thanks ,its working fine