bmap.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <html>
  2. <head>
  3. <meta charset='utf-8'>
  4. <script src='esl.js'></script>
  5. <script src='config.js'></script>
  6. <script src='lib/jquery.min.js'></script>
  7. <script src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
  8. <meta name="viewport" content="width=device-width, initial-scale=1" />
  9. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. }
  17. </style>
  18. <div id='main'></div>
  19. <script>
  20. require([
  21. 'echarts',
  22. 'echarts/chart/scatter',
  23. 'echarts/chart/effectScatter',
  24. 'echarts/component/legend',
  25. 'extension/bmap/bmap'
  26. ], function (echarts) {
  27. var data = [
  28. {name: '海门', value: 9},
  29. {name: '鄂尔多斯', value: 12},
  30. {name: '招远', value: 12},
  31. {name: '舟山', value: 12},
  32. {name: '齐齐哈尔', value: 14},
  33. {name: '盐城', value: 15},
  34. {name: '赤峰', value: 16},
  35. {name: '青岛', value: 18},
  36. {name: '乳山', value: 18},
  37. {name: '金昌', value: 19},
  38. {name: '泉州', value: 21},
  39. {name: '莱西', value: 21},
  40. {name: '日照', value: 21},
  41. {name: '胶南', value: 22},
  42. {name: '南通', value: 23},
  43. {name: '拉萨', value: 24},
  44. {name: '云浮', value: 24},
  45. {name: '梅州', value: 25},
  46. {name: '文登', value: 25},
  47. {name: '上海', value: 25},
  48. {name: '攀枝花', value: 25},
  49. {name: '威海', value: 25},
  50. {name: '承德', value: 25},
  51. {name: '厦门', value: 26},
  52. {name: '汕尾', value: 26},
  53. {name: '潮州', value: 26},
  54. {name: '丹东', value: 27},
  55. {name: '太仓', value: 27},
  56. {name: '曲靖', value: 27},
  57. {name: '烟台', value: 28},
  58. {name: '福州', value: 29},
  59. {name: '瓦房店', value: 30},
  60. {name: '即墨', value: 30},
  61. {name: '抚顺', value: 31},
  62. {name: '玉溪', value: 31},
  63. {name: '张家口', value: 31},
  64. {name: '阳泉', value: 31},
  65. {name: '莱州', value: 32},
  66. {name: '湖州', value: 32},
  67. {name: '汕头', value: 32},
  68. {name: '昆山', value: 33},
  69. {name: '宁波', value: 33},
  70. {name: '湛江', value: 33},
  71. {name: '揭阳', value: 34},
  72. {name: '荣成', value: 34},
  73. {name: '连云港', value: 35},
  74. {name: '葫芦岛', value: 35},
  75. {name: '常熟', value: 36},
  76. {name: '东莞', value: 36},
  77. {name: '河源', value: 36},
  78. {name: '淮安', value: 36},
  79. {name: '泰州', value: 36},
  80. {name: '南宁', value: 37},
  81. {name: '营口', value: 37},
  82. {name: '惠州', value: 37},
  83. {name: '江阴', value: 37},
  84. {name: '蓬莱', value: 37},
  85. {name: '韶关', value: 38},
  86. {name: '嘉峪关', value: 38},
  87. {name: '广州', value: 38},
  88. {name: '延安', value: 38},
  89. {name: '太原', value: 39},
  90. {name: '清远', value: 39},
  91. {name: '中山', value: 39},
  92. {name: '昆明', value: 39},
  93. {name: '寿光', value: 40},
  94. {name: '盘锦', value: 40},
  95. {name: '长治', value: 41},
  96. {name: '深圳', value: 41},
  97. {name: '珠海', value: 42},
  98. {name: '宿迁', value: 43},
  99. {name: '咸阳', value: 43},
  100. {name: '铜川', value: 44},
  101. {name: '平度', value: 44},
  102. {name: '佛山', value: 44},
  103. {name: '海口', value: 44},
  104. {name: '江门', value: 45},
  105. {name: '章丘', value: 45},
  106. {name: '肇庆', value: 46},
  107. {name: '大连', value: 47},
  108. {name: '临汾', value: 47},
  109. {name: '吴江', value: 47},
  110. {name: '石嘴山', value: 49},
  111. {name: '沈阳', value: 50},
  112. {name: '苏州', value: 50},
  113. {name: '茂名', value: 50},
  114. {name: '嘉兴', value: 51},
  115. {name: '长春', value: 51},
  116. {name: '胶州', value: 52},
  117. {name: '银川', value: 52},
  118. {name: '张家港', value: 52},
  119. {name: '三门峡', value: 53},
  120. {name: '锦州', value: 54},
  121. {name: '南昌', value: 54},
  122. {name: '柳州', value: 54},
  123. {name: '三亚', value: 54},
  124. {name: '自贡', value: 56},
  125. {name: '吉林', value: 56},
  126. {name: '阳江', value: 57},
  127. {name: '泸州', value: 57},
  128. {name: '西宁', value: 57},
  129. {name: '宜宾', value: 58},
  130. {name: '呼和浩特', value: 58},
  131. {name: '成都', value: 58},
  132. {name: '大同', value: 58},
  133. {name: '镇江', value: 59},
  134. {name: '桂林', value: 59},
  135. {name: '张家界', value: 59},
  136. {name: '宜兴', value: 59},
  137. {name: '北海', value: 60},
  138. {name: '西安', value: 61},
  139. {name: '金坛', value: 62},
  140. {name: '东营', value: 62},
  141. {name: '牡丹江', value: 63},
  142. {name: '遵义', value: 63},
  143. {name: '绍兴', value: 63},
  144. {name: '扬州', value: 64},
  145. {name: '常州', value: 64},
  146. {name: '潍坊', value: 65},
  147. {name: '重庆', value: 66},
  148. {name: '台州', value: 67},
  149. {name: '南京', value: 67},
  150. {name: '滨州', value: 70},
  151. {name: '贵阳', value: 71},
  152. {name: '无锡', value: 71},
  153. {name: '本溪', value: 71},
  154. {name: '克拉玛依', value: 72},
  155. {name: '渭南', value: 72},
  156. {name: '马鞍山', value: 72},
  157. {name: '宝鸡', value: 72},
  158. {name: '焦作', value: 75},
  159. {name: '句容', value: 75},
  160. {name: '北京', value: 79},
  161. {name: '徐州', value: 79},
  162. {name: '衡水', value: 80},
  163. {name: '包头', value: 80},
  164. {name: '绵阳', value: 80},
  165. {name: '乌鲁木齐', value: 84},
  166. {name: '枣庄', value: 84},
  167. {name: '杭州', value: 84},
  168. {name: '淄博', value: 85},
  169. {name: '鞍山', value: 86},
  170. {name: '溧阳', value: 86},
  171. {name: '库尔勒', value: 86},
  172. {name: '安阳', value: 90},
  173. {name: '开封', value: 90},
  174. {name: '济南', value: 92},
  175. {name: '德阳', value: 93},
  176. {name: '温州', value: 95},
  177. {name: '九江', value: 96},
  178. {name: '邯郸', value: 98},
  179. {name: '临安', value: 99},
  180. {name: '兰州', value: 99},
  181. {name: '沧州', value: 100},
  182. {name: '临沂', value: 103},
  183. {name: '南充', value: 104},
  184. {name: '天津', value: 105},
  185. {name: '富阳', value: 106},
  186. {name: '泰安', value: 112},
  187. {name: '诸暨', value: 112},
  188. {name: '郑州', value: 113},
  189. {name: '哈尔滨', value: 114},
  190. {name: '聊城', value: 116},
  191. {name: '芜湖', value: 117},
  192. {name: '唐山', value: 119},
  193. {name: '平顶山', value: 119},
  194. {name: '邢台', value: 119},
  195. {name: '德州', value: 120},
  196. {name: '济宁', value: 120},
  197. {name: '荆州', value: 127},
  198. {name: '宜昌', value: 130},
  199. {name: '义乌', value: 132},
  200. {name: '丽水', value: 133},
  201. {name: '洛阳', value: 134},
  202. {name: '秦皇岛', value: 136},
  203. {name: '株洲', value: 143},
  204. {name: '石家庄', value: 147},
  205. {name: '莱芜', value: 148},
  206. {name: '常德', value: 152},
  207. {name: '保定', value: 153},
  208. {name: '湘潭', value: 154},
  209. {name: '金华', value: 157},
  210. {name: '岳阳', value: 169},
  211. {name: '长沙', value: 175},
  212. {name: '衢州', value: 177},
  213. {name: '廊坊', value: 193},
  214. {name: '菏泽', value: 194},
  215. {name: '合肥', value: 229},
  216. {name: '武汉', value: 273},
  217. {name: '大庆', value: 279}
  218. ];
  219. var geoCoordMap = {
  220. '海门':[121.15,31.89],
  221. '鄂尔多斯':[109.781327,39.608266],
  222. '招远':[120.38,37.35],
  223. '舟山':[122.207216,29.985295],
  224. '齐齐哈尔':[123.97,47.33],
  225. '盐城':[120.13,33.38],
  226. '赤峰':[118.87,42.28],
  227. '青岛':[120.33,36.07],
  228. '乳山':[121.52,36.89],
  229. '金昌':[102.188043,38.520089],
  230. '泉州':[118.58,24.93],
  231. '莱西':[120.53,36.86],
  232. '日照':[119.46,35.42],
  233. '胶南':[119.97,35.88],
  234. '南通':[121.05,32.08],
  235. '拉萨':[91.11,29.97],
  236. '云浮':[112.02,22.93],
  237. '梅州':[116.1,24.55],
  238. '文登':[122.05,37.2],
  239. '上海':[121.48,31.22],
  240. '攀枝花':[101.718637,26.582347],
  241. '威海':[122.1,37.5],
  242. '承德':[117.93,40.97],
  243. '厦门':[118.1,24.46],
  244. '汕尾':[115.375279,22.786211],
  245. '潮州':[116.63,23.68],
  246. '丹东':[124.37,40.13],
  247. '太仓':[121.1,31.45],
  248. '曲靖':[103.79,25.51],
  249. '烟台':[121.39,37.52],
  250. '福州':[119.3,26.08],
  251. '瓦房店':[121.979603,39.627114],
  252. '即墨':[120.45,36.38],
  253. '抚顺':[123.97,41.97],
  254. '玉溪':[102.52,24.35],
  255. '张家口':[114.87,40.82],
  256. '阳泉':[113.57,37.85],
  257. '莱州':[119.942327,37.177017],
  258. '湖州':[120.1,30.86],
  259. '汕头':[116.69,23.39],
  260. '昆山':[120.95,31.39],
  261. '宁波':[121.56,29.86],
  262. '湛江':[110.359377,21.270708],
  263. '揭阳':[116.35,23.55],
  264. '荣成':[122.41,37.16],
  265. '连云港':[119.16,34.59],
  266. '葫芦岛':[120.836932,40.711052],
  267. '常熟':[120.74,31.64],
  268. '东莞':[113.75,23.04],
  269. '河源':[114.68,23.73],
  270. '淮安':[119.15,33.5],
  271. '泰州':[119.9,32.49],
  272. '南宁':[108.33,22.84],
  273. '营口':[122.18,40.65],
  274. '惠州':[114.4,23.09],
  275. '江阴':[120.26,31.91],
  276. '蓬莱':[120.75,37.8],
  277. '韶关':[113.62,24.84],
  278. '嘉峪关':[98.289152,39.77313],
  279. '广州':[113.23,23.16],
  280. '延安':[109.47,36.6],
  281. '太原':[112.53,37.87],
  282. '清远':[113.01,23.7],
  283. '中山':[113.38,22.52],
  284. '昆明':[102.73,25.04],
  285. '寿光':[118.73,36.86],
  286. '盘锦':[122.070714,41.119997],
  287. '长治':[113.08,36.18],
  288. '深圳':[114.07,22.62],
  289. '珠海':[113.52,22.3],
  290. '宿迁':[118.3,33.96],
  291. '咸阳':[108.72,34.36],
  292. '铜川':[109.11,35.09],
  293. '平度':[119.97,36.77],
  294. '佛山':[113.11,23.05],
  295. '海口':[110.35,20.02],
  296. '江门':[113.06,22.61],
  297. '章丘':[117.53,36.72],
  298. '肇庆':[112.44,23.05],
  299. '大连':[121.62,38.92],
  300. '临汾':[111.5,36.08],
  301. '吴江':[120.63,31.16],
  302. '石嘴山':[106.39,39.04],
  303. '沈阳':[123.38,41.8],
  304. '苏州':[120.62,31.32],
  305. '茂名':[110.88,21.68],
  306. '嘉兴':[120.76,30.77],
  307. '长春':[125.35,43.88],
  308. '胶州':[120.03336,36.264622],
  309. '银川':[106.27,38.47],
  310. '张家港':[120.555821,31.875428],
  311. '三门峡':[111.19,34.76],
  312. '锦州':[121.15,41.13],
  313. '南昌':[115.89,28.68],
  314. '柳州':[109.4,24.33],
  315. '三亚':[109.511909,18.252847],
  316. '自贡':[104.778442,29.33903],
  317. '吉林':[126.57,43.87],
  318. '阳江':[111.95,21.85],
  319. '泸州':[105.39,28.91],
  320. '西宁':[101.74,36.56],
  321. '宜宾':[104.56,29.77],
  322. '呼和浩特':[111.65,40.82],
  323. '成都':[104.06,30.67],
  324. '大同':[113.3,40.12],
  325. '镇江':[119.44,32.2],
  326. '桂林':[110.28,25.29],
  327. '张家界':[110.479191,29.117096],
  328. '宜兴':[119.82,31.36],
  329. '北海':[109.12,21.49],
  330. '西安':[108.95,34.27],
  331. '金坛':[119.56,31.74],
  332. '东营':[118.49,37.46],
  333. '牡丹江':[129.58,44.6],
  334. '遵义':[106.9,27.7],
  335. '绍兴':[120.58,30.01],
  336. '扬州':[119.42,32.39],
  337. '常州':[119.95,31.79],
  338. '潍坊':[119.1,36.62],
  339. '重庆':[106.54,29.59],
  340. '台州':[121.420757,28.656386],
  341. '南京':[118.78,32.04],
  342. '滨州':[118.03,37.36],
  343. '贵阳':[106.71,26.57],
  344. '无锡':[120.29,31.59],
  345. '本溪':[123.73,41.3],
  346. '克拉玛依':[84.77,45.59],
  347. '渭南':[109.5,34.52],
  348. '马鞍山':[118.48,31.56],
  349. '宝鸡':[107.15,34.38],
  350. '焦作':[113.21,35.24],
  351. '句容':[119.16,31.95],
  352. '北京':[116.46,39.92],
  353. '徐州':[117.2,34.26],
  354. '衡水':[115.72,37.72],
  355. '包头':[110,40.58],
  356. '绵阳':[104.73,31.48],
  357. '乌鲁木齐':[87.68,43.77],
  358. '枣庄':[117.57,34.86],
  359. '杭州':[120.19,30.26],
  360. '淄博':[118.05,36.78],
  361. '鞍山':[122.85,41.12],
  362. '溧阳':[119.48,31.43],
  363. '库尔勒':[86.06,41.68],
  364. '安阳':[114.35,36.1],
  365. '开封':[114.35,34.79],
  366. '济南':[117,36.65],
  367. '德阳':[104.37,31.13],
  368. '温州':[120.65,28.01],
  369. '九江':[115.97,29.71],
  370. '邯郸':[114.47,36.6],
  371. '临安':[119.72,30.23],
  372. '兰州':[103.73,36.03],
  373. '沧州':[116.83,38.33],
  374. '临沂':[118.35,35.05],
  375. '南充':[106.110698,30.837793],
  376. '天津':[117.2,39.13],
  377. '富阳':[119.95,30.07],
  378. '泰安':[117.13,36.18],
  379. '诸暨':[120.23,29.71],
  380. '郑州':[113.65,34.76],
  381. '哈尔滨':[126.63,45.75],
  382. '聊城':[115.97,36.45],
  383. '芜湖':[118.38,31.33],
  384. '唐山':[118.02,39.63],
  385. '平顶山':[113.29,33.75],
  386. '邢台':[114.48,37.05],
  387. '德州':[116.29,37.45],
  388. '济宁':[116.59,35.38],
  389. '荆州':[112.239741,30.335165],
  390. '宜昌':[111.3,30.7],
  391. '义乌':[120.06,29.32],
  392. '丽水':[119.92,28.45],
  393. '洛阳':[112.44,34.7],
  394. '秦皇岛':[119.57,39.95],
  395. '株洲':[113.16,27.83],
  396. '石家庄':[114.48,38.03],
  397. '莱芜':[117.67,36.19],
  398. '常德':[111.69,29.05],
  399. '保定':[115.48,38.85],
  400. '湘潭':[112.91,27.87],
  401. '金华':[119.64,29.12],
  402. '岳阳':[113.09,29.37],
  403. '长沙':[113,28.21],
  404. '衢州':[118.88,28.97],
  405. '廊坊':[116.7,39.53],
  406. '菏泽':[115.480656,35.23375],
  407. '合肥':[117.27,31.86],
  408. '武汉':[114.31,30.52],
  409. '大庆':[125.03,46.58]
  410. };
  411. var convertData = function (data) {
  412. var res = [];
  413. for (var i = 0; i < data.length; i++) {
  414. var geoCoord = geoCoordMap[data[i].name];
  415. if (geoCoord) {
  416. res.push({
  417. name: data[i].name,
  418. value: geoCoord.concat(data[i].value)
  419. });
  420. }
  421. }
  422. return res;
  423. };
  424. var myChart = echarts.init(document.getElementById('main'));
  425. myChart.setOption({
  426. backgroundColor: '#404a59',
  427. title: {
  428. text: '全国主要城市空气质量',
  429. subtext: 'data from PM25.in',
  430. sublink: 'http://www.pm25.in',
  431. left: 'center',
  432. textStyle: {
  433. color: '#fff'
  434. }
  435. },
  436. tooltip : {
  437. trigger: 'item'
  438. },
  439. bmap: {
  440. center: [104.114129, 37.550339],
  441. zoom: 5,
  442. roam: true,
  443. mapStyle: {
  444. styleJson: [
  445. {
  446. "featureType": "water",
  447. "elementType": "all",
  448. "stylers": {
  449. "color": "#044161"
  450. }
  451. },
  452. {
  453. "featureType": "land",
  454. "elementType": "all",
  455. "stylers": {
  456. "color": "#004981"
  457. }
  458. },
  459. {
  460. "featureType": "boundary",
  461. "elementType": "geometry",
  462. "stylers": {
  463. "color": "#064f85"
  464. }
  465. },
  466. {
  467. "featureType": "railway",
  468. "elementType": "all",
  469. "stylers": {
  470. "visibility": "off"
  471. }
  472. },
  473. {
  474. "featureType": "highway",
  475. "elementType": "geometry",
  476. "stylers": {
  477. "color": "#004981"
  478. }
  479. },
  480. {
  481. "featureType": "highway",
  482. "elementType": "geometry.fill",
  483. "stylers": {
  484. "color": "#005b96",
  485. "lightness": 1
  486. }
  487. },
  488. {
  489. "featureType": "highway",
  490. "elementType": "labels",
  491. "stylers": {
  492. "visibility": "off"
  493. }
  494. },
  495. {
  496. "featureType": "arterial",
  497. "elementType": "geometry",
  498. "stylers": {
  499. "color": "#004981"
  500. }
  501. },
  502. {
  503. "featureType": "arterial",
  504. "elementType": "geometry.fill",
  505. "stylers": {
  506. "color": "#00508b"
  507. }
  508. },
  509. {
  510. "featureType": "poi",
  511. "elementType": "all",
  512. "stylers": {
  513. "visibility": "off"
  514. }
  515. },
  516. {
  517. "featureType": "green",
  518. "elementType": "all",
  519. "stylers": {
  520. "color": "#056197",
  521. "visibility": "off"
  522. }
  523. },
  524. {
  525. "featureType": "subway",
  526. "elementType": "all",
  527. "stylers": {
  528. "visibility": "off"
  529. }
  530. },
  531. {
  532. "featureType": "manmade",
  533. "elementType": "all",
  534. "stylers": {
  535. "visibility": "off"
  536. }
  537. },
  538. {
  539. "featureType": "local",
  540. "elementType": "all",
  541. "stylers": {
  542. "visibility": "off"
  543. }
  544. },
  545. {
  546. "featureType": "arterial",
  547. "elementType": "labels",
  548. "stylers": {
  549. "visibility": "off"
  550. }
  551. },
  552. {
  553. "featureType": "boundary",
  554. "elementType": "geometry.fill",
  555. "stylers": {
  556. "color": "#029fd4"
  557. }
  558. },
  559. {
  560. "featureType": "building",
  561. "elementType": "all",
  562. "stylers": {
  563. "color": "#1a5787"
  564. }
  565. },
  566. {
  567. "featureType": "label",
  568. "elementType": "all",
  569. "stylers": {
  570. "visibility": "off"
  571. }
  572. }
  573. ]
  574. }
  575. },
  576. series : [
  577. {
  578. name: 'pm2.5',
  579. type: 'scatter',
  580. coordinateSystem: 'bmap',
  581. data: convertData(data),
  582. symbolSize: function (val) {
  583. return val[2] / 10;
  584. },
  585. label: {
  586. normal: {
  587. formatter: '{b}',
  588. position: 'right',
  589. show: false
  590. },
  591. emphasis: {
  592. show: true
  593. }
  594. },
  595. itemStyle: {
  596. normal: {
  597. color: '#ddb926'
  598. }
  599. }
  600. },
  601. {
  602. name: 'Top 5',
  603. type: 'effectScatter',
  604. coordinateSystem: 'bmap',
  605. data: convertData(data.sort(function (a, b) {
  606. return b.value - a.value;
  607. }).slice(0, 6)),
  608. symbolSize: function (val) {
  609. return val[2] / 10;
  610. },
  611. showEffectOn: 'emphasis',
  612. rippleEffect: {
  613. brushType: 'stroke'
  614. },
  615. hoverAnimation: true,
  616. label: {
  617. normal: {
  618. formatter: '{b}',
  619. position: 'right',
  620. show: true
  621. }
  622. },
  623. itemStyle: {
  624. normal: {
  625. color: '#f4e925',
  626. shadowBlur: 10,
  627. shadowColor: '#333'
  628. }
  629. },
  630. zlevel: 1
  631. }
  632. ]
  633. });
  634. });
  635. </script>
  636. </body>
  637. </html>