通过经度和纬度获取国家/地区名称
问题描述:
亲爱的所有人
我想找到一种方法来使用javascript中的经度和纬度来获取国家/地区的名称,请注意,我想使用国家/地区代码显示该国家/地区的图片.
我找到了提供国家/地区代码的服务器,但无法在javascript中使用它.
这是一个例子:
http://ws.geonames.org/countryCode?lat=49.03&lng=10.2 [ ^ ]
dear all
I want to find a method to get the name of the country using latitude and longitude in javascript ,note that i want to use the country code to show a picture for that country .
I found a server that gives the country code but i cant use it in javascript .
here is an example :
http://ws.geonames.org/countryCode?lat=49.03&lng=10.2[^]
答
您可以使用Google地图查找给定纬度和经度的国家/地区.请参阅: https://developers.google.com/maps/documentation/javascript/services#ReverseGeocoding [^ ].您可以从服务器获得的响应中获得国家,城市,邮政编码和完整地址,如下所示:
You can use google maps to find the country for given latitudes and longitudes. Refer at: https://developers.google.com/maps/documentation/javascript/services#ReverseGeocoding[^]. You can get the country, city, zip code and the complete address from the response you get from the server as:
<form id="form1" runat="server">
<div>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js" ></script>
<br />Country Code:
<script type="text/javascript">document.write(geoip_country_code());</script>
<br />Country Name:
<script type="text/javascript">document.write(geoip_country_name());</script>
<br />City:
<script type="text/javascript">document.write(geoip_city());</script>
<br />Region:
<script type="text/javascript">document.write(geoip_region());</script>
<br />Region Name:
<script type="text/javascript">document.write(geoip_region_name());</script>
<br />Latitude:
<script type="text/javascript">document.write(geoip_latitude());</script>
<br />Longitude:
<script type="text/javascript">document.write(geoip_longitude());</script>
<br />Postal Code:
<script type="text/javascript">document.write(geoip_postal_code());</script>
</div>
</form>