安装插件
npm i --save vue-baidu-map
如何使用?
main.js
// 引入百度地图
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
ak: '' // 在此输入你自己的百度地图ak
})
<template>
<div class="map-site">
<baidu-map
:style="'height:'+height+';width:100%'"
class="map"
ak="" // 你自己的百度 ak
:scroll-wheel-zoom="true"
:zoom="14"
@ready="handle"
@click="getClickInfo"
@moving="syncCenterAndZoom"
@moveend="syncCenterAndZoom"
@zoomend="syncCenterAndZoom">
<bm-view style="width: 100%; height:500px;"></bm-view>
<bm-marker
:position="{ lng: center.lng, lat: center.lat }"
:dragging="true"