亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    vuejs項目怎么實現(xiàn)百度地圖顯示

    實現(xiàn)方法:1、在“百度地圖開發(fā)平臺”中申請秘鑰;2、在“index.html”中使用script標簽引入地圖鏈接;3、在“APP.vue”中放入相關(guān)js代碼實現(xiàn)百度地圖。

    vuejs項目怎么實現(xiàn)百度地圖顯示

    本教程操作環(huán)境:windows7系統(tǒng)、vue2.9.6版,DELL G3電腦。

    vue在項目中使用百度地圖

    第一步,去百度地圖開發(fā)平臺http://lbsyun.baidu.com/ 申請秘鑰。

    第二步在項目中引入,具體如下

    vuejs項目怎么實現(xiàn)百度地圖顯示

    其中index.html存放地圖鏈接,代碼如下

    vuejs項目怎么實現(xiàn)百度地圖顯示

    然后在APP.vue里面實現(xiàn),代碼如下

    <template>  <div id="app">   <div id="allmap" ref="allmap"></div>   <router-view></router-view>  </div> </template>    <script> export default {  name: 'App',  methods:{   map(){    let map =new BMap.Map(this.$refs.allmap); // 創(chuàng)建Map實例    map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);// 初始化地圖,設(shè)置中心點坐標和地圖級別    map.addControl(new BMap.MapTypeControl({//添加地圖類型控件     mapTypes:[      BMAP_NORMAL_MAP,      BMAP_HYBRID_MAP     ]}));    map.setCurrentCity("北京");// 設(shè)置地圖顯示的城市 此項是必須設(shè)置的    map.enableScrollWheelZoom(true); //開啟鼠標滾輪縮放   }     },  mounted(){   this.map()     } } </script>    <style> #app {  font-family: 'Avenir', Helvetica, Arial, sans-serif;  -webkit-font-smoothing: antialiased;  -moz-osx-font-smoothing: grayscale;  text-align: center;  color: #2c3e50;  margin-top: 60px; } #allmap{  height: 500px;  overflow: hidden;    } </style>

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號