使用步骤【原生api】
vue中在public/index.html
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
基本的步骤文档中写的很详细了,这边就不多介绍了。申请应用时请注意所选择的类型(Web JS)
同时需要在vue.config.js中
module.exports = {
configureWebpack: {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
externals:{
'AMap':'AMap',
'AMapUI':'AMapUI',
'Loca':'Loca'
}
},
}
在使用的到的vue文件中,否则会报AMap is not defined
import AMap from 'AMap';
new AMap.Map("map", {
resizeEnable: true,
rotateEnable: false,
pitchEnable: true,
zoom: 17,//当前缩放的层级
pitch: