页面效果如下:

项目结构如下:

引入的包

"dependencies": {
"core-js": "^3.3.2",
"register-service-worker": "^1.6.2",
"vue": "^2.6.10",
"vue-aplayer": "^1.6.1",
"vue-router": "^3.1.3",
"vuex": "^3.0.1",
"echarts": "^4.4.0",
"echarts-gl": "^1.1.1",
"element-ui": "^2.11.1"
},

地球的页面

<template>
<div class="earthmap" id="earth"> </div>
</template> <script>
import echarts from 'echarts'
import 'echarts/map/js/world.js'
import 'echarts-gl'
export default {
data(){
return{
mapChart:{},
//立体球形纹路
option :{
globe: {
globeRadius: ,
baseTexture: '',//贴图 球形和平面的吻合
silent: true,
environment: require("../static/img/background.jpg"), //背景
heightTexture: require("../static/img/map.jpg"), //地球的整个纹路
shading: 'realistic',
light: {
main: {
color: '#fff',
intensity: ,
shadow: false,
shadowQuality: 'high',
alpha: ,
beta:
},
ambient: {
color: '#fff',
intensity:
}
},
postEffect: {
enable: false,
SSAO: {
enable: true,
radius:
}
}, //地球是否自己转动 autoRotate为true时自己转动
viewControl: {
autoRotate: true,
animationDurationUpdate: ,
targetCoord: ''
}
},
series: [
/* {
type: 'scatter3D',
coordinateSystem: 'globe',
blendMode: 'lighter',
symbolSize: 20,
symbol: 'pin',
silent: false,
itemStyle: {
color: function (params) {
var colorList = ['rgb(246, 153, 180)', 'rgb(118,77,209)'];
if (params.dataIndex % 2 != 0) {
return colorList[0]
} else {
return colorList[1]
}
},
opacity: 1
},
label: {
show: true,
textStyle: {
fontSize: 20
},
formatter: function (params) {
if (params.dataIndex % 2 != 0) {
return 'Destination:\n' + params.name
} else {
return 'Departure:\n' + params.name
}
},
position: 'top'
}
}*/
{
name: 'lines3D',
type: 'lines3D',
coordinateSystem: 'globe',
effect: {
show: true,
period: ,
trailWidth: ,
trailLength: 0.5,
trailOpacity: ,
trailColor: '#0087f4'
},
blendMode: 'lighter',
lineStyle: {
width: ,
color: '#0087f4',
opacity:
},
data: [],
silent: false, } ] }, //平面地球 主要是设置地球的样式
mapOption: {
backgroundColor: 'rgba(20,104,121,0.71)',//当和立体球形贴图是海洋的颜色
visualMap: {
show: false,
min: ,
max:
},
series: [
{
type: 'map',
map: 'world',
left: ,
top: ,
right: ,
bottom: ,
environment: 'rgba(0,0,0,0)',
boundingCoords: [
[-, ],
[, -]
],
itemStyle: {
normal: {
borderWidth: ,
borderColor: 'rgb(0,232,232)',//地球纹路的颜色
areaColor: {
type: 'linear',
x: ,
y: ,
x2: ,
y2: ,
//相邻每个板块 从上到下的颜色变化
colorStops: [{
offset: 0.2, color: 'rgb(0,48,62)' // 0% 处的颜色
}, {
offset: 0.8, color: 'rgba(0,179,188,0.8)' // 100% 处的颜色
}],
global: false // 缺省为 false
},
}
}
}
]
} }
},
mounted(){
this.initMap()
},
methods:{
initMap(){ this.mapChart = echarts.init(document.createElement('canvas'), null, {
width: ,
height:
});
//获取容器并对其初始化
this.myChart = echarts.init(document.getElementById('earth')) //将平面地球和立体球形的纹路重叠
this.mapChart.setOption(this.mapOption)
this.option.globe.baseTexture = this.mapChart //随机划多条线
for (let i = ; i < ; i++) {
this.option.series[].data = this.option.series[].data.concat(this.rodamData())
} this.myChart.setOption(this.option);
// this.myChart.setOption(this.mapOption);// 平面展开图
}, //调用划线方法
rodamData() {
//let name = '随机点' + Math.random().toFixed(5) * 100000
// let longitude = Math.random() * 62 + 73
let longitude = 105.18
let longitude2 = Math.random() * -
// let latitude = Math.random() * 50 + 3.52
let latitude = 37.51
let latitude2 = Math.random() * -
return {
coords: [
[longitude2, latitude2],
[longitude, latitude]
],
value: (Math.random() * ).toFixed()
}
} } } </script> <style>
.earthmap{
width: %;
height: 700px;
background: rgba(, , , 0.39);
} </style>

统一的页面 home.vue

<template>
<div class="home"> <div style="width: 100%;height: 100%">
<Earth></Earth>
</div> </div>
</template> <script> import Earth from "@/components/Earth"; export default {
components: { Earth
},
data() {
return {
}
} };
</script>

首页 App.vue

<template>
<div id="app">
<Home/>
<router-view/>
</div>
</template> <script>
import Home from '@/views/Home' export default {
components: {
Home
}
}
</script> <style lang="less">
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
width: %;
height:%;
} </style>

vue用echarts 画3d地球 且画线的更多相关文章

  1. WPF用SkewTransform画3D柱状图

    WPF用SkewTransform画3D柱状图 SkewTransform主要是对控件实现一种2-D扭曲,具体内容可以查看以下链接: http://msdn.microsoft.com/zh-cn/l ...

  2. Vue+WebSocket+ES6+Canvas 制作「你画我猜」小游戏

    Vue+WebSocket+ES6+Canvas 制作「你画我猜」小游戏 转载 来源:jrainlau 链接:https://segmentfault.com/a/1190000005804860 项 ...

  3. 用ChemDraw画3D图的方法

    在绘制化学图形的时候,很多的用户都会发现很多的图形都是三维的,这个时候就需要找一款能够绘制3D图形的化学绘图软件.ChemOffice 15.1是最新的化学绘图工具套件,总共有三个组件,其中ChemD ...

  4. Css3动画(一) 如何画3D旋转效果或者卫星围绕旋转效果

    如何画3D旋转效果或者卫星围绕旋转效果,当然这个也是工作中的一个任务,我在网上翻了一下,并没有找到类似的东西,所以写下来还是费了一番功夫,因此我把它拿出来记录一下,当然替换了一部分内容.好了,话不多说 ...

  5. python 画3D的高斯曲线

    用python画3D的高斯曲线,我想如果有多个峰怎么画? import numpy as npimport matplotlib.pyplot as pltimport mathimport mpl_ ...

  6. 菱形实现气泡Bubble,菱形画箭头,菱形画三角形

    菱形实现气泡Bubble,菱形画箭头,菱形画三角形 >>>>>>>>>>>>>>>>>>&g ...

  7. WPF 如何画出1像素的线

    如何有人告诉你,请你画出1像素的线,是不是觉得很简单,实际上在 WPF 上还是比较难的. 本文告诉大家,如何让画出的线不模糊 画出线的第一个方法,创建一个 Canvas ,添加一个线 界面代码 < ...

  8. Vue使用Echarts以及Echarts配置分享

    一.本篇文章将给大家分享如何在vue中使用echart以及echart各项配置,这些配置都是工作中比较常见以及常用到的,所以给大家分享下,希望对大家有用. 二.vue中使用echart. 1.首先下载 ...

  9. 用python做数字油画或者从一幅画学习风格,去画另一幅画

    1. 用python做数字油画 模块: pillow 2. 从一幅画学习风格,去画另一幅画 http://pytorch.org/tutorials/advanced/neural_style_tut ...

随机推荐

  1. [Python自学] day-22 (1) (Session、CSRF、中间件)

    一.响应函数补充 三种返回响应的方式: return HttpResponse() return render() return redirect() HttpResponse: 除了能够返回字符串, ...

  2. 全选所有checkbox

    $("table input[type=checkbox]").attr("checked",true)

  3. 创建第一个springboot项目,maven project

  4. Bzoj 1086: [SCOI2005]王室联邦(分块)

    1086: [SCOI2005]王室联邦 Time Limit: 10 Sec Memory Limit: 162 MBSec Special Judge Submit: 1557 Solved: 9 ...

  5. 【概率论】1-1:概率定义(Definition of Probability)

    title: [概率论]1-1:概率定义(Definition of Probability) categories: Mathematic Probability keywords: Sample ...

  6. sql server解锁表

    EXEC sp_who active --看哪个引起的阻塞,blk blk<>0 --解锁表declare @spid intSet @spid = 274 --锁表进程declare @ ...

  7. C# http请求工具类

    /// <summary> /// Http请求操作类之HttpWebRequest /// </summary> public class HttpHelper { #reg ...

  8. Ubuntu下制作deb包的方法详解

    1  认识deb包 1.1   认识deb包 deb是Unix系统(其实主要是Linux)下的安装包,基于 tar 包,因此本身会记录文件的权限(读/写/可执行)以及所有者/用户组. 由于 Unix ...

  9. 在使用vagrant访问PHP文件是报错“file not found”,好像是最新的NGINX不能识别document_root,只能改为自己的项目目录/vagrant_data

    出现该错误有很多可能,有可能是root配置不对,有可能是fastcgi_param SCRIPT_FILENAME参数不对等. 而本人遇到的也是参数不对,但是是一个比较少人提及的问题,nginx版本不 ...

  10. Sublime 添加∕删除右键菜单.bat

    Sublime 添加∕删除右键菜单.bat @ECHO OFF & PUSHD %~DP0 & TITLE >NUL 2>&1 REG.exe query &quo ...