vue用BMap百度地图实现即时搜索功能

2020-06-12 20:52:58易采站长站整理

th.userlocation = local.getResults().getPoi(0).point // 获取第一个智能搜索的结果
map.centerAndZoom(th.userlocation, 18)
map.addOverlay(new BMap.Marker(th.userlocation)) // 添加标注
}

var local = new BMap.LocalSearch(map, { // 智能搜索
onSearchComplete: myFun
})
local.search(myValue)

// 测试输出坐标(指的是输入框最后确定地点的经纬度)
map.addEventListener('click', function(e) {
// 经度
console.log(th.userlocation.lng)
// 纬度
console.log(th.userlocation.lat)
})
}
},)
},
// 新增小区 点击的地址增加进list
add_housing() {
this.add_housing_list.push(this.city)
},
// 删除小区
delete_housing(index) {
// console.log(index)
this.add_housing_list.splice(index, 1)
},
}
}
</script>

<style scoped>
.housingList{
margin-top:20px;
}
.delete_button{
color: #409EFF;
text-decoration: underline;
border:none;
background:#fff;
cursor: pointer;
margin-left:20px;
}

.el-input{
width: 800px;
}
.housing_input .el-input{
width: 730px;
}

#allmap{
width: 400px;
height: 400px;
font-family: "微软雅黑";
display: none;
}

</style>