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

WBOY
Release: 2016-08-04 09:19:19
Original
1583 people have browsed it

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>
Copy after login

Have you reversed the longitude and latitude parameters

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template