<baidu-map class="bm-view" :center="center" :zoom="zoom" :scroll-wheel-zoom="true" @click="getClickInfo">
<bm-view style="width: 100%; height:500px;"></bm-view>
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
</baidu-map>
export default {
data: function () {
return {
keyword: "",
center: { lng: 116.404, lat: 39.915 },
zoom: 15,
autoViewport: true,
};
},
methods: {
//地图的点击事件
getClickInfo(e) {
this.center.lng = e.point.lng;
this.center.lat = e.point.lat;
console.log(this.center.lng);
console.log(this.center.lat);
},
},
};
值得注意的是你用来装百度地图的那个容器div必须要设置高度,不然的话百度地图不会显示。
二,百度地图相关属性及其控件解释。
A,属性配置: