這篇文章將為大家詳細(xì)講解有關(guān)vue怎么使用高德地圖根據(jù)坐標(biāo)定位點,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
正文
<script> var map,marker; export default { data(){ return{ arriveCoor:[108.947025,34.2613255],//坐標(biāo)點 arrive:"",//位置信息 } }, mounted() { mapDraw(this.arriveCoor), mapCoor(this.arriveCoor) }, methods:{ mapDraw(arriveCoor){ map = new AMap.Map('map-location', { //map-location是嵌地圖div的id resizeEnable: true, //是否監(jiān)控地圖容器尺寸變化 zoom:16, //初始化地圖層級 center: arriveCoor //初始化地圖中心點 }); // 定位點 this.addMarker(arriveCoor); }, // 實例化點標(biāo)記 addMarker(arriveCoor) { var _this = this; marker = new AMap.Marker({ icon: "", //圖片ip imageSize: "20px", position: arriveCoor, offset: new AMap.Pixel(-13, -30), // 設(shè)置是否可以拖拽 draggable: true, cursor: 'move', // 設(shè)置拖拽效果 raiseOnDrag: true }); marker.setMap(map); }, // 查詢坐標(biāo) mapCoor(lnglatXY){ var _this = this; AMap.service('AMap.Geocoder',function() {//回調(diào)函數(shù) var geocoder = new AMap.Geocoder({}); geocoder.getAddress(lnglatXY, function (status, result) { if (status === 'complete' && result.info === 'OK') { //獲得了有效的地址信息: _this.arrive = result.regeocode.formattedAddress; else { _this.arrive = "暫無位置"; } }); }) }, } </script>
關(guān)于“vue怎么使用高德地圖根據(jù)坐標(biāo)定位點”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
當(dāng)前文章:vue怎么使用高德地圖根據(jù)坐標(biāo)定位點-創(chuàng)新互聯(lián)
文章源于:http://m.rwnh.cn/article34/ggipe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、服務(wù)器托管、微信公眾號、企業(yè)建站、搜索引擎優(yōu)化、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容