最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

VUE引入騰訊地圖并實(shí)現(xiàn)軌跡動(dòng)畫的詳細(xì)步驟

 更新時(shí)間:2022年09月22日 15:25:31   作者:書中楓葉  
這篇文章主要介紹了VUE引入騰訊地圖并實(shí)現(xiàn)軌跡動(dòng)畫,引入步驟大概是在 html 中通過(guò)引入 script 標(biāo)簽加載API服務(wù),結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下

效果:

引入步驟:

  • 在 html 中通過(guò)引入 script 標(biāo)簽加載API服務(wù)
  • 在一個(gè)盒子元素 div 中預(yù)先準(zhǔn)備地圖容器,并在CSS樣式中定義地圖(容器)顯示大小
  • 創(chuàng)建并顯示地圖的代碼
  • 創(chuàng)建動(dòng)畫和標(biāo)記

1. 在 html 中通過(guò)引入 script 標(biāo)簽加載API服務(wù)

 <script src="https://map.qq.com/api/gljs?v=1.exp&key=你申請(qǐng)的騰訊地圖應(yīng)用key"></script>

2. 在body中預(yù)先準(zhǔn)備地圖容器,并在CSS樣式中定義地圖(容器)顯示大小

<div id="container"></div>
 
  #container {
    width: 100%;
    height: calc(100vh - 280px);
    border-radius: 10px;
    overflow: hidden;
  }

3. 創(chuàng)建并顯示地圖的代碼

 mounted() {
      this.initMap()
    },
 
   methods: {
      initMap() {
        //設(shè)置地圖中心點(diǎn)
        let center = new TMap.LatLng(39.984104, 116.307503);
        // 初始化地圖
        this.map = new TMap.Map('container', {
          zoom: 15,
          center: center,
          // baseMap: {  // 設(shè)置衛(wèi)星地圖
          //   type: 'satellite'
          // }
        });
        this.polylineLayer = new TMap.MultiPolyline({
          map:this.map, // 繪制到目標(biāo)地圖
          // 折線樣式定義
          styles: {
            style_blue: new TMap.PolylineStyle({
              color: '#ff8d00', // 線填充色
              width: 4, // 折線寬度
              borderWidth: 2, // 邊線寬度
              borderColor: '#FFF', // 邊線顏色
              lineCap: 'round', // 線端頭方式
              eraseColor: 'rgb(172,172,172)',//擦除路徑的顏色
            }),
          },
          geometries: [
            {
              id: 'erasePath',
              styleId: 'style_blue',
              paths: this.path,
            },
          ],
        });
        this.marker = new TMap.MultiMarker({
          map:this.map, // 繪制到目標(biāo)地圖
          styles: {
            'car-down': new TMap.MarkerStyle({
              width: 40,
              height: 40,
              anchor: {
                x: 20,
                y: 20,
              },
              faceTo: 'map',
              rotate: 180,
              src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/car.png',
            }),
            start: new TMap.MarkerStyle({
              width: 25,
              height: 35,
              anchor: {x: 16, y: 32},
              src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/start.png',
            }),
            end: new TMap.MarkerStyle({
              width: 25,
              height: 35,
              anchor: {x: 16, y: 32},
              src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/end.png',
            }),
          },
          geometries: [
            {
              id: 'car',
              styleId: 'car-down',
              position: new TMap.LatLng(39.98481500648338, 116.30571126937866),
            },
            {
              id: 'start',
              styleId: 'start',
              position: new TMap.LatLng(39.98481500648338, 116.30571126937866),
            },
            {
              id: 'end',
              styleId: 'end',
              position: new TMap.LatLng(39.978813710266024, 116.31699800491333),
            },
          ],
        });
      }
    }

4. 創(chuàng)建動(dòng)畫和標(biāo)記

?// 暫停動(dòng)畫
? ? ?pauseMove() {
? ? ? ? this.marker.pauseMove()
? ? ? },
? ? ?// 停止動(dòng)畫
? ? ? resumeMove() {
? ? ? ? this.marker.resumeMove()
? ? ? },
? ? ?// 開(kāi)始動(dòng)畫
? ? ? startCar() {
? ? ? ? // 使用marker 移動(dòng)接口, https://lbs.qq.com/webApi/javascriptGL/glDoc/glDocMarker
? ? ? ? //調(diào)用moveAlong動(dòng)畫 執(zhí)行標(biāo)記點(diǎn)動(dòng)畫開(kāi)始
? ? ? ? this.marker.moveAlong(
? ? ? ? ? {
? ? ? ? ? ? car: {
? ? ? ? ? ? ? path: this.path,//移動(dòng)路徑的坐標(biāo)串
? ? ? ? ? ? ? // duration:8000,//完成移動(dòng)所需的時(shí)間,單位:毫秒
? ? ? ? ? ? ? speed: 250, //speed為指定速度,正整數(shù),單位:千米/小時(shí)
? ? ? ? ? ? },
? ? ? ? ? },
? ? ? ? ? {
? ? ? ? ? ? autoRotation: true,//自動(dòng)旋轉(zhuǎn)
? ? ? ? ? }
? ? ? ? );
? ? ? ? //監(jiān)聽(tīng)事件名
? ? ? ? this.marker.on('moving', (e) => {
? ? ? ? ? var passedLatLngs = e.car && e.car.passedLatLngs;
? ? ? ? ? if (passedLatLngs) {
? ? ? ? ? ? // 使用路線擦除接口 eraseTo, https://lbs.qq.com/webApi/javascriptGL/glDoc/glDocVector
? ? ? ? ? ? this.polylineLayer.eraseTo(
? ? ? ? ? ? ? 'erasePath',
? ? ? ? ? ? ? passedLatLngs.length - 1,
? ? ? ? ? ? ? passedLatLngs[passedLatLngs.length - 1]
? ? ? ? ? ? );
? ? ? ? ? }
? ? ? ? });
?
? ? ? },

地圖組件完整代碼

<template>
? <section>
? ? <el-button style="margin: 15px" size="mini" type="danger" @click="startCar">開(kāi)始</el-button>
? ? <el-button style="margin: 15px" size="mini" type="danger" @click="pauseMove">暫停</el-button>
? ? <el-button style="margin: 15px" size="mini" type="info" @click="resumeMove">繼續(xù)</el-button>
? ? <div id="container"></div>
? </section>
</template>
?
<script>
? export default {
? ? name: "mk-map",
? ? data() {
? ? ? return {
? ? ? ? map: null,
? ? ? ? path: [
? ? ? ? ? new TMap.LatLng(39.98481500648338, 116.30571126937866),
? ? ? ? ? new TMap.LatLng(39.982266575222155, 116.30596876144409),
? ? ? ? ? new TMap.LatLng(39.982348784165886, 116.3111400604248),
? ? ? ? ? new TMap.LatLng(39.978813710266024, 116.3111400604248),
? ? ? ? ? new TMap.LatLng(39.978813710266024, 116.31699800491333),
? ? ? ? ? new TMap.LatLng(39.988813710266024, 116.31699800491333),
? ? ? ? ? new TMap.LatLng(39.989813710266024, 116.31699800491333),
? ? ? ? ? new TMap.LatLng(39.990813710266024, 116.31699800491333),
? ? ? ? ? new TMap.LatLng(39.98481500648338, 116.30571126937866),
? ? ? ? ],
? ? ? ? polylineLayer: null,
? ? ? ? marker: null
? ? ? }
? ? },
? ? mounted() {
? ? ? this.initMap()
? ? },
? ? methods: {
? ? ? pauseMove() {
? ? ? ? this.marker.pauseMove()
? ? ? },
? ? ? resumeMove() {
? ? ? ? this.marker.resumeMove()
? ? ? },
? ? ? startCar() {
? ? ? ? // 使用marker 移動(dòng)接口, https://lbs.qq.com/webApi/javascriptGL/glDoc/glDocMarker
? ? ? ? //調(diào)用moveAlong動(dòng)畫 執(zhí)行標(biāo)記點(diǎn)動(dòng)畫開(kāi)始
? ? ? ? this.marker.moveAlong(
? ? ? ? ? {
? ? ? ? ? ? car: {
? ? ? ? ? ? ? path: this.path,//移動(dòng)路徑的坐標(biāo)串
? ? ? ? ? ? ? // duration:8000,//完成移動(dòng)所需的時(shí)間,單位:毫秒
? ? ? ? ? ? ? speed: 250, //speed為指定速度,正整數(shù),單位:千米/小時(shí)
? ? ? ? ? ? },
? ? ? ? ? },
? ? ? ? ? {
? ? ? ? ? ? autoRotation: true,//自動(dòng)旋轉(zhuǎn)
? ? ? ? ? }
? ? ? ? );
? ? ? ? //監(jiān)聽(tīng)事件名
? ? ? ? this.marker.on('moving', (e) => {
? ? ? ? ? var passedLatLngs = e.car && e.car.passedLatLngs;
? ? ? ? ? if (passedLatLngs) {
? ? ? ? ? ? // 使用路線擦除接口 eraseTo, https://lbs.qq.com/webApi/javascriptGL/glDoc/glDocVector
? ? ? ? ? ? this.polylineLayer.eraseTo(
? ? ? ? ? ? ? 'erasePath',
? ? ? ? ? ? ? passedLatLngs.length - 1,
? ? ? ? ? ? ? passedLatLngs[passedLatLngs.length - 1]
? ? ? ? ? ? );
? ? ? ? ? }
? ? ? ? });
?
? ? ? },
? ? ? initMap() {
? ? ? ? //設(shè)置地圖中心點(diǎn)
? ? ? ? let center = new TMap.LatLng(39.984104, 116.307503);
? ? ? ? // 初始化地圖
? ? ? ? this.map = new TMap.Map('container', {
? ? ? ? ? zoom: 15,
? ? ? ? ? center: center,
? ? ? ? ? // baseMap: { ?// 設(shè)置衛(wèi)星地圖
? ? ? ? ? // ? type: 'satellite'
? ? ? ? ? // }
? ? ? ? });
? ? ? ? this.polylineLayer = new TMap.MultiPolyline({
? ? ? ? ? map:this.map, // 繪制到目標(biāo)地圖
? ? ? ? ? // 折線樣式定義
? ? ? ? ? styles: {
? ? ? ? ? ? style_blue: new TMap.PolylineStyle({
? ? ? ? ? ? ? color: '#ff8d00', // 線填充色
? ? ? ? ? ? ? width: 4, // 折線寬度
? ? ? ? ? ? ? borderWidth: 2, // 邊線寬度
? ? ? ? ? ? ? borderColor: '#FFF', // 邊線顏色
? ? ? ? ? ? ? lineCap: 'round', // 線端頭方式
? ? ? ? ? ? ? eraseColor: 'rgb(172,172,172)',//擦除路徑的顏色
? ? ? ? ? ? }),
? ? ? ? ? },
? ? ? ? ? geometries: [
? ? ? ? ? ? {
? ? ? ? ? ? ? id: 'erasePath',
? ? ? ? ? ? ? styleId: 'style_blue',
? ? ? ? ? ? ? paths: this.path,
? ? ? ? ? ? },
? ? ? ? ? ],
? ? ? ? });
? ? ? ? this.marker = new TMap.MultiMarker({
? ? ? ? ? map:this.map, // 繪制到目標(biāo)地圖
? ? ? ? ? styles: {
? ? ? ? ? ? 'car-down': new TMap.MarkerStyle({
? ? ? ? ? ? ? width: 40,
? ? ? ? ? ? ? height: 40,
? ? ? ? ? ? ? anchor: {
? ? ? ? ? ? ? ? x: 20,
? ? ? ? ? ? ? ? y: 20,
? ? ? ? ? ? ? },
? ? ? ? ? ? ? faceTo: 'map',
? ? ? ? ? ? ? rotate: 180,
? ? ? ? ? ? ? src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/car.png',
? ? ? ? ? ? }),
? ? ? ? ? ? start: new TMap.MarkerStyle({
? ? ? ? ? ? ? width: 25,
? ? ? ? ? ? ? height: 35,
? ? ? ? ? ? ? anchor: {x: 16, y: 32},
? ? ? ? ? ? ? src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/start.png',
? ? ? ? ? ? }),
? ? ? ? ? ? end: new TMap.MarkerStyle({
? ? ? ? ? ? ? width: 25,
? ? ? ? ? ? ? height: 35,
? ? ? ? ? ? ? anchor: {x: 16, y: 32},
? ? ? ? ? ? ? src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/end.png',
? ? ? ? ? ? }),
? ? ? ? ? },
? ? ? ? ? geometries: [
? ? ? ? ? ? {
? ? ? ? ? ? ? id: 'car',
? ? ? ? ? ? ? styleId: 'car-down',
? ? ? ? ? ? ? position: new TMap.LatLng(39.98481500648338, 116.30571126937866),
? ? ? ? ? ? },
? ? ? ? ? ? {
? ? ? ? ? ? ? id: 'start',
? ? ? ? ? ? ? styleId: 'start',
? ? ? ? ? ? ? position: new TMap.LatLng(39.98481500648338, 116.30571126937866),
? ? ? ? ? ? },
? ? ? ? ? ? {
? ? ? ? ? ? ? id: 'end',
? ? ? ? ? ? ? styleId: 'end',
? ? ? ? ? ? ? position: new TMap.LatLng(39.978813710266024, 116.31699800491333),
? ? ? ? ? ? },
? ? ? ? ? ],
? ? ? ? });
? ? ? }
? ? }
? }
</script>
?
<style lang="scss" scoped>
? #container {
? ? width: 100%;
? ? height: calc(100vh - 280px);
? ? border-radius: 10px;
? ? overflow: hidden;
? }
</style>

到此這篇關(guān)于VUE引入騰訊地圖并實(shí)現(xiàn)軌跡動(dòng)畫的文章就介紹到這了,更多相關(guān)vue引入騰訊地圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 解決報(bào)錯(cuò)ValidationError: Progress Plugin Invalid Options問(wèn)題

    解決報(bào)錯(cuò)ValidationError: Progress Plugin Invalid&

    這篇文章主要介紹了解決報(bào)錯(cuò)ValidationError: Progress Plugin Invalid Options問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • Vue 實(shí)現(xiàn)CLI 3.0 + momentjs + lodash打包時(shí)優(yōu)化

    Vue 實(shí)現(xiàn)CLI 3.0 + momentjs + lodash打包時(shí)優(yōu)化

    今天小編就為大家分享一篇Vue 實(shí)現(xiàn)CLI 3.0 + momentjs + lodash打包時(shí)優(yōu)化,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-11-11
  • element中TimePicker時(shí)間選擇器禁用部分時(shí)間(顯示禁用到分鐘)

    element中TimePicker時(shí)間選擇器禁用部分時(shí)間(顯示禁用到分鐘)

    這篇文章主要介紹了element中TimePicker時(shí)間選擇器禁用部分時(shí)間(顯示禁用到分鐘),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • element step組件在另一側(cè)加時(shí)間軸顯示

    element step組件在另一側(cè)加時(shí)間軸顯示

    本文主要介紹了element step組件在另一側(cè)加時(shí)間軸顯示,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • Vue中的Props(不可變狀態(tài))

    Vue中的Props(不可變狀態(tài))

    這篇文章主要介紹了Vue中的Props(不可變狀態(tài)),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-09-09
  • Vue自定義表單內(nèi)容檢查rules實(shí)例

    Vue自定義表單內(nèi)容檢查rules實(shí)例

    這篇文章主要介紹了Vue自定義表單內(nèi)容檢查rules實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-10-10
  • vue3中項(xiàng)目?jī)?yōu)化方法詳解(Web?Worker的使用)

    vue3中項(xiàng)目?jī)?yōu)化方法詳解(Web?Worker的使用)

    最近在做vue3的項(xiàng)目中,遇到了計(jì)算量龐大導(dǎo)致頁(yè)面響應(yīng)緩慢的問(wèn)題,所以下面這篇文章主要給大家介紹了關(guān)于vue3中項(xiàng)目?jī)?yōu)化方法的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-07-07
  • vue實(shí)現(xiàn)點(diǎn)擊按鈕下載文件功能

    vue實(shí)現(xiàn)點(diǎn)擊按鈕下載文件功能

    這篇文章主要介紹了vue中點(diǎn)擊按鈕下載文件,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-10-10
  • Vue項(xiàng)目添加前綴,ngnix發(fā)布相關(guān)修改問(wèn)題

    Vue項(xiàng)目添加前綴,ngnix發(fā)布相關(guān)修改問(wèn)題

    這篇文章主要介紹了Vue項(xiàng)目添加前綴,ngnix發(fā)布相關(guān)修改問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • vue中解決微信html5原生ios虛擬鍵返回不刷新問(wèn)題

    vue中解決微信html5原生ios虛擬鍵返回不刷新問(wèn)題

    這篇文章主要介紹了vue中解決微信html5原生ios虛擬鍵返回不刷新問(wèn)題,本文給大家分享解決方法,通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10

最新評(píng)論

大荔县| 巴林右旗| 大洼县| 达拉特旗| 霍城县| 冕宁县| 宁海县| 玉树县| 平江县| 紫云| 广灵县| 连云港市| 渭源县| 靖安县| 务川| 武山县| 辽阳县| 来凤县| 安龙县| 洱源县| 平乐县| 京山县| 双牌县| 义马市| 教育| 靖远县| 华安县| 瑞昌市| 凌海市| 津市市| 达日县| 洪泽县| 贵德县| 桦川县| 渭源县| 宜黄县| 通江县| 阿克苏市| 利津县| 龙江县| 剑阁县|