Heim  >  Artikel  >  Backend-Entwicklung  >  javascript通过经纬度获取当前城市名?

javascript通过经纬度获取当前城市名?

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

在微信开发里需要获取当前城市,我用的高德地图,但有的城市定位有误,比如在深圳会定位到成都,有没有其他方法可以定位到当前城市,例如通过html5获取的经纬度获取城市

回复内容:

在微信开发里需要获取当前城市,我用的高德地图,但有的城市定位有误,比如在深圳会定位到成都,有没有其他方法可以定位到当前城市,例如通过html5获取的经纬度获取城市

微信自带位置接口https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
可以用ip定位,链接ip库查找.
新浪接口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>

你是不是经纬参数弄反了

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn