vue-baidu-map + mapv 实现百度地图迁徙图动效

index.html引用

<script src='http://api.map.baidu.com/api?v=3.0&ak='></script>
<script src="http://mapv.baidu.com/build/mapv.min.js"></script>

页面

<div style="height:100%;width:100%" ref="asiaMap"></div>
initMapChart() {

	let mapJson = this.japanJson //地图数据json
	
	let myChart = this.$echarts.init(this.$refs["asiaMap"]);
	let name = 'asia'
	this.$echarts.registerMap(name, mapJson);
	let lineData = [//迁徙线起始点
	    [ {
	        coord: [121.406124, 37.460187],//toCoord烟台
	    },{
	        coord: [130.523135, 32.880423],//fromCoord
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [126.622908,40.625553],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [126.917264,37.704522],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [124.084081,47.060744],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [115.915681,39.949276],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [130.927875,31.401204],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [127.634759,35.996901],
	        value: 0
	    }],
	    [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [126.070989,41.957591],
	        value: 0
	    }],
	     [ {
	        coord: [121.406124, 37.460187],
	    },{
	        coord: [128.536226,47.255256],
	        value: 0
	    }],
	]
	let scatterPoints = [
	    {value: [121.406124, 37.460187],itemStyle:{color:'#ffc107'}}
	]
	let option = {
	    backgroundColor: '#0F1C3C',
	    geo: {
	        show: true,
	        map: name,
	        label: {
	            normal: {
	                show: false
	            },
	            emphasis: {
	                show: false,
	            }
	        },
	        //zoom: 1.2,
	        roam: true, //是否开启平游或缩放
	         itemStyle: {
	                normal: {
	                    areaColor: {
	                        x: 0,
	                        y: 0,
	                        x2: 0,
	                        y2: 1,
	                        colorStops: [{
	                            offset: 0,
	                            color: '#073684' // 0% 处的颜色
	                        }, {
	                            offset: 1,
	                            color: '#061E3D' // 100% 处的颜色
	                        }],
	                    },
	                    borderColor: '#2196f3',
	                    borderWidth: 1,
	                },
	                emphasis: {
	                    areaColor: {
	
	                        x: 0,
	                        y: 0,
	                        x2: 0,
	                        y2: 1,
	                        colorStops: [{
	                            offset: 0,
	                            color: '#073684' // 0% 处的颜色
	                        }, {
	                            offset: 1,
	                            color: '#061E3D' // 100% 处的颜色
	                        }],
	                    },
	                }
	            },
	    },
	    series: [
	        {///地图线的动画效果
	            type: 'lines',
	            zlevel: 2,
	            effect: {
	                show: true,
	                period: 4, //箭头指向速度,值越小速度越快
	                trailLength: 0.02, //特效尾迹长度[0,1]值越大,尾迹越长重
	                symbol: 'arrow', //箭头图标
	                symbolSize: 5, //图标大小
	                color:'#ff9800'
	            },
	            lineStyle: {
	                normal: {
	                    width: 1, //尾迹线条宽度
	                    opacity: .5, //尾迹线条透明度
	                    curveness: .1, //尾迹线条曲直度
	                    color:'#ff9800',
	                    type:'dotted'
	                }
	            },
	            data: lineData
	        },   
	        {//涟漪
	            type: 'effectScatter',
	            coordinateSystem: 'geo',
	            showEffectOn: 'render',
	            zlevel:1,
	            rippleEffect: {
	                period: 15,
	                scale: 4,
	                brushType: 'fill'
	            },
	            hoverAnimation: true,
	            itemStyle: {
	                normal: {
	                color:'#1DE9B6'/* function (value){ //随机颜色
	return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);
	}*/,
	                    shadowBlur: 10,
	                    shadowColor: '#333'
	                }
	            },
	            symbolSize: 12,
	            data: scatterPoints
	        }, 
	    ]
	}
	myChart.setOption(option,true);
	},
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值