Echarts Map地图类型使用

使用的时候出现了一个BUG, China地图的底色没有绘制出来,现在把一个小的DEMO给大家,以供参考,并附上参考文章(http://blog.csdn.net/danielinbiti/article/details/44851781),祝好。

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
</head>
<body>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="height:500px;width:500px;"></div>
    <!-- ECharts单文件引入 -->
    <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
    <script type="text/javascript">
        // 路径配置
        require.config({
            paths: {
                echarts: ‘http://echarts.baidu.com/build/dist‘
            }
        });

        // 使用
        require(
            [
                ‘echarts‘,
                ‘echarts/chart/map‘  // 使用柱状图就加载bar模块,按需加载
            ],
            function (ec) {
                // 基于准备好的dom,初始化echarts图表
                var myChart = ec.init(document.getElementById(‘main‘)); 

                      var effect = {
    show: true,
    scaleSize: require(‘zrender/tool/env‘).canvasSupported ? 1 : 2,
    period: 30,             // 运动周期,无单位,值越大越慢
    color: ‘#fff‘,
    shadowColor: ‘rgba(220,220,220,0.4)‘,
    shadowBlur : 5
};
function itemStyle(idx) {
    return {
        normal: {
            color:‘#fff‘,
            borderWidth:1,
            borderColor:[‘rgba(30,144,255,1)‘,‘lime‘][idx],
            lineStyle: {
                //shadowColor : [‘rgba(30,144,255,1)‘,‘lime‘][idx], //默认透明
                //shadowBlur: 10,
                //shadowOffsetX: 0,
                //shadowOffsetY: 0,
                type: ‘solid‘
            }
        }
    }
};
var option = {
    backgroundColor: ‘#1b1b1b‘,
    color: [‘rgba(30,144,255,1)‘,‘lime‘],
    title : {
        text: ‘中国铁路运输主干线‘,
        subtext:‘数据来自维基百科‘,
        x:‘center‘,
        textStyle : {
            color: ‘#fff‘
        }
    },
      tooltip : {
        trigger: ‘item‘,
        formatter: ‘{b}‘
    },
    toolbox: {
        show : true,
        orient : ‘vertical‘,
        x: ‘right‘,
        y: ‘center‘,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    series : [
             {
            name: ‘八横通道‘,
            type: ‘map‘,
            roam: true,
            hoverable: false,
            mapType: ‘china‘,
            itemStyle:{
                normal:{
                    borderColor:‘rgba(100,149,237,1)‘,
                    borderWidth:0.5,
                    areaStyle:{
                        color: ‘#1b1b1b‘
                    }
                }
            },
            data:[],

        },
        {
            name: ‘八横通道‘,
            type: ‘map‘,
            roam: true,
            hoverable: false,
            mapType: ‘china‘,
            itedmStyle:{
                normal:{
                    borderColor:‘rgba(100,149,237,1)‘,
                    borderWidth:0.5,
                    areaStyle:{
                        //color: ‘#1b1b1b‘
                        color: ‘red‘
                    }
                }
            },
            data:[],
            markLine : {
                symbol: [‘circle‘, ‘circle‘],
                symbolSize : 1,
                effect : effect,
                itemStyle : itemStyle(1),
                smooth:true,
                data : [
                    [{name:‘北京‘}, {name:‘兰州‘}],
                    [{name:‘兰州‘}, {name:‘拉萨‘}],

                    [{name:‘大同‘}, {name:‘秦皇岛‘}],

                    [{name:‘神木‘}, {name:‘黄骅‘}],

                    [{name:‘太原‘}, {name:‘德州‘}],
                    [{name:‘德州‘}, {name:‘龙口‘}],
                    [{name:‘龙口‘}, {name:‘烟台‘}],

                    [{name:‘太原‘}, {name:‘德州‘}],
                    [{name:‘德州‘}, {name:‘济南‘}],
                    [{name:‘济南‘}, {name:‘青岛‘}],

                    [{name:‘长治‘}, {name:‘邯郸‘}],
                    [{name:‘邯郸‘}, {name:‘济南‘}],
                    [{name:‘济南‘}, {name:‘青岛‘}],

                    [{name:‘瓦塘‘}, {name:‘临汾‘}],
                    [{name:‘临汾‘}, {name:‘长治‘}],
                    [{name:‘长治‘}, {name:‘汤阴‘}],
                    [{name:‘汤阴‘}, {name:‘台前‘}],
                    [{name:‘台前‘}, {name:‘兖州‘}],
                    [{name:‘兖州‘}, {name:‘日照‘}],

                    [{name:‘侯马‘}, {name:‘月山‘}],
                    [{name:‘月山‘}, {name:‘新乡‘}],
                    [{name:‘新乡‘}, {name:‘兖州‘}],
                    [{name:‘兖州‘}, {name:‘日照‘}],

                    [{name:‘连云港‘}, {name:‘郑州‘}],
                    [{name:‘郑州‘}, {name:‘兰州‘}],
                    [{name:‘兰州‘}, {name:‘乌鲁木齐‘}],
                    [{name:‘乌鲁木齐‘}, {name:‘阿拉山口‘}],

                    [{name:‘西安‘}, {name:‘南阳‘}],
                    [{name:‘南阳‘}, {name:‘信阳‘}],
                    [{name:‘信阳‘}, {name:‘合肥‘}],
                    [{name:‘合肥‘}, {name:‘南京‘}],
                    [{name:‘南京‘}, {name:‘启东‘}],

                    [{name:‘重庆‘}, {name:‘武汉‘}],
                    [{name:‘武汉‘}, {name:‘九江‘}],
                    [{name:‘九江‘}, {name:‘铜陵‘}],
                    [{name:‘铜陵‘}, {name:‘南京‘}],
                    [{name:‘南京‘}, {name:‘上海‘}],

                    [{name:‘上海‘}, {name:‘怀化‘}],
                    [{name:‘怀化‘}, {name:‘重庆‘}],
                    [{name:‘重庆‘}, {name:‘成都‘}],
                    [{name:‘成都‘}, {name:‘贵阳‘}],
                    [{name:‘贵阳‘}, {name:‘昆明‘}],

                    [{name:‘昆明‘}, {name:‘南宁‘}],
                    [{name:‘南宁‘}, {name:‘黎塘‘}],
                    [{name:‘黎塘‘}, {name:‘湛江‘}]
                ]
            },
            geoCoord: {
                ‘阿拉山口‘:[82.5757,45.1706],
                ‘包头‘:[109.8403,40.6574],
                ‘北京‘:[116.4075,39.9040],
                ‘成都‘:[104.0665,30.5723],
                ‘大连‘:[121.6147,38.9140],
                ‘大同‘:[113.3001,40.0768],
                ‘德州‘:[116.3575,37.4341],
                ‘福州‘:[119.2965,26.0745],
                ‘广州‘:[113.2644,23.1292],
                ‘贵阳‘:[106.6302,26.6477],
                ‘哈尔滨‘:[126.5363,45.8023],
                ‘邯郸‘:[114.5391,36.6256],
                ‘杭州‘:[120.1551,30.2741],
                ‘合肥‘:[117.2272,31.8206],
                ‘侯马‘:[111.3720,35.6191],
                ‘怀化‘:[109.9985,27.5550],
                ‘淮安‘:[119.0153,33.6104],
                ‘黄骅‘:[117.3300,38.3714],
                ‘济南‘:[117.1205,36.6510],
                ‘焦作‘:[113.2418,35.2159],
                ‘九江‘:[116.0019,29.7051],
                ‘九龙红磡‘:[114.1870,22.3076],
                ‘昆明‘:[102.8329,24.8801],
                ‘拉萨‘:[91.1409,29.6456],
                ‘兰州‘:[103.8343,36.0611],
                ‘黎塘‘:[109.1363,23.2066],
                ‘连云港‘:[119.2216,34.5967],
                ‘临汾‘:[111.5190,36.0880],
                ‘柳州‘:[109.4160,24.3255],
                ‘龙口‘:[120.4778,37.6461],
                ‘洛阳‘:[112.4540,34.6197],
                ‘满洲里‘:[117.3787,49.5978],
                ‘南昌‘:[115.8581,28.6832],
                ‘南京‘:[118.7969,32.0603],
                ‘南宁‘:[108.3661,22.8172],
                ‘南阳‘:[112.5283,32.9908],
                ‘宁波‘:[121.5440,29.8683],
                ‘启东‘:[121.6574,31.8082],
                ‘秦皇岛‘:[119.6005,39.9354],
                ‘青岛‘:[120.3826,36.0671],
                ‘日照‘:[119.5269,35.4164],
                ‘厦门‘:[118.0894,24.4798],
                ‘上海‘:[121.4737,31.2304],
                ‘深圳‘:[114.0579,22.5431],
                ‘神木‘:[110.4871,38.8610],
                ‘沈阳‘:[123.4315,41.8057],
                ‘台前‘:[115.8717,35.9701],
                ‘太原‘:[112.5489,37.8706],
                ‘汤阴‘:[114.3572,35.9218],
                ‘天津‘:[117.2010,39.0842],
                ‘铜陵‘:[117.8121,30.9454],
                ‘瓦塘‘:[109.7600,23.3161],
                ‘温州‘:[120.6994,27.9943],
                ‘乌鲁木齐‘:[87.6168,43.8256],
                ‘武汉‘:[114.3054,30.5931],
                ‘西安‘:[108.9402,34.3416],
                ‘新乡‘:[113.9268,35.3030],
                ‘信阳‘:[114.0913,32.1470],
                ‘烟台‘:[121.4479,37.4638],
                ‘兖州‘:[116.7838,35.5531],
                ‘月山‘:[113.0550,35.2104],
                ‘湛江‘:[110.3594,21.2707],
                ‘长治‘:[113.1163,36.1954],
                ‘郑州‘:[113.6254,34.7466],
                ‘重庆‘:[106.5516,29.5630]
            }
        }
    ]
};

                // 为echarts对象加载数据
                myChart.setOption(option);
            }
        );
    </script>
</body>

注意: Series里面,一共写了两个data,这样才会显示China地图的底图,否则BUG出现了之后地图的底色是高亮的。

时间: 2025-01-09 02:52:27

Echarts Map地图类型使用的相关文章

echarts Map(地图) 不同颜色区块显示

echarts Map(地图) 不同区块显示 这里以重庆地图为例 配置项: var option = { title : { text: '重庆市', subtext: '', x:'left' }, tooltip : { trigger: 'item', formatter: '{b}', itemSize:'14px' }, legend: { orient: 'vertical', x:'center', data:['重庆市区县'] }, dataRange: { x: 'left',

Echarts map地图中需要的JSON 数据格式

var initData1 = [ { "name": "安徽", "value": 244 }, { "name": "北京", "value": 5019 }, { "name": "福建", "value": 120 }, { "name": "甘肃", "value&qu

ECharts系列 - 地图 实例一

ECharts主页:  http://echarts.baidu.com/index.html ECharts-2.1.8下载地址:  http://echarts.baidu.com/build/echarts-2.1.8.zip ECharts官方实例:  http://echarts.baidu.com/doc/example.html ECharts官方API文档:  http://echarts.baidu.com/doc/doc.html 1.项目结构 js文件夹: 下载了EChar

数据视化Echarts+百度地图API实现市县区级下钻

开始 这两天公司有个页面需要做数据可视化的展示,数据视化采用的是Echarts+百度地图API做展示,需要用到县级区级下钻的一个联动效果发现网上关于Echarts做到县区级下钻的资料很少,有的话也不是很详细,对于刚接触Echarts的让人来说可能有些搞不明白,在这里我把Echarts下钻开发过程中总结的知识分享给大家,也能使自己加深印象,当然啦,对于一些在软件行业折腾了几年的老油条来说,这些都是一些非常基础的东西.但是还是希望能帮助到那些刚接触Echarts遇到类似问题需要帮助的人.如果哪里写的

react+echarts实现地图

6 import React, { Component } from 'react'; 7 import axios from 'axios'; 8 import echarts from 'echarts/lib/echarts'; 9 import 'echarts/lib/component/tooltip'; 10 import 'echarts/lib/component/title'; 11 import 'echarts/lib/component/visualMap'; 12 i

【高德地图API】从零开始学高德JS API(二)地图控件与插件——测距、圆形编辑器、鼠标工具、地图类型切换、鹰眼鱼骨

摘要:无论是控件还是插件,都是在一级API接口的基础上,进行二次开发,封装的一系列更加便于开发者使用,减少开发者工作量的二级API接口.除了官方通用的鱼骨.鹰眼控件,还有大量官方开发的地图插件,类似谷歌的lib.当然本文还会介绍自定义插件的使用. ------------------------------------------------------------------------------------------------- 第一部分 控件 目前官方支持的控件包含:缩放控制条-地图

Google地图接口API之地图类型(六)

1. Google 地图- 基本地图类型 Google Maps API 中提供了以下地图类型: MapTypeId.ROADMAP,用于显示默认的道路地图视图 MapTypeId.SATELLITE,用于显示 Google 地球卫星图片 MapTypeId.HYBRID,用于同时显示普通视图和卫星视图 MapTypeId.TERRAIN,用于根据地形信息显示实际地图. 要通过 Map 修改正在使用的地图类型,可以为其设置 mapTypeId 属性,如下所示: var mapProp = { c

百度地图API详解之自定义地图类型

http://blog.csdn.net/sup_heaven/article/details/8461586 今天的文章主要介绍如何利用地图API实现自定义地图. 百度地图API目前默认支持两种地图类型(map type):普通图和三维图,它们分别通过常量BMAP_NORMAL_MAP和BMAP_PERSPECTIVE_MAP来表示,在1.2版本中这两个常量实际上是MapType对象的实例.当然开发者也可以自己实例化一个MapType从而实现一个自定义的地图. 切图工具的使用 我们先从切图工具

Highmaps网页图表教程之下载Highmaps与Highmaps的地图类型

Highmaps网页图表教程之下载Highmaps与Highmaps的地图类型 认识Highmaps Highmaps是Highcharts的姊妹框架,用来实现地图图表. 它全然使用Javascript编写实现.其结构清晰,使用简单.开发者能够非常轻松地构建出常见的各种地图图表类型. 本章将简要介绍Highmaps的特点.并实现第一个Highmaps地图应用. Highmaps概述 为了更好学习Highmaps的使用.我们首先了解怎样获取Highmaps插件和Highmaps所支持的图表类型.