根据上一篇博客代码,继续:mounted钩子函数内的内容就省略了
<template>
<div >
<div id="allmap">
<div id="map"</div>
</div>
<div id="r-result" style="">
<el-input placeholder="请输入内容" @keyup.enter.native="searchAddr" v-model="positionValue" class="input-with-select">
<el-button slot="append" icon="iconfont icon-chaxun" class="searchBtn" @click="searchAddr"></el-button>
</el-input>
</div>
</div>
</template>
<script>
export default {
name: "baiduMap",
data(){
return {
positionValue: '',
map: '', //地图
}
},
mounted() {},
methods: {
/**
* 查询地点事件
*/
searchAddr() {
let _this = this;
var local = new BMap.LocalSearch(this.map, {
renderOptions:{map: this.map}
});
local.search(this.positionValue);
setTimeout(function(){
_this.map.setZoom(12);
}, 1000); //2秒后放大到14级
},
}
}
</script>
<style>
#allmap {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>