vue 使用高德地圖實(shí)現(xiàn)搜索+點(diǎn)擊定位效果

首先需要在index.html中引入高德地圖的資源鏈接,key需要換成你自己的key

cnpm install vue-amap --save-dev 安裝高德地圖依賴

在build/webpack.base.config.js中的module.exports中添加

html部分
js部分


css部分


#wrap{

width:100%;

display:flex;

}

#iCenter {

height:600px;

position:relative;

display:flex;

flex:1;

}

#searchWrap{

width:300px;

position:relative;

height:600px;

.searchWrap{

position:absolute;

width:300px;

z-index:9;

display:flex;

align-items:center;

input{

width:260px;

height:24px;

}

button{

width:36px;

height:28px;

}

}

#result {

width:300px;

position:absolute;

top:30px;

height:570px;

z-index:8;

overflow-y:scroll;

border-right:1px solid #ccc;

}

}

.amap_lib_placeSearch {

height:100%;

overflow-y:scroll;

.poibox {

border-bottom:1px solid #eaeaea;

cursor:pointer;

padding:5px 0 5px 10px;

position:relative;

min-height:35px;

.selected {

background-image:url(https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png)!important;

}

&:hover {

background:#f6f6f6;

}

.poi-img {

float:right;

margin:3px 8px 0;

width:90px;

height:56px;

overflow:hidden;

}

.poi-title {

margin-left:25px;

font-size:13px;

overflow:hidden;

}

.poi-info {

word-break:break-all;

margin:0 0 0 25px;

overflow:hidden;

p {

color:#999;

font-family:Tahoma;

line-height:20px;

font-size:12px;

}

}

.poibox-icon {

margin-left:7px;

margin-top:4px;

}

.amap_lib_placeSearch_poi {

background:url(https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png)

no-repeat;

height:31px;

width:19px;

cursor:pointer;

left:-1px;

text-align:center;

color:#fff;

font:12px arial,simsun,sans-serif;

padding-top:3px;

position:absolute;

}

}

}


借鑒的是一個(gè)小姐姐的文章,但是鏈接找不到了,不好意思!

可以復(fù)制代碼的鏈接:https://blog.csdn.net/qq_42165062/article/details/92782197

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容