久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

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

      vue.js怎么引入地圖

      vue.js引入地圖的方法:1、進入天地圖官網(wǎng)拿到密鑰;2、在vue項目中的index.html中引入對應(yīng)的src;3、新建map.js文件,在vue頁面中引用即可。

      vue.js怎么引入地圖

      本文操作環(huán)境:windows10系統(tǒng)、vue 2.5.2、thinkpad t480電腦。

      要在vue項目中引入地圖其實有很多種方法,比如我們可以使用天地圖、vue-amap燈的功能,兩種方式各有優(yōu)勢,大家可以根據(jù)自己的需要來進行選擇。這里就介紹下天地圖方式。

      具體方法步驟如下所示:

      第一步是按照天地圖官網(wǎng)拿到自己的key(密鑰)

      第二步是在你的vue項目中的 index.html 中引入對應(yīng)的src。

      <script src="//api.tianditu.gov.cn/api?v=4.0&tk=396a532e3cc05a260931d1b308636316"></script>

      第三步就是建一個js文件 Map.js ,方便天地圖的引入,此文件可以放在你方便引入的位置。Map.js 中代碼如下

      // 初始化地圖 export default {   init() {     return new Promise((resolve, reject) => {       // 如果已加載直接返回       if (window.T) {         console.log('地圖腳本初始化成功...')         resolve(window.T)         reject('error')       }     })   } }

      第四步就可以在使用的vue頁面中引用了。代碼如下

      <template>     <div class="home">         <div id="bdmap" class="map" style ="position:absolute;bottom:0px;top:0px;width:100%"></div>     </div> </template> <script> import MapInit from "@/components/Map.js"  export default {     data(){         return{             map: null,         }     },     created(){         this.init()     },     methods:{         init(){             MapInit.init().then(             T => {                 this.T = T;                 const imageURL = "http://t0.tianditu.gov.cn/img_c/wmts?tk=您的密鑰";                 const lay = new T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 });                 const config = { layers: [lay], name: 'TMAP_SATELLITE_MAP' };                 this.map = new T.Map('bdmap', config);                 const ctrl = new T.Control.MapType();                 this.map.addControl(ctrl);                 this.map.centerAndZoom(new T.LngLat(118.62, 28.75), 16)                 this.map.addEventListener("zoomend", () => {                 console.log(lay.Pe)             });             }).catch()             // 監(jiān)聽縮放級別(縮放后的級別)                      }     } } </script> <style> .map{     width: 100vw;     height: 100%;     position: absolute; } </style>

      推薦學(xué)習(xí):php培訓(xùn)

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