Allen
Allen

Reputation:

latitude/longitude

Is there any way to find out the latitude/longitude of a place using IP address.

Upvotes: 1

Views: 1431

Answers (6)

danni olsen
danni olsen

Reputation: 36

I would say that this is a very easy way to do get the latitude and longitude. You can even get it of the user who is visiting your site.

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));

//$user_location is returning latitude , longitude
$user_location = $details->loc;

//you can split them like this som you get them in two different variables
$pieces = explode(",", $user_location);
$lat = $pieces[0];
$lon = $pieces[1];

Upvotes: 0

Brian
Brian

Reputation: 8626

I use quite a good free api for that in my PHP projects: http://api.hostip.info/?ip=IPADDRESSTOLOOKUP

returls XML... not sure if this is of use to you! :)

Upvotes: 1

pavium
pavium

Reputation: 15128

The IP address doesn't uniquely identify a location.

I know I get a lot of unwanted ads telling me about good times to be had in my location.

The problem is the location is wrong.

Upvotes: 0

Waggers
Waggers

Reputation: 621

ip2location.com has a number of resources (some of which are free) for doing this, including scripts and demo databases - but I'm no iphone expert so I don't know if they're of any use in that particular environment.

Upvotes: 2

Rowland Shaw
Rowland Shaw

Reputation: 38128

Assuming you're trying to find the position of someone/thing else, then generally no. There are a few exceptions, for when that IP address is registered to an individual business, which in turn list their full address in the whois record. You could then geocode that using a webservice (etc.) to get lat/long.

If you're trying to find out where you are, then you're probably better off using the built in GPS

Upvotes: 0

Aif
Aif

Reputation: 11220

But the iphone is supposed to have an embedded gps chip, so I think you might use it to get this information.

Moreover, I think that with IPV6 you'll be able to use a given IP from multiple locations.

Upvotes: 0

Related Questions