vue調用高德地圖


1、申請高德地圖key

地址:https://lbs.amap.com/dev/key/app

2、在index.html頁面引入cdn

 

3、在地圖組件的頁面引入Amap

 1 <template>
 2   <div>
 3     <div id="container" style="width:100%; height:900px"></div>
 4   </div>
 5 </template>
 6 
 7 <script>
 8   import AMap from 'AMap'
 9   export default {
10     mounted: function () {
11       this.init()
12     },
13     methods: {
14       init: function () {
15         const map = new AMap.Map('container', {
16           center: [116.397428, 39.90923],
17           resizeEnable: true,
18           zoom: 10
19         })
20         AMap.plugin(['AMap.ToolBar', 'AMap.Scale'], function () {
21           map.addControl(new AMap.ToolBar())
22           map.addControl(new AMap.Scale())
23         })
24       }
25     }
26   }
27 </script>

4、效果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM