Echarts 山东地图 普通html

echarts yekong 1858℃

Echarts 山东地图

function getecharts5() {
            var chartDom = document.getElementById('echarts5');
            var myChart = echarts.init(chartDom);
            var uploadedDataURL = "data/data-1605510661041-oDutJVlSC.json";
            var nameMap = '山东省';
            window.dataList = [{name: '济南市', value: 396},
                {name: '青岛市', value: 66},
                {name: '烟台市', value: 222},
                {name: '潍坊市', value: 688},
                {name: '菏泽市', value: 75},
                {name: '日照市', value: 121},
                {name: '威海市', value: 91},
                {name: '枣庄市', value: 479},
                {name: '临沂市', value: 34},
                {name: '滨州市', value: 631},
                {name: '东营市', value: 1203},
                {name: '淄博市', value: 988},
                {name: '泰安市', value: 693},
                {name: '聊城市', value: 934},
                {name: '济宁市', value: 748},
                {name: '德州市', value: 1267}
            ];
            var geoCoordMap = {};
            var convertData = function (data) {
                console.log('data', data)
                var res = [];
                for (var i = 0; i < data.length; i++) {
                    var geoCoord = geoCoordMap[data[i].name];
                    if (geoCoord) {
                        res.push({
                            name: data[i].name,
                            value: geoCoord.concat(data[i].value),
                        });
                    }
                }
                console.log('res', res)
                return res;
            };


            $.get(uploadedDataURL, function (gdMap) {
                debugger
                echarts.registerMap(nameMap, gdMap);
                /*获取地图数据*/
                myChart.showLoading();
                var mapFeatures = echarts.getMap(nameMap).geoJson.features;
                myChart.hideLoading();
                mapFeatures.forEach(function (v) {
                    // 地区名称
                    var name = v.properties.name;
                    // 地区经纬度
                    geoCoordMap[name] = v.properties.center;

                });
                console.log(geoCoordMap)
                //GDP
                var optionMap = {
                    visualMap: [{
                        min: 0,
                        max: 1000,
                        show: false,
                        //   text: ['High', 'Low'],
                        realtime: false,
                        calculable: false,
                        seriesIndex: [0],
                        inRange: {
                            color: ['#116EE1', '#34B8F7', '#2ACAEF', '#1290EC', '#0A86EB', 'rgb(128,128,255)', 'rgb(236,128,141)', 'rgb(194,128,255)', 'rgb(245,154,35)', 'rgb(112,182,3)', 'rgb(0,182,128)', 'rgb(99,0,191)']
                        }
                    },
                        {
                            min: 0,
                            max: 1000,
                            seriesIndex: 1,
                            show: false,
                            splitNumber: 4,
                            right: '2%',
                            inRange: {
                                color: ['#116EE1', '#34B8F7', '#2ACAEF', '#1290EC', '#0A86EB',].reverse()
                            },
                            formatter: function (value) {
                                return ''
                            }
                        }],
                    geo: {
                        map: nameMap,
                        show: false,
                        roam: true,
                        label: {
                            normal: {
                                show: false
                            },
                            emphasis: {
                                show: false
                            }
                        }
                    },
                    series: [
                        { // 地图块的相关信息
                            type: 'map',
                            map: nameMap,
                            label: {
                                normal: {
                                    show: true,
                                    textStyle: {
                                        fontSize: 12,
                                        fontWeight: 400,
                                        color: 'rgb(0,0,0) '
                                    }
                                }
                            },
                            data: window.dataList
                        },
                        {
                            type: 'scatter',
                            coordinateSystem: 'geo',
                            symbol: 'pin',
                            symbolSize: [40, 40],
                            label: {
                                normal: {
                                    show: true,
                                    textStyle: {
                                        color: '#000',
                                        fontSize: 10,
                                        fontWeight: 600
                                    },
                                    formatter(value) {
                                        return value.data.value[2]
                                    }
                                }
                            },
                            hoverAnimation: true,
                            itemStyle: {
                                normal: {
                                    color: 'pink' // 标志颜色
                                }
                            },
                            zlevel: 6,
                            data: convertData(window.dataList)
                        }
                    ]
                };
                myChart.clear()
                myChart.resize()
                myChart.setOption(optionMap, true);
            });
        }

地图数据源:Echarts地图数据中国省市区县geoJSON格式地图行政等地区

喜欢 (6)