是否可以根据java中的IP地址知道城市名称?
答案 0 :(得分:4)
填充后,将使用以下城域级粒度属性填充google.loader.ClientLocation对象:
* ClientLocation.latitude — supplies the low resolution latitude associated with the client's IP address
* ClientLocation.longitude — supplies the low resolution longitude associated with the client's IP address
* ClientLocation.address.city — supplies the name of the city associated with the client's IP address
* ClientLocation.address.country — supplies the name of the country associated with the client's IP address
* ClientLocation.address.country_code — supplies the name of the ISO 3166-1 country code associated with the client's IP address
* ClientLocation.address.region — supplies the country specific region name associated with the client's IP address
上的完整文档
答案 1 :(得分:2)
您必须使用hostip.info等将IP映射到其物理位置的服务,并向开发人员提供API以简化任务。
您可以在Google找到许多其他有偿和免费的服务。
答案 2 :(得分:1)
如果其他人建议的在线API不适合您的应用程序,我之前已经成功使用了MaxMind GeoLite City,它带有Java API(以及许多其他API)。只需下载数据库文件,将API代码指向它们,然后就可以了。简单明了。