How to get city name based on IP address in java?

后端 未结 3 1710
心在旅途
心在旅途 2020-12-03 16:48

Is it possible to know the city name based on IP address in java?

3条回答
  •  情深已故
    2020-12-03 17:22

    are you using jsp or what ? for city name over client side you can use google's API which will return you the geographical details of the user mapped with the IP. As google's documentation say you can get the following

    When populated, the google.loader.ClientLocation object is populated with the following metro-level granularity properties:

    * 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
    

    for further reference see the complete documentation at http://code.google.com/apis/ajax/documentation/

提交回复
热议问题