Vue2项目实践十一:旅游地图

  • 单点涟漪图
  • 多点散点图
  • 单线图和样式设置
  • 散点图线图

<template>
  <div class="travel-map">
    <div id="main"></div>
  </div>
</template>
<script>
import geoJson from '@/assets/data.json'
export default {
  data() {
    return {}
  },
  mounted() {
    let myChart = this.$echarts.init(document.getElementById('main'))
    this.$echarts.registerMap('china', geoJson)
    console.log(geoJson)
    let option = {
      backgroundColor: 'rgb(121,145,209)',
      geo: {
        map: 'china',
        aspectScale: 0.75,
        zoom: 1.1,
        itemStyle: {
          normal: {
            areaColor: {
              type: 'radial',
              x: 0.5,
              y: 0.5,
              r: 0.8,
              colorStops: [
                {
                  offset: 0,
                  color: '#09132c'
                },
                {
                  offset: 1,
                  color: '#274d68'
                }
              ],
              globalCoord: true
            },
            shadowColor: 'rgb(58,115,192)',
            shadowOffsetX: 10,
            shadowOffsetY: 11,
          }

        },
        regions: [{
          name: '南海诸岛',
          itemStyle: {
            opacity: 0.5
          }
        }]
      },
      series: [
        {
          type: 'map',
          label: {
            normal: {
              show: true,
              textStyle: {
                color: '#1DE9B6'
              }
            },
            emphasis: {
              textStyle: {
                color: 'rgb(183,185,14)'
              }
            }
          },
          zoom: 1.1,
          map: 'china',
          itemStyle: {
            normal: {
              backgroundColor: 'rgb(147,1235,148)',
              borderWidth: 1,
              areaColor: {
                type: 'radial',
                x: 0.5,
                y: 0.5,
                r: 0.8,
                colorStops: [
                  {
                    offset: 0,
                    color: 'rgb(31,54,150)'
                  },
                  {
                    offset: 1,
                    color: 'rgb(89,128,142)'
                  }
                ],
                globalCoord: true
              }
            },
            emphasis: {
              areaColor: 'rgb(46,229,206)',
              borderWidth: 0.1

            }
          },
        },
        //地图散点图配置
        {
          type: 'effectScatter', //散点图
          coordinateSystem: 'geo',
          showEffectOn: 'render',
          SymbolSize: 10,//散点大小
          zlevel: 1,
          data: [
            { value: [118.8062, 31.9208], itemStyle: { color: '#4ab2e5' } },
            { value: [110.8062, 31.9208], itemStyle: { color: '#1af456' } },
            { value: [120.8062, 30.9208], itemStyle: { color: '#1af456' } },
            { value: [115.8062, 31.9208], itemStyle: { color: '#1af456' } },
            { value: [125.8062, 46.9208], itemStyle: { color: '#1af456' } },
            { value: [125.8062, 43.9208], itemStyle: { color: '#1af456' } },
            { value: [120.8062, 39.9208], itemStyle: { color: '#1af456' } }
          ],
          rippleEffect: {
            //涟漪特效配置
            period: 15,
            scale: 4,
            brushType: 'fill'
          }

        },
        //线路动画效果设置
        {
          type: 'lines',
          zlevel: 2,
          effect: {
            show: true,
            period: 4,
            symbolSize: 7,
            symbol: 'arrow',
            trailLength: 0.4
          },
          lineStype: {
            normal: {
              color: '#1DE9B6',
              width: 1,
              apacity: 0.1,
              curveness: 0.9
            }
          },
          data: [
            { coords: [[118.8062, 31.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } },
            { coords: [[110.8062, 31.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } },
            { coords: [[120.8062, 30.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } },
            { coords: [[125.8062, 46.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } },
            { coords: [[125.8062, 43.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } },
            { coords: [[120.8062, 39.9208], [115.8062, 31.9208]], lineStype: { color: '#4ab2e5' } }
          ]
        },
      ]
    }
    myChart.setOption(option)
  }
}
</script>
<style>
.travel-map {
  width: 100%;

  #main {
    width: 100%;
    height: 600px;
  }
}
</style>

【拿走即用】Echarts案例网站、150套源码模板、入门视频教程 - 知乎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值