1.申请AK
**http://lbsyun.baidu.com/apiconsole/key**
2、在vue项目的public文件夹下的index.html中引入脚本
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的密钥"></script>
3、$ npm install vue-baidu-map --save
4、在main.js中全局注册
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
ak: '你申请的key'
})
定位
在mounted中定义:
```css
mounted() {
var map = new BMap.Map("allmap"); //定义地图实例
var point = new BMap.Point(116.331398,39.897445); //定义当前坐标
var self=this
var geolocation = new BMap.Geolocation();
geo