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

vue如何使用原生高德地圖你知道嗎

 更新時間:2022年02月27日 17:33:52   作者:大得369  
這篇文章主要為大家詳細(xì)介紹了vue如何使用原生高德地圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助

1、先在vue項目根目錄下新建vue.config.js,這個文件是沒有的,vue不提供

module.exports = {
  configureWebpack: {
	  externals: {
		'AMap': 'AMap', // 高德地圖配置
		'AMapUI': 'AMapUI'
	  }
  },
}

2、在vue文件index.html中引入高德地圖js文件

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>default</title>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but default doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
	<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.3&key=你的高德地圖key&plugin=AMap.ControlBar"></script>
  </body>
</html>

3、在vue文件中使用

<template>
  <div class="box">
    <div id="container" style="width:1500px; height:900px"></div>
  </div>
</template>
<script>
import AMap from 'AMap' // 引入高德地圖
let map,marker;
export default {
  data() {
    return {
       markers : [
         {
              icon: 1,
              position: [121.506377, 31.243105],
              name:'張三',
          }, {
              icon: 1,
              position: [121.506077, 31.242105],
              name:'李四',
          }, {
              icon: 1,
              position: [121.506577, 31.240105],
              name:'王五',
          }
      ]
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
      let that = this;
       map = new AMap.Map('container', {
          resizeEnable: true,
          rotateEnable:true,
          pitchEnable:true,
          zoom: 17,
          pitch:50,
          rotation:-15,
          viewMode:'3D',//開啟3D視圖,默認(rèn)為關(guān)閉
          buildingAnimation:true,//樓塊出現(xiàn)是否帶動畫
          // expandZoomRange:true,
          zooms:[3,20],
          center:that.markers[0].position
      })
      AMap.plugin(['AMap.ControlBar',], function(){
              // 添加 3D 羅盤控制
              map.addControl(new AMap.ControlBar());
      });
      this.addMarker(this.markers)
    },
    //拖動事件
    mapDraw(arriveCoor){
         map = new AMap.Map('container', {   //map-location是嵌地圖div的id
              resizeEnable: true, //是否監(jiān)控地圖容器尺寸變化
              zoom:20, //初始化地圖層級
              center: arriveCoor //初始化地圖中心點
         });
         // 定位點
          this.addMarker(arriveCoor);
    },
    // 實例化點標(biāo)記
    addMarker(arriveCoor) {
       var _this = this;
       arriveCoor.forEach(item=>{
          marker = new AMap.Marker({
              icon: item.icon,  //圖片ip
              imageSize: "20px",
              position: [item.position[0], item.position[1]],
              // offset: new AMap.Pixel(-13, -30),
              content:`<div class="custom-content-marker"><span style="display:block;width:200px">${item.name}</span><img src=${mapicon} onclick="clickImgMarker(${item.name})"></div>`,
              // 設(shè)置是否可以拖拽
              draggable: true,
              cursor: 'move',
              // 設(shè)置拖拽效果
              // raiseOnDrag: true
          });
          marker.setMap(map);
      })
    },
  },
}
</script>

5、衛(wèi)星圖動漫切換鏡頭,動畫效果

<template>
  <div class="box">
	  <div style="position: absolute;z-index: 10;cursor:pointer" @click="animates()">點擊去鼎旺中心</div>
    <div id="container" style="width: 2400px;height: 920px;"></div>
  </div>
</template>
<script>
import AMap from 'AMap' // 引入高德地圖
var map;
export default {
  data() {
    return {
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
       var _this = this;
       map = new AMap.Map('container', {
          resizeEnable: true,
          rotateEnable:true,
          pitchEnable:true,
          zoom: 13,
		  pitch: 65,
		  rotation: 45,
          viewMode:'3D',//開啟3D視圖,默認(rèn)為關(guān)閉
          buildingAnimation:true,//樓塊出現(xiàn)是否帶動畫
          expandZoomRange:true,
          center:[113.2385,22.96605],
		  layers: [
			// 高德默認(rèn)標(biāo)準(zhǔn)圖層
			new AMap.TileLayer.Satellite(),
			// 樓塊圖層
			new AMap.Buildings({
				zooms: [16, 18],
				zIndex: 10,
				heightFactor: 2 //2倍于默認(rèn)高度,3D下有效
			}),
		  ],
      })
	  //定位鼎旺中心
	  var maskerIn = new AMap.Marker({
		position:[113.2385,22.96605],
		map:map
	  });
	  var loca = window.loca = new Loca.Container({
	      map,
	  });
	  var pl = window.pl = new Loca.PolygonLayer({
	        zIndex: 120,
	        shininess: 10,
	        hasSide: true,
	        cullface: 'back',
	        depth: true,
	    });
	    pl.setLoca(loca);
	    map.on('complete', function () {
	        loca.animate.start();
	        // setTimeout(_this.animates, 2000);//調(diào)用鏡頭動畫
	    });
    }, 
	//點擊調(diào)用精通動漫
	animates(){
		var speed = 1;
		loca.viewControl.addAnimates([
		   // 尋跡
		   {
			  center: {
			  value: [113.2385,22.96605],
			  control: [[113.2385,22.96605], [113.2385,22.96605]],
			  timing: [0.3, 0, 0.1, 1],
			  duration: 8000 / speed,
			},
			//快速移動,前進(jìn)
			zoom: {
			  value: 17,
			  control: [[0.3, 15], [1, 17]],
			  timing: [0.3, 0, 0.7, 1],
			  duration: 4000 / speed,
			},
		  }, {
			// 環(huán)繞
			rotation: {
			  value: 270,
			  control: [[0, 0], [1, 270]],
			  timing: [0, 0, 0, 1],
			  duration: 7000 / speed,
			},
			//前進(jìn)
			zoom: {
			  value: 17,
			  control: [[0.3, 16], [1, 17]],
			  timing: [0.3, 0, 0.7, 1],
			  duration: 5000 / speed,
			},
		  }], function () {
			pl.hide(1000);
			setTimeout(animate, 2000);
			console.log('結(jié)束');
		});
	},
  },
}
</script>
<style>
	.amap-e, .amap-maps {
	    width: 100%;
	    height: 100%;
	    outline: none;
	    background: #050b17;
	}
	.amap-copyright {
	    display: none!important;
	    left: 77px;
	    height: 16px;
	    bottom: 0;
	    padding-bottom: 2px;
	    font-size: 11px;
	    font-family: Arial,sans-serif;
	}
	.amap-copyright, .amap-logo {
	    display: none!important;
	}
</style>

總結(jié)

本篇文章就到這里了,希望能夠給你帶來幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!   

相關(guān)文章

  • VUE學(xué)習(xí)之Element-ui文件上傳實例詳解

    VUE學(xué)習(xí)之Element-ui文件上傳實例詳解

    今天進(jìn)行了element?文件上傳組件的運用,寫一下心得,下面這篇文章主要給大家介紹了關(guān)于VUE學(xué)習(xí)之Element-ui文件上傳的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-10-10
  • vue項目配置element-ui容易遇到的坑及解決

    vue項目配置element-ui容易遇到的坑及解決

    這篇文章主要介紹了vue項目配置element-ui容易遇到的坑及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • Vue3中emit傳值的具體使用

    Vue3中emit傳值的具體使用

    Emit是Vue3中另一種常見的組件間傳值方式,它通過在子組件中觸發(fā)事件并將數(shù)據(jù)通過事件參數(shù)傳遞給父組件來實現(xiàn)數(shù)據(jù)傳遞,本文就來介紹一下Vue3 emit傳值,感興趣的可以了解一下
    2023-12-12
  • Vue3與pywebview實現(xiàn)獲取本地文件夾的絕對路徑

    Vue3與pywebview實現(xiàn)獲取本地文件夾的絕對路徑

    這篇文章主要為大家詳細(xì)介紹了Vue3如何結(jié)合pywebview實現(xiàn)獲取本地文件夾的絕對路徑,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下
    2024-11-11
  • Vue自定義指令實現(xiàn)點擊右鍵彈出菜單示例詳解

    Vue自定義指令實現(xiàn)點擊右鍵彈出菜單示例詳解

    這篇文章主要為大家介紹了Vue自定義指令實現(xiàn)點擊右鍵彈出菜單示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • vue路由懶加載的實現(xiàn)方法

    vue路由懶加載的實現(xiàn)方法

    本篇文章主要介紹了vue路由懶加載的實現(xiàn)方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • 如何解決ECharts圖表切換后縮成一團(tuán)的問題

    如何解決ECharts圖表切換后縮成一團(tuán)的問題

    這篇文章主要介紹了如何解決ECharts圖表切換后縮成一團(tuán)的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • Vue3中v-if和v-for優(yōu)先級實例詳解

    Vue3中v-if和v-for優(yōu)先級實例詳解

    Vue.js中使用最多的兩個指令就是v-if和v-for,下面這篇文章主要給大家介紹了關(guān)于Vue3中v-if和v-for優(yōu)先級的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • 解決ele ui 表格表頭太長問題的實現(xiàn)

    解決ele ui 表格表頭太長問題的實現(xiàn)

    這篇文章主要介紹了解決ele ui 表格表頭太長問題的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 公共Hooks封裝useTableData表格數(shù)據(jù)實例

    公共Hooks封裝useTableData表格數(shù)據(jù)實例

    這篇文章主要為大家介紹了公共Hooks封裝useTableData表格數(shù)據(jù)實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12

最新評論

永靖县| 马龙县| 崇左市| 濮阳市| 大英县| 石家庄市| 安康市| 巴林右旗| 鹿邑县| 莒南县| 宝坻区| 永修县| 安义县| 邵阳市| 什邡市| 昭平县| 贺州市| 宁乡县| 瑞金市| 旬邑县| 巫溪县| 谷城县| 宁海县| 金山区| 张北县| 安多县| 潞西市| 登封市| 盐源县| 博兴县| 白山市| 莎车县| 昌吉市| 互助| 河津市| 靖边县| 定日县| 安溪县| 本溪| 吉木乃县| 渑池县|