您好,欢迎访问一九零五行业门户网

javascript - ip地址如何转换为经纬度坐标?

最近,在做地图相关的应用。
有大量的用户数据是ip地址,如果把用户标记在地图上,需要把ip地址转换为经纬度坐标。
请问有没有可行的办法实现?
回复内容: 最近,在做地图相关的应用。
有大量的用户数据是ip地址,如果把用户标记在地图上,需要把ip地址转换为经纬度坐标。
请问有没有可行的办法实现?
我曾经做过一个类似的事情,使用的方案比较折腾:
nginx 有 geoip 的模块,检查安装的 nginx 是否编译了这个模块。nginx -vnginx version: nginx/1.1.19tls sni support enabledconfigure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module
如果是没有重新编译一个带 geoip 模块的 nginx 使用。
nginx 的配置文件配置 geoip 的数据库,geoip 的数据库有收费的,也有免费的下载,我都是用免费的,经常更新一下即可。http { geoip_country /etc/nginx/geoip.dat; geoip_city /etc/nginx/geolitecity.dat;}
geo 的信息就可以通过fastcgi的参数传递给应用了,以下是django的一段 fastcgi 配置示例。#geoipfastcgi_param geoip_country_code $geoip_city_country_code;fastcgi_param geoip_country_code3 $geoip_country_code3;fastcgi_param geoip_country_name $geoip_country_name;fastcgi_param geoip_city_country_code $geoip_city_country_code;fastcgi_param geoip_city_country_code3 $geoip_city_country_code3;fastcgi_param geoip_city_country_name $geoip_city_country_name;fastcgi_param geoip_region $geoip_region;fastcgi_param geoip_city $geoip_city;fastcgi_param geoip_postal_code $geoip_postal_code;fastcgi_param geoip_city_continent_code $geoip_city_continent_code;fastcgi_param geoip_lat $geoip_latitude;fastcgi_param geoip_lng $geoip_longitude;
django 把得到的经纬度通过 ajax 传递到前台,交给 google map api 显示即可。如果是国内的 ip 可能就不准确,我用了纯真ip的数据库,方法 google 一下有很多。这个方法的限定是使用 nginx + fastcgi,不是适合所有的人。
无意义。ip地址转换过来是城市信息。城市信息得到的经纬度是地区行政规划中心点。
我也有做ip 地理位置查询站点的想法。
查了下,http://www.iplocationtools.com/ 这个api 看起来比较靠谱。
此网站 http://www.ipgeo.com/ 也号称提供api,但是api 的域名都无法解析。
sae 也提供付费的接口。
看看这个有没有帮助 https://developers.google.com/maps/do...
http://freegeoip.net/static/index.htm...
返回jsonp数据。
http://www.haoservice.com/docs/8 这里是经纬度数据接口,根据提供坐标等查询位置
其它类似信息

推荐信息