中国地图tooltip轮播以及点击tooltip进行页面跳转

本文介绍了如何使用Echarts在地图的Tooltip上实现轮播效果,并详细说明了当用户点击Tooltip时如何触发页面跳转,提供了一段关键的JavaScript代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

中国地图tooltip轮播以及点击tooltip进行页面跳转

在这里插入图片描述

tooltip轮播点击进行页面跳转

废话不说,直接上代码

<div id="ChartsChina" ref="ChartsRef" style="width:1000px;height:800px"></div>
import 'echarts/map/js/china'
import "echarts/lib/chart/map";
var myChart = echarts.init(this.$refs.ChartsRef);
option = {
   
   
    tooltip: {
   
   
        trigger: 'item',
        formatter: function(params) {
   
   

            if (params.data != 'undefined' && params.data.hasOwnProperty('jgCODE')) {
   
   
                // console.log('1111',params);
                // 提示框内容
                // 点击提示框页面跳转
                // 页面路由跳转以及传参 

                return `
                      <a target="_Blank" href="www.baidu.com?id=${
     
     params.data.c}" style="text-decoration:none">
                            <div  style="font-size: 13px;height: 17px;line-height: 17px;color: #fff;text-align: center;">${
     
     params.data.name}</div>
                            <div  style="height: 30px; line-height: 30px; font-size: 15px;display: flex;align-items: center;color:#fff">
                                <i style="border-radius: 50%;width: 15px; height: 15px;background-color: #fff;margin:0  5px;background-color: green;"></i>
                                a的数据:${
     
     params.data.a}
                            </div>
                            <div  style="height: 30px; line-height: 30px;font-size: 15px; display: flex;align-items: center;color:#fff">
                                <i style="border-radius: 50%;width: 15px;height: 15px;background-color: #fff;margin:0  5px;background-color: red;"></i> 
                                b的数据:${
     
     params.data.b}
                            </div>
                      </a>
                    `
            }
        },
        //提示框是否交互
        enterable: true,
        // 提示框点击显示
        triggerOn: 'click',
        //内编剧
        padding: [0],
        //提示框的样式
        extraCssText: 'width: 150px;height: 78px;' +
            'background-color: blue;' // +'background: url('+require('../assets/indexbg.png')+');'自己提示框的背景图或者背景色
            +
            'border-radius: 0; border: 1px solid #000;' +
            'background-size: 100% 100%; background-repeat: no-repeat;'
    },

    geo: {
   
   
        map: "china",
        show: true,
        // //是否开启鼠标缩放和平移漫游。
        roam: false,
        // //当前视角的缩放比例。
        zoom: 1.2,
        // //图形上的文本标签,
        label: {
   
   
            show: false,
            color: 'red',
            fontSize: '20'

        },
        // // // 地图的大小,见 layoutCenter。支持相对于屏幕宽高的百分比或者绝对的像素大小。
        layoutSize: 100,
        // // //这个是高亮边框
        itemStyle: {
   
   
            borderColor: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
   
   
                offset: 0,
                color: '#00F6FF'
            }, {
   
   
                offset: 1,
                color: '#53D9FF'
            }], false),
            borderWidth: 5,
            shadowColor: 'rgba(10,76,139,1)',
            shadowOffsetY: 0,
            shadowBlur: 60
        }
    },
    series: [
        //给地图填充颜色
        {
   
   
            name: "地图",
            type: "map", //地图种类
            map: "china", //地图类型。
            // data: this._mapData,
            zoom: 1.2, //放大比例
            label: {
   
   
                //图形上的文本标签,可用于说明图形的一些数据信息
                show: false
            },
            // 每个省份的颜色
            itemStyle: {
   
   
                areaColor: {
   
   
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
   
   
                            offset: 0,
                            color: '#073684' // 0% 处的颜色
                        },
                        {
   
   
                            offset: 1,
                            color: '#061E3D' // 100% 处的颜色
                        }
                    ],
                },
                borderColor: '#215495',
                borderWidth: 1,
            },
            // 鼠标移动到每个省份高亮的颜色属性的等设置
            emphasis: {
   
   
                itemStyle: {
   
   
                    areaColor: {
   
   
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
   
   
                            offset: 0,
                            color: '#073684' // 0% 处的颜色
                        }, {
   
   
                            offset: 1,
                            color: '#061E3D' // 100% 处的颜色
                        }],
                    },
                    // borderColor: 'red',
                },
                label: {
   
   
                    show: true,
                    color: '#fff'
                }

            },
        },
        {
   
   
            type: 'scatter',
            name: '散点',
            // 使用的坐标轴
            coordinateSystem: 'geo',
            // 层级
            zlevel: 3,
            itemStyle: {
   
   
                normal: {
   
   
                    color: '#1DE9B6',
                    shadowBlur: 10,
                    shadowColor: '#333'
                }
            },
            symbolSize: 10,
            // 选中
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值