Tool or PHP code to convert IP address into lat/lng coordinates [closed]

放肆的年华 提交于 2019-12-20 10:57:35

问题


I have thousands of IP addresses of visitors to my site, what tools can I use to convert these into lat/lng coordinates? I will then be able visualise the data on a map with filters for further demographics gathered.


回答1:


For one of my sites I made use of maxmind's free geolite country database which can be downloaded here: http://www.maxmind.com/app/geolitecountry

They also provide a city level version which includes the long/lat: http://www.maxmind.com/app/geolitecity

but note that the accuracy on the free version is a lot lower than the paid version.




回答2:


I suggest using Google Analytics to your problem, but if you want to try yourself here is a starting point:

Take a look at this link http://www.geoplugin.net/php.gp, you get a full list of details about that ip address position, including latitude and longitude.

It is not that acurate but it works, and I use it. Here is a php script actually in use :

<?php
$ip_addr = $_SERVER['REMOTE_ADDR'];
$geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_addr) );

if ( is_numeric($geoplugin['geoplugin_latitude']) && is_numeric($geoplugin['geoplugin_longitude']) ) {

$lat = $geoplugin['geoplugin_latitude'];
$long = $geoplugin['geoplugin_longitude'];
}
echo $ip_addr.';'.$lat.';'.$long;
?>

You can see it working at http://whateverhappens.org/ip-addr/

And that a look at the Geoplugin website examples.




回答3:


this might also help https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6103179.html




回答4:


http://www.telize.com and http://www.iptolatlng.com both provide solutions in JSON



来源:https://stackoverflow.com/questions/1077455/tool-or-php-code-to-convert-ip-address-into-lat-lng-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!