JSAPI Loader
是高德提供的 API 加载器,可帮助开发者快速定位、有效避免加载引用地图 JSAPI 各种错误用法,具有以下特性:
IE9
以上的浏览器,不支持IE8
以下安装loader包
npm i @amap/amap-jsapi-loader --save-dev
在vue组件中使用 如此
<template>
<div class="home-container">
<h4 class="text-center">AMap疑难问题的解决方案及优秀实例解析</h4>
<div class="flex-center">
<div id="mymap" style="height:500px;width:500px"></div>
</div>
</div>
</template>
<script>
import AMapLoader from "@amap/amap-jsapi-loader";
export default {
name: "Home",
components: {},
data() {
return {
map: null
};
},
mounted() {
this.initMap();
},
methods: {
initMap() {
AMapLoader.load({
key: "your key", // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [] //插件列表
})
.then(AMap => {
this.map = new AMap.Map("mymap");
})
.catch(e => {
console.log(e);
});
}
}
};
</script>
<style lang="scss"></style>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有