安装及配置
index.html入口文件中引用高德地图的js
<script src="http://webapi.amap.com/maps?v=1.4.15&key=你申请的key"></script>
在vue.config.js中,定义
configureWebpack: {
externals: {
'AMap': 'AMap'
}
}
注意:需要重启一下才会生效
调用
import AMap from 'AMap'
let map = new AMap.Map('amap', {
resizeEnable: true,
mapStyle: "amap://styles/normal",
center: [119.676881, 29.091466],
lang: "zh_cn",
zoom: 15,
});
//实时路况图层
let marker = new AMap.Marker({
position: [119.676881, 29.091466]
})
map.add(marker);//添加到地图