日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > javascript >内容正文

javascript

【高德地图】------- JavaScript实现高德地图经纬度获取地址位置

發(fā)布時(shí)間:2023/12/31 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【高德地图】------- 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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。