比较简单,直接调用百度地图API
创建一个查询POI的方法:
searchPOI ( ) {
var local = new BMapGL. LocalSearch ( map, {
renderOptions: { map: map}
} ) ;
local. search ( this . $refs. place. value) ;
} ,
创建一个清除POI点的方法:
clearMarker ( ) {
map. clearOverlays ( ) ;
this . $refs. place. value= "" ;
} ,
添加一个div:
< / div>
< div class = "info" id= "r-result" > 景点查询: < input type= "text" id= "suggestId" size= "20" value= "景点" ref= "place" style= "width:150px;" / > < button @click= "searchPOI" > 查询< / button> < button @click= "clearMarker" > 清除标记< / button> < / div>
< / div>
css
#result{
padding: 7 px 10 px;
position: fixed;
top: 15 rem;
left: 20 px;
width: 450 px;
background: #fff;
box- shadow: 0 2 px 6 px 0 rgba ( 27 , 142 , 236 , 0.5 ) ;
border- radius: 7 px;
z- index: 99 ;
}
#result input{
width: 130 px;
margin- right: 10 px;
height: 25 px;
border: 1 px solid rgba ( 27 , 142 , 236 , 0.5 ) ;
border- radius: 5 px;
}
#result button{
border: 1 px solid rgba ( 27 , 142 , 236 , 0.5 ) ;
border- radius: 5 px;
background: rgba ( 27 , 142 , 236 , 0.5 ) ;
color: #fff
}
. info {
z- index: 999 ;
width: auto;
min- width: 22 rem;
padding: .75 rem 1.25 rem;
margin- left: 1.25 rem;
position: fixed;
top: 10 rem;
background- color: #fff;
border- radius: .25 rem;
font- size: 14 px;
color: #666 ;
box- shadow: 0 2 px 6 px 0 rgba ( 27 , 142 , 236 , 0.5 ) ;
}
#r- result button{
border: 1 px solid rgba ( 27 , 142 , 236 , 0.5 ) ;
border- radius: 5 px;
background: rgba ( 27 , 142 , 236 , 0.5 ) ;
color: #fff
}
效果