Home  >  Article  >  Backend Development  >  How to get the current city name through latitude and longitude with javascript?

How to get the current city name through latitude and longitude with javascript?

WBOY
WBOYOriginal
2016-08-04 09:19:191546browse

In WeChat development, we need to get the current city. I use Amap, but some cities are positioned incorrectly. For example, Shenzhen will be positioned to Chengdu. Is there any other way to locate the current city, such as obtaining the longitude and latitude obtained through HTML5? city ​​

Reply content:

In WeChat development, we need to get the current city. I use Amap, but some cities are positioned incorrectly. For example, Shenzhen will be positioned to Chengdu. Is there any other way to locate the current city, such as obtaining the longitude and latitude obtained through HTML5? city ​​

WeChat has its own location interface https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
You can use IP location and link the IP library to search.
Sina interface http://int .dpool.sina.com.cn/iplookup/iplookup.php?format=js

<code><script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
<script>
    alert(remote_ip_info.province + '\n' + remote_ip_info.city)
</script>
</code>

Have you reversed the longitude and latitude parameters

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn