通过经度和纬度获取国家/地区名称 [英] get country name by latitude and longitude

查看:117
本文介绍了通过经度和纬度获取国家/地区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人
我想找到一种方法来使用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>


这篇关于通过经度和纬度获取国家/地区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆