當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
【高德地图】------- JavaScript实现高德地图经纬度获取地址位置
生活随笔
收集整理的這篇文章主要介紹了
【高德地图】------- JavaScript实现高德地图经纬度获取地址位置
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.高德地圖通過(guò)經(jīng)緯度獲取地址信息代碼 【需要高德Key值】 里面的參數(shù)我做改變了 不能暴露自己的位置哈哈哈哈
//原生ajaxvar fn_Ajax_Get=function(vapi,callback,errer) {//創(chuàng)建XMLHttpRequestvar xmlHttp;if (window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();}else{// code for IE6, IE5xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}//監(jiān)聽響應(yīng)xmlHttp.onreadystatechange = function () {if (xmlHttp.readyState === 4 && (xmlHttp.status === 200 || xmlHttp.status === 304)) {callback(xmlHttp.responseText);}else{errer(xmlHttp.responseText);}};xmlHttp.open("GET",vapi,false);xmlHttp.send();}; //獲取經(jīng)緯度的地址信息var fn_get_gd_lng_lat_address=function(v_lng,v_lat,v_key){var key="";var address="";if(v_lng && v_lat){if(v_key){key=v_key;}var locationLngLat=v_lng+","+v_lat;var gdUrl="https://restapi.amap.com/v3/geocode/regeo?key={{@key}}&location={{@lnglat}}";gdUrl=gdUrl.replace("{{@key}}",key).replace("{{@lnglat}}",locationLngLat);fn_Ajax_Get(gdUrl,function (ret) {var retJson=JSON.parse(ret);if(retJson.status=="1") {address = retJson.regeocode.formatted_address;}},function (ret) {})}return address;};fn_get_gd_lng_lat_address(116.142421,34.205636,key);?2.得到的數(shù)據(jù)json
{"status":"1","regeocode":{"addressComponent":{"city":"**市","province":"**省","adcode":"32012","district":"**區(qū)","towncode":"3203109000","streetNumber":{"number":"97號(hào)","location":"116.142279,34.205911","direction":"西北","distance":"33.2597","street":"大學(xué)路"},"country":"中國(guó)","township":"**街道","businessAreas":[[]],"building":{"name":[],"type":[]},"neighborhood":{"name":[],"type":[]},"citycode":"0506"},"formatted_address":"**省**市**區(qū)銅山街道***大學(xué)創(chuàng)業(yè)園"},"info":"OK","infocode":"10000"}1.高德地址:概述-Web服務(wù) API | 高德地圖API
總結(jié)
以上是生活随笔為你收集整理的【高德地图】------- JavaScript实现高德地图经纬度获取地址位置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android Ble蓝牙中如何获取Ra
- 下一篇: 基于HTML+CSS+JavaScrip