安裝
npm install vue-baidu-map --save
全局注冊
在main.js 里面配置
// 使用百度地圖
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
/* Visit http://lbsyun.baidu.com/apiconsole/key for details about app key. */
ak: '######'
})
vue 頁面使用
<template>
<div>
<baidu-map class="map" :center="center" :zoom="zoom" @ready="handler" />
</div>
</template>
<script>
export default {
data() {
return {
center: {
lng: 0,
lat: 0
},
zoom: 3
}
},
methods: {
handler({ BMap, map }) {
console.log(BMap, map)
this.center.lng = 116.404
this.center.lat = 39.915
this.zoom = 15
},
}
}
</script>
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。