echars 3D map solution for custom colors of regions

echars 3D map solution for custom colors of regions

question

According to the project requirements, we want to highlight (different colors) individual cities in the provincial map below

extend

First, let me introduce how this map is displayed:

  • The Vue framework uses echarts
  • The map uses geo3D and scatter3D

Of course, his implementation is very simple

First we need to initialize echarts

let echartsMap = this.$echarts.init(this.$refs.echartsMap);

Register Map

this.$echarts.registerMap('河南', dataGeoLocation);
//The dataGeoLocation at the back is the map json file we downloaded and then introduced into the current //component for use, and the Henan at the front is the map we want to register

Set the option object

The configuration here is based on your own project requirements. You can read the documents for detailed introduction.

 this.echartsDataMap = {
              visualMap:
                min: 0,
                max: 500,
                show: false,
                inRange: {
                  color: ['#eac736', '#6EAFE3'].reverse()
                },

              },
              globeRadius: 100,
              globeOuterRadius: 100,
              geo3D:
                map: mapName,
                viewControl: {
                  center: [0, 0, 0],
                  alpha: 100, //Up and down rotation anglebeta: 10, //Left and right rotation angleanimation: true, //Whether to display animationDurationUpdate: 1000, //Animation timedistance: 130, //Distance from view to subjectminBeta: -9999, //Minimum (left) rotation degreemaxBeta: 9999, //Maximum (right) rotation angleautoRotate: false,
                  autoRotateDirection: 'cw',
                  autoRotateSpeed: 10,

                },
                splitArea:{
                  areaStyle:{
                    color:'red',
                  }
                },
                light:
                  main: {
                    intensity: 1.2,
                    // color: 'transparent',
                    color: '#0D3867',
                    shadowQuality: 'ultra',
                    shadow: true,
                    alpha: 150,
                    beta: 200
                  },
                  ambient:
                    intensity: 1, //ambient light intensity},
                  ambientCubemap:
                    diffuseIntensity: 1,
                    texture: ''
                  }
                },
                groundPlane:
                  show:false
                },
                postEffect: {
                  enable: false
                },
                itemStyle: {
                  color: '#175096',
                  borderColor: 'rgb(62,215,213)',
                  opacity: 0.8, //transparency borderWidth: 1
                },
                label: {
                  show:false
                },
                emphasis:
                  label: {
                    show:false
                  },
                  itemStyle: {
                  }
                },
                silent: false, // Do not respond to or trigger mouse events},
              series: [
                {
                  type: 'scatter3D',
                  coordinateSystem: 'geo3D',
                  data: this.areaName
                  symbol: 'circle',
                  symbolSize: 0,
                  silent: false, // Do not respond to or trigger mouse events itemStyle: {
                    borderColor: '#fff',
                    borderWidth: 1
                  },
                  label: {
                    distance: 30,
                    show: true,
                    formatter: '{b}',
                    position: 'bottom',
                    bottom: '100',
                    textStyle: {
                      color: '#fff',
                      marginTop: 40,
                      fontSize: 16,
                      // fontWeight:'bold',
                      backgroundColor: 'transparent',
                    }
                  }
                },
                {

                  type: 'scatter3D',
                  coordinateSystem: 'geo3D',
                  data: pinArr,
                  color: '#6EAFE3',
                  symbol: 'pin',
                  symbolSize: 56,
                  symbolOffset: ['100%','50%','0'],
                  silent: false, // Do not respond to or trigger mouse events itemStyle: {
                    textAlign: 'center',
                    borderColor: '#6EAFE3',
                    backgroundColor: '#6EAFE3',
                    borderWidth: 0
                  },
                  zlevel: -10,
                  label: {
                    show: true,
                    distance: -45,
                    // left: -10,
                    position: 'bottom',
                    formatter: (data) => {
                      return data.value[3] + ' ';
                    },
                    textStyle: {
                      color: '#333',
                      backgroundColor: 'transparent'
                    }
                  }
                },

              ]
            };

Put the option instance on our echarts

echartsMap.setOption(this.echartsDataMap);

Solving the problem

Let's look back at the problem at the beginning of the article. I found many ways on Baidu, but after trying, it seems that there is no effect. In fact, I was able to solve it after improving it according to the methods provided on the Internet.


This is a more reliable method I found among many methods. Here he said to add regions in geo. In fact, it is like this, but it didn't work after I added it. The reason is that mine is geo3D and his is geo, but it's not a big problem. After trying three times, I finally found that they just have different writing methods.

regions:      
                {
                  name: 'Zhengzhou City', /
                  itemStyle: {
                      color: 'green'
                  }
                },{
                  name: 'Nanyang City', 
                  itemStyle: {
                      color: 'green'
                  }
                },{
                  name: 'Shangqiu City',
                  itemStyle: {
                      color: 'green'
                  }
                }]

We just need to correct the color setting and add it to our geo3D.

Summarize

This is the end of this article about echars 3D map custom colors for areas. For more relevant echars 3D map custom colors content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Example of setting legend color and map background color in echarts
  • Summary of echarts3 usage (drawing various charts and maps)
  • Detailed explanation of python using echarts to draw maps (heat maps) (world maps, provincial and municipal maps, district and county maps)
  • Echarts map adds guide line effect (labelLine)
  • Case study of introducing Chinese map in echarts in vue

<<:  Graphic tutorial on installing Ubuntu 18.04 on VMware 15 virtual machine

>>:  Example analysis of mysql non-primary key self-increment usage

Recommend

How to simply encapsulate axios in vue

Inject axios into Vue import axios from 'axio...

Solution to index failure caused by MySQL implicit type conversion

Table of contents question Reproduction Implicit ...

Quickly master how to get started with Vuex state management in Vue3.0

Vuex is a state management pattern developed spec...

Web page layout should consider IE6 compatibility issues

The figure below shows the browser viewing rate i...

An article to help you understand Js inheritance and prototype chain

Table of contents Inheritance and prototype chain...

Summary of some common configurations and techniques of Nginx

Preface This article lists several common, practi...

Why does using limit in MySQL affect performance?

First, let me explain the version of MySQL: mysql...

Some questions about hyperlinks

I am very happy to attend this episode of potato ...

Detailed steps for installing ros2 in docker

Table of contents Main topic 1. Install Docker on...

How to visualize sketched charts in Vue.js using RoughViz

introduce A chart is a graphical representation o...

Tips for optimizing MySQL SQL statements

When faced with a SQL statement that is not optim...

MySQL 8.0.17 installation graphic tutorial

This article shares with you the MySQL 8.0.17 ins...

How to view version information in Linux

How to view version information under Linux, incl...