用于将IP地址转换为lat / lng坐标的工具或PHP代码

时间:2021-07-18 21:17:09

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.

我有几千个访问我网站的访问者的IP地址,我可以使用哪些工具将它们转换为lat / lng坐标?然后,我将能够在地图上显示数据,并使用过滤器收集进一步的人口统计数据。

4 个解决方案

#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

对于我的一个网站,我使用了maxmind的免费geolite国家数据库,可以在这里下载:http://www.maxmind.com/app/geolitecountry

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

它们还提供城市级版本,其中包括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.

请查看此链接http://www.geoplugin.net/php.gp,您将获得有关该IP地址位置的详细列表,包括纬度和经度。

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

它不是那么精确但它有效,我使用它。这是一个实际使用的PHP脚本:

<?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/

你可以在http://whateverhappens.org/ip-addr/看到它的工作原理

And that a look at the Geoplugin website examples.

那看看Geoplugin网站上的例子。

#3


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

这也可以帮助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

http://www.telize.com和http://www.iptolatlng.com都提供JSON解决方案

#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

对于我的一个网站,我使用了maxmind的免费geolite国家数据库,可以在这里下载:http://www.maxmind.com/app/geolitecountry

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

它们还提供城市级版本,其中包括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.

请查看此链接http://www.geoplugin.net/php.gp,您将获得有关该IP地址位置的详细列表,包括纬度和经度。

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

它不是那么精确但它有效,我使用它。这是一个实际使用的PHP脚本:

<?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/

你可以在http://whateverhappens.org/ip-addr/看到它的工作原理

And that a look at the Geoplugin website examples.

那看看Geoplugin网站上的例子。

#3


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

这也可以帮助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

http://www.telize.com和http://www.iptolatlng.com都提供JSON解决方案