当前位置:   article > 正文

Echart在Openlayers的应用-航班的炫光特效

echarts的地图效果在openlayers应用

概述

在前两篇文章中讲到了echart在openlayers2中的应用,地图统计图与热力图的实现,在本文中介绍openlayers中结合echart实现航班的炫光特效展示。


效果




实现代码:

1、EchartLayer

  1. OpenLayers.Layer.EchartLayer = OpenLayers.Class(OpenLayers.Layer,
  2. {
  3. isBaseLayer : false,
  4. echart : null,
  5. mapLayer : null,
  6. _geoCoord: [],
  7. initialize : function (name, map, echart, options)
  8. {
  9. var scope = this, echartdiv = document.createElement("div"), handler;
  10. OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
  11. echartdiv.style.cssText = "position:absolute;width:" + map.size.w + "px;height:"
  12. + map.size.h + "px;";
  13. scope.div.appendChild(echartdiv);
  14. scope.map = map;
  15. scope.echartdiv = echartdiv;
  16. scope.opacity = options.opacity;
  17. scope.echart = echart;
  18. scope.option = options.option;
  19. handler = function (e)
  20. {
  21. scope.updateLayer(e);
  22. };
  23. map.events.register("zoomend", this, handler);
  24. map.events.register("moveend", this, handler);
  25. },
  26. geoCoord2Pixel:function(geoCoord){
  27. var scope = this;
  28. var lonLat = new OpenLayers.LonLat(geoCoord[0], geoCoord[1]);
  29. var scrPt = scope.map.getPixelFromLonLat(lonLat);
  30. var x = scrPt.x,
  31. y = scrPt.y;
  32. return [x,y];
  33. },
  34. updateLayer : function (e)
  35. {
  36. var scope = this;
  37. var myChart = scope.echart.init(scope.echartdiv);
  38. var orgXy, w, h;
  39. if(e){
  40. orgXy = e.object.layerContainerOriginPx;
  41. }
  42. else{
  43. orgXy={x:0,y:0};
  44. }
  45. w = scope.map.size.w;
  46. h = scope.map.size.h;
  47. scope.echartdiv.style.cssText = "position:absolute;top:"+(-orgXy.y)+"px;left:"+(-orgXy.x)+
  48. "px;width:" + w + "px;height:" + h + "px;";
  49. var ecOption = scope.getEcOption();
  50. myChart.setOption(ecOption);
  51. },
  52. /**
  53. *将echart的option转换
  54. * @returns {*}
  55. */
  56. getEcOption: function(){
  57. var scope = this;
  58. scope._option = scope.option;
  59. var series = scope._option.series || {};
  60. // 记录所有的geoCoord
  61. for (var i = 0, item; item = series[i++];) {
  62. var geoCoord = item.geoCoord;
  63. if (geoCoord) {
  64. for (var k in geoCoord) {
  65. scope._geoCoord[k] = geoCoord[k];
  66. }
  67. }
  68. }
  69. // 添加x、y
  70. for (var i = 0, item; item = series[i++];) {
  71. var markPoint = item.markPoint || {};
  72. var markLine = item.markLine || {};
  73. var data = markPoint.data;
  74. if (data && data.length) {
  75. for (var k = 0, len = data.length; k < len; k++) {
  76. if (!(data[k].name && this._geoCoord.hasOwnProperty(data[k].name))) {
  77. data[k].name = k + 'markp';
  78. scope._geoCoord[data[k].name] = data[k].geoCoord;
  79. }
  80. scope._AddPos(data[k]);
  81. }
  82. }
  83. data = markLine.data;
  84. if (data && data.length) {
  85. for (var k = 0, len = data.length; k < len; k++) {
  86. if (!(data[k][0].name && this._geoCoord.hasOwnProperty(data[k][0].name))) {
  87. data[k][0].name = k + 'startp';
  88. scope._geoCoord[data[k][0].name] = data[k][0].geoCoord;
  89. }
  90. if (!(data[k][1].name && this._geoCoord.hasOwnProperty(data[k][1].name))) {
  91. data[k][1].name = k + 'endp';
  92. scope._geoCoord[data[k][1].name] = data[k][1].geoCoord;
  93. }
  94. scope._AddPos(data[k][0]);
  95. scope._AddPos(data[k][1]);
  96. }
  97. }
  98. }
  99. return scope._option;
  100. },
  101. _AddPos:function(obj){
  102. var scope = this;
  103. var coord = scope._geoCoord[obj.name];
  104. var pos = scope.geoCoord2Pixel(coord);
  105. obj.x = pos[0]; //- self._mapOffset[0];
  106. obj.y = pos[1]; //- self._mapOffset[1];
  107. },
  108. destroy : function ()
  109. {
  110. OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
  111. },
  112. CLASS_NAME : "OpenLayers.Layer.EchartLayer"
  113. }
  114. );

2、页面调用

  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>heatmap.js OpenLayers Heatmap Layer</title>
  5. <link rel="stylesheet" type="text/css" href="http://dev.openlayers.org/theme/default/style.css"/>
  6. <style type="text/css">
  7. html, body, #map{
  8. padding:0;
  9. margin:0;
  10. height:100%;
  11. width:100%;
  12. }
  13. </style>
  14. <script type="text/javascript" src="http://dev.openlayers.org/OpenLayers.js"></script>
  15. <script src="http://echarts.baidu.com/echarts2/doc/example/www/js/echarts.js"></script>
  16. <script src="js/EchartLayer.js"></script>
  17. <script type="text/javascript">
  18. require.config({
  19. paths: {
  20. echarts: 'http://echarts.baidu.com/echarts2/doc/example/www/js'
  21. }
  22. });
  23. var map, echartlayer;
  24. function getBaseLayer(layername, layer){
  25. return new OpenLayers.Layer.XYZ(
  26. layername,
  27. [
  28. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  29. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  30. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  31. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  32. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  33. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  34. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  35. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}"
  36. ],
  37. {
  38. isBaseLayer: true,
  39. displayInLayerSwitcher:true
  40. }
  41. );
  42. };
  43. function getAnnoLayer(layername, layer, visiable){
  44. return new OpenLayers.Layer.XYZ(
  45. layername,
  46. [
  47. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  48. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  49. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  50. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  51. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  52. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  53. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}",
  54. "http://t0.tianditu.com/DataServer?T="+layer+"&X=${x}&Y=${y}&L=${z}"
  55. ],
  56. {
  57. isBaseLayer: false,
  58. visibility:visiable,
  59. displayInLayerSwitcher:false
  60. }
  61. );
  62. };
  63. function init(){
  64. var baseLayers = ["vec_c","img_c","ter_c"];
  65. var vecLayer = getBaseLayer("vec",baseLayers[1]);
  66. var vecAnno = getAnnoLayer("cva", "cva_c", true);
  67. map = new OpenLayers.Map({
  68. div: "map",
  69. projection: "EPSG:4326",
  70. layers: [vecLayer, vecAnno],
  71. numZoomLevels:20,
  72. center: [103.847, 36.0473],
  73. zoom: 4
  74. });
  75. var option = {
  76. color: ['gold','aqua','lime'],
  77. tooltip : {
  78. trigger: 'item',
  79. formatter: '{b}'
  80. },
  81. legend: {
  82. orient: 'vertical',
  83. x:'right',
  84. y:"center",
  85. data:['北京 Top10', '上海 Top10', '广州 Top10'],
  86. selectedMode: 'single',
  87. selected:{
  88. '上海 Top10' : false,
  89. '广州 Top10' : false
  90. },
  91. textStyle : {
  92. color: 'auto'
  93. }
  94. },
  95. series : [
  96. /*{
  97. type: 'map',
  98. mapType: 'none',
  99. roam: false,//鼠标滚轮缩放
  100. data:[],
  101. itemStyle:{
  102. normal:{
  103. borderColor:'rgba(100,149,237,1)',
  104. borderWidth:0.5,
  105. areaStyle:{
  106. color: '#1b1b1b'
  107. }
  108. }
  109. },
  110. markLine : {
  111. smooth:true,
  112. symbol: ['none', 'circle'],
  113. symbolSize : 1,
  114. itemStyle : {
  115. normal: {
  116. color:'#fff',
  117. borderWidth:1,
  118. borderColor:'rgba(255,0,0,0.8)'
  119. }
  120. },
  121. data : [
  122. [{name:'北京'},{name:'包头'}],
  123. [{name:'北京'},{name:'北海'}],
  124. [{name:'北京'},{name:'广州'}],
  125. [{name:'北京'},{name:'郑州'}],
  126. [{name:'北京'},{name:'长春'}],
  127. [{name:'北京'},{name:'长治'}],
  128. [{name:'北京'},{name:'重庆'}],
  129. [{name:'北京'},{name:'长沙'}],
  130. [{name:'北京'},{name:'成都'}],
  131. [{name:'北京'},{name:'常州'}],
  132. [{name:'北京'},{name:'丹东'}],
  133. [{name:'北京'},{name:'大连'}],
  134. [{name:'北京'},{name:'东营'}],
  135. [{name:'北京'},{name:'延安'}],
  136. [{name:'北京'},{name:'福州'}],
  137. [{name:'北京'},{name:'海口'}],
  138. [{name:'北京'},{name:'呼和浩特'}],
  139. [{name:'北京'},{name:'合肥'}],
  140. [{name:'北京'},{name:'杭州'}],
  141. [{name:'北京'},{name:'哈尔滨'}],
  142. [{name:'北京'},{name:'舟山'}],
  143. [{name:'北京'},{name:'银川'}],
  144. [{name:'北京'},{name:'衢州'}],
  145. [{name:'北京'},{name:'南昌'}],
  146. [{name:'北京'},{name:'昆明'}],
  147. [{name:'北京'},{name:'贵阳'}],
  148. [{name:'北京'},{name:'兰州'}],
  149. [{name:'北京'},{name:'拉萨'}],
  150. [{name:'北京'},{name:'连云港'}],
  151. [{name:'北京'},{name:'临沂'}],
  152. [{name:'北京'},{name:'柳州'}],
  153. [{name:'北京'},{name:'宁波'}],
  154. [{name:'北京'},{name:'南京'}],
  155. [{name:'北京'},{name:'南宁'}],
  156. [{name:'北京'},{name:'南通'}],
  157. [{name:'北京'},{name:'上海'}],
  158. [{name:'北京'},{name:'沈阳'}],
  159. [{name:'北京'},{name:'西安'}],
  160. [{name:'北京'},{name:'汕头'}],
  161. [{name:'北京'},{name:'深圳'}],
  162. [{name:'北京'},{name:'青岛'}],
  163. [{name:'北京'},{name:'济南'}],
  164. [{name:'北京'},{name:'太原'}],
  165. [{name:'北京'},{name:'乌鲁木齐'}],
  166. [{name:'北京'},{name:'潍坊'}],
  167. [{name:'北京'},{name:'威海'}],
  168. [{name:'北京'},{name:'温州'}],
  169. [{name:'北京'},{name:'武汉'}],
  170. [{name:'北京'},{name:'无锡'}],
  171. [{name:'北京'},{name:'厦门'}],
  172. [{name:'北京'},{name:'西宁'}],
  173. [{name:'北京'},{name:'徐州'}],
  174. [{name:'北京'},{name:'烟台'}],
  175. [{name:'北京'},{name:'盐城'}],
  176. [{name:'北京'},{name:'珠海'}],
  177. [{name:'上海'},{name:'包头'}],
  178. [{name:'上海'},{name:'北海'}],
  179. [{name:'上海'},{name:'广州'}],
  180. [{name:'上海'},{name:'郑州'}],
  181. [{name:'上海'},{name:'长春'}],
  182. [{name:'上海'},{name:'重庆'}],
  183. [{name:'上海'},{name:'长沙'}],
  184. [{name:'上海'},{name:'成都'}],
  185. [{name:'上海'},{name:'丹东'}],
  186. [{name:'上海'},{name:'大连'}],
  187. [{name:'上海'},{name:'福州'}],
  188. [{name:'上海'},{name:'海口'}],
  189. [{name:'上海'},{name:'呼和浩特'}],
  190. [{name:'上海'},{name:'合肥'}],
  191. [{name:'上海'},{name:'哈尔滨'}],
  192. [{name:'上海'},{name:'舟山'}],
  193. [{name:'上海'},{name:'银川'}],
  194. [{name:'上海'},{name:'南昌'}],
  195. [{name:'上海'},{name:'昆明'}],
  196. [{name:'上海'},{name:'贵阳'}],
  197. [{name:'上海'},{name:'兰州'}],
  198. [{name:'上海'},{name:'拉萨'}],
  199. [{name:'上海'},{name:'连云港'}],
  200. [{name:'上海'},{name:'临沂'}],
  201. [{name:'上海'},{name:'柳州'}],
  202. [{name:'上海'},{name:'宁波'}],
  203. [{name:'上海'},{name:'南宁'}],
  204. [{name:'上海'},{name:'北京'}],
  205. [{name:'上海'},{name:'沈阳'}],
  206. [{name:'上海'},{name:'秦皇岛'}],
  207. [{name:'上海'},{name:'西安'}],
  208. [{name:'上海'},{name:'石家庄'}],
  209. [{name:'上海'},{name:'汕头'}],
  210. [{name:'上海'},{name:'深圳'}],
  211. [{name:'上海'},{name:'青岛'}],
  212. [{name:'上海'},{name:'济南'}],
  213. [{name:'上海'},{name:'天津'}],
  214. [{name:'上海'},{name:'太原'}],
  215. [{name:'上海'},{name:'乌鲁木齐'}],
  216. [{name:'上海'},{name:'潍坊'}],
  217. [{name:'上海'},{name:'威海'}],
  218. [{name:'上海'},{name:'温州'}],
  219. [{name:'上海'},{name:'武汉'}],
  220. [{name:'上海'},{name:'厦门'}],
  221. [{name:'上海'},{name:'西宁'}],
  222. [{name:'上海'},{name:'徐州'}],
  223. [{name:'上海'},{name:'烟台'}],
  224. [{name:'上海'},{name:'珠海'}],
  225. [{name:'广州'},{name:'北海'}],
  226. [{name:'广州'},{name:'郑州'}],
  227. [{name:'广州'},{name:'长春'}],
  228. [{name:'广州'},{name:'重庆'}],
  229. [{name:'广州'},{name:'长沙'}],
  230. [{name:'广州'},{name:'成都'}],
  231. [{name:'广州'},{name:'常州'}],
  232. [{name:'广州'},{name:'大连'}],
  233. [{name:'广州'},{name:'福州'}],
  234. [{name:'广州'},{name:'海口'}],
  235. [{name:'广州'},{name:'呼和浩特'}],
  236. [{name:'广州'},{name:'合肥'}],
  237. [{name:'广州'},{name:'杭州'}],
  238. [{name:'广州'},{name:'哈尔滨'}],
  239. [{name:'广州'},{name:'舟山'}],
  240. [{name:'广州'},{name:'银川'}],
  241. [{name:'广州'},{name:'南昌'}],
  242. [{name:'广州'},{name:'昆明'}],
  243. [{name:'广州'},{name:'贵阳'}],
  244. [{name:'广州'},{name:'兰州'}],
  245. [{name:'广州'},{name:'拉萨'}],
  246. [{name:'广州'},{name:'连云港'}],
  247. [{name:'广州'},{name:'临沂'}],
  248. [{name:'广州'},{name:'柳州'}],
  249. [{name:'广州'},{name:'宁波'}],
  250. [{name:'广州'},{name:'南京'}],
  251. [{name:'广州'},{name:'南宁'}],
  252. [{name:'广州'},{name:'南通'}],
  253. [{name:'广州'},{name:'北京'}],
  254. [{name:'广州'},{name:'上海'}],
  255. [{name:'广州'},{name:'沈阳'}],
  256. [{name:'广州'},{name:'西安'}],
  257. [{name:'广州'},{name:'石家庄'}],
  258. [{name:'广州'},{name:'汕头'}],
  259. [{name:'广州'},{name:'青岛'}],
  260. [{name:'广州'},{name:'济南'}],
  261. [{name:'广州'},{name:'天津'}],
  262. [{name:'广州'},{name:'太原'}],
  263. [{name:'广州'},{name:'乌鲁木齐'}],
  264. [{name:'广州'},{name:'温州'}],
  265. [{name:'广州'},{name:'武汉'}],
  266. [{name:'广州'},{name:'无锡'}],
  267. [{name:'广州'},{name:'厦门'}],
  268. [{name:'广州'},{name:'西宁'}],
  269. [{name:'广州'},{name:'徐州'}],
  270. [{name:'广州'},{name:'烟台'}],
  271. [{name:'广州'},{name:'盐城'}]
  272. ]
  273. },
  274. geoCoord: {
  275. '上海': [121.4648,31.2891],
  276. '东莞': [113.8953,22.901],
  277. '东营': [118.7073,37.5513],
  278. '中山': [113.4229,22.478],
  279. '临汾': [111.4783,36.1615],
  280. '临沂': [118.3118,35.2936],
  281. '丹东': [124.541,40.4242],
  282. '丽水': [119.5642,28.1854],
  283. '乌鲁木齐': [87.9236,43.5883],
  284. '佛山': [112.8955,23.1097],
  285. '保定': [115.0488,39.0948],
  286. '兰州': [103.5901,36.3043],
  287. '包头': [110.3467,41.4899],
  288. '北京': [116.4551,40.2539],
  289. '北海': [109.314,21.6211],
  290. '南京': [118.8062,31.9208],
  291. '南宁': [108.479,23.1152],
  292. '南昌': [116.0046,28.6633],
  293. '南通': [121.1023,32.1625],
  294. '厦门': [118.1689,24.6478],
  295. '台州': [121.1353,28.6688],
  296. '合肥': [117.29,32.0581],
  297. '呼和浩特': [111.4124,40.4901],
  298. '咸阳': [108.4131,34.8706],
  299. '哈尔滨': [127.9688,45.368],
  300. '唐山': [118.4766,39.6826],
  301. '嘉兴': [120.9155,30.6354],
  302. '大同': [113.7854,39.8035],
  303. '大连': [122.2229,39.4409],
  304. '天津': [117.4219,39.4189],
  305. '太原': [112.3352,37.9413],
  306. '威海': [121.9482,37.1393],
  307. '宁波': [121.5967,29.6466],
  308. '宝鸡': [107.1826,34.3433],
  309. '宿迁': [118.5535,33.7775],
  310. '常州': [119.4543,31.5582],
  311. '广州': [113.5107,23.2196],
  312. '廊坊': [116.521,39.0509],
  313. '延安': [109.1052,36.4252],
  314. '张家口': [115.1477,40.8527],
  315. '徐州': [117.5208,34.3268],
  316. '德州': [116.6858,37.2107],
  317. '惠州': [114.6204,23.1647],
  318. '成都': [103.9526,30.7617],
  319. '扬州': [119.4653,32.8162],
  320. '承德': [117.5757,41.4075],
  321. '拉萨': [91.1865,30.1465],
  322. '无锡': [120.3442,31.5527],
  323. '日照': [119.2786,35.5023],
  324. '昆明': [102.9199,25.4663],
  325. '杭州': [119.5313,29.8773],
  326. '枣庄': [117.323,34.8926],
  327. '柳州': [109.3799,24.9774],
  328. '株洲': [113.5327,27.0319],
  329. '武汉': [114.3896,30.6628],
  330. '汕头': [117.1692,23.3405],
  331. '江门': [112.6318,22.1484],
  332. '沈阳': [123.1238,42.1216],
  333. '沧州': [116.8286,38.2104],
  334. '河源': [114.917,23.9722],
  335. '泉州': [118.3228,25.1147],
  336. '泰安': [117.0264,36.0516],
  337. '泰州': [120.0586,32.5525],
  338. '济南': [117.1582,36.8701],
  339. '济宁': [116.8286,35.3375],
  340. '海口': [110.3893,19.8516],
  341. '淄博': [118.0371,36.6064],
  342. '淮安': [118.927,33.4039],
  343. '深圳': [114.5435,22.5439],
  344. '清远': [112.9175,24.3292],
  345. '温州': [120.498,27.8119],
  346. '渭南': [109.7864,35.0299],
  347. '湖州': [119.8608,30.7782],
  348. '湘潭': [112.5439,27.7075],
  349. '滨州': [117.8174,37.4963],
  350. '潍坊': [119.0918,36.524],
  351. '烟台': [120.7397,37.5128],
  352. '玉溪': [101.9312,23.8898],
  353. '珠海': [113.7305,22.1155],
  354. '盐城': [120.2234,33.5577],
  355. '盘锦': [121.9482,41.0449],
  356. '石家庄': [114.4995,38.1006],
  357. '福州': [119.4543,25.9222],
  358. '秦皇岛': [119.2126,40.0232],
  359. '绍兴': [120.564,29.7565],
  360. '聊城': [115.9167,36.4032],
  361. '肇庆': [112.1265,23.5822],
  362. '舟山': [122.2559,30.2234],
  363. '苏州': [120.6519,31.3989],
  364. '莱芜': [117.6526,36.2714],
  365. '菏泽': [115.6201,35.2057],
  366. '营口': [122.4316,40.4297],
  367. '葫芦岛': [120.1575,40.578],
  368. '衡水': [115.8838,37.7161],
  369. '衢州': [118.6853,28.8666],
  370. '西宁': [101.4038,36.8207],
  371. '西安': [109.1162,34.2004],
  372. '贵阳': [106.6992,26.7682],
  373. '连云港': [119.1248,34.552],
  374. '邢台': [114.8071,37.2821],
  375. '邯郸': [114.4775,36.535],
  376. '郑州': [113.4668,34.6234],
  377. '鄂尔多斯': [108.9734,39.2487],
  378. '重庆': [107.7539,30.1904],
  379. '金华': [120.0037,29.1028],
  380. '铜川': [109.0393,35.1947],
  381. '银川': [106.3586,38.1775],
  382. '镇江': [119.4763,31.9702],
  383. '长春': [125.8154,44.2584],
  384. '长沙': [113.0823,28.2568],
  385. '长治': [112.8625,36.4746],
  386. '阳泉': [113.4778,38.0951],
  387. '青岛': [120.4651,36.3373],
  388. '韶关': [113.7964,24.7028]
  389. }
  390. },*/
  391. {
  392. name: '北京 Top10',
  393. type: 'map',
  394. mapType: 'none',
  395. roam: false,//鼠标滚轮缩放
  396. data:[],
  397. geoCoord: {
  398. '上海': [121.4648,31.2891],
  399. '东莞': [113.8953,22.901],
  400. '东营': [118.7073,37.5513],
  401. '中山': [113.4229,22.478],
  402. '临汾': [111.4783,36.1615],
  403. '临沂': [118.3118,35.2936],
  404. '丹东': [124.541,40.4242],
  405. '丽水': [119.5642,28.1854],
  406. '乌鲁木齐': [87.9236,43.5883],
  407. '佛山': [112.8955,23.1097],
  408. '保定': [115.0488,39.0948],
  409. '兰州': [103.5901,36.3043],
  410. '包头': [110.3467,41.4899],
  411. '北京': [116.4551,40.2539],
  412. '北海': [109.314,21.6211],
  413. '南京': [118.8062,31.9208],
  414. '南宁': [108.479,23.1152],
  415. '南昌': [116.0046,28.6633],
  416. '南通': [121.1023,32.1625],
  417. '厦门': [118.1689,24.6478],
  418. '台州': [121.1353,28.6688],
  419. '合肥': [117.29,32.0581],
  420. '呼和浩特': [111.4124,40.4901],
  421. '咸阳': [108.4131,34.8706],
  422. '哈尔滨': [127.9688,45.368],
  423. '唐山': [118.4766,39.6826],
  424. '嘉兴': [120.9155,30.6354],
  425. '大同': [113.7854,39.8035],
  426. '大连': [122.2229,39.4409],
  427. '天津': [117.4219,39.4189],
  428. '太原': [112.3352,37.9413],
  429. '威海': [121.9482,37.1393],
  430. '宁波': [121.5967,29.6466],
  431. '宝鸡': [107.1826,34.3433],
  432. '宿迁': [118.5535,33.7775],
  433. '常州': [119.4543,31.5582],
  434. '广州': [113.5107,23.2196],
  435. '廊坊': [116.521,39.0509],
  436. '延安': [109.1052,36.4252],
  437. '张家口': [115.1477,40.8527],
  438. '徐州': [117.5208,34.3268],
  439. '德州': [116.6858,37.2107],
  440. '惠州': [114.6204,23.1647],
  441. '成都': [103.9526,30.7617],
  442. '扬州': [119.4653,32.8162],
  443. '承德': [117.5757,41.4075],
  444. '拉萨': [91.1865,30.1465],
  445. '无锡': [120.3442,31.5527],
  446. '日照': [119.2786,35.5023],
  447. '昆明': [102.9199,25.4663],
  448. '杭州': [119.5313,29.8773],
  449. '枣庄': [117.323,34.8926],
  450. '柳州': [109.3799,24.9774],
  451. '株洲': [113.5327,27.0319],
  452. '武汉': [114.3896,30.6628],
  453. '汕头': [117.1692,23.3405],
  454. '江门': [112.6318,22.1484],
  455. '沈阳': [123.1238,42.1216],
  456. '沧州': [116.8286,38.2104],
  457. '河源': [114.917,23.9722],
  458. '泉州': [118.3228,25.1147],
  459. '泰安': [117.0264,36.0516],
  460. '泰州': [120.0586,32.5525],
  461. '济南': [117.1582,36.8701],
  462. '济宁': [116.8286,35.3375],
  463. '海口': [110.3893,19.8516],
  464. '淄博': [118.0371,36.6064],
  465. '淮安': [118.927,33.4039],
  466. '深圳': [114.5435,22.5439],
  467. '清远': [112.9175,24.3292],
  468. '温州': [120.498,27.8119],
  469. '渭南': [109.7864,35.0299],
  470. '湖州': [119.8608,30.7782],
  471. '湘潭': [112.5439,27.7075],
  472. '滨州': [117.8174,37.4963],
  473. '潍坊': [119.0918,36.524],
  474. '烟台': [120.7397,37.5128],
  475. '玉溪': [101.9312,23.8898],
  476. '珠海': [113.7305,22.1155],
  477. '盐城': [120.2234,33.5577],
  478. '盘锦': [121.9482,41.0449],
  479. '石家庄': [114.4995,38.1006],
  480. '福州': [119.4543,25.9222],
  481. '秦皇岛': [119.2126,40.0232],
  482. '绍兴': [120.564,29.7565],
  483. '聊城': [115.9167,36.4032],
  484. '肇庆': [112.1265,23.5822],
  485. '舟山': [122.2559,30.2234],
  486. '苏州': [120.6519,31.3989],
  487. '莱芜': [117.6526,36.2714],
  488. '菏泽': [115.6201,35.2057],
  489. '营口': [122.4316,40.4297],
  490. '葫芦岛': [120.1575,40.578],
  491. '衡水': [115.8838,37.7161],
  492. '衢州': [118.6853,28.8666],
  493. '西宁': [101.4038,36.8207],
  494. '西安': [109.1162,34.2004],
  495. '贵阳': [106.6992,26.7682],
  496. '连云港': [119.1248,34.552],
  497. '邢台': [114.8071,37.2821],
  498. '邯郸': [114.4775,36.535],
  499. '郑州': [113.4668,34.6234],
  500. '鄂尔多斯': [108.9734,39.2487],
  501. '重庆': [107.7539,30.1904],
  502. '金华': [120.0037,29.1028],
  503. '铜川': [109.0393,35.1947],
  504. '银川': [106.3586,38.1775],
  505. '镇江': [119.4763,31.9702],
  506. '长春': [125.8154,44.2584],
  507. '长沙': [113.0823,28.2568],
  508. '长治': [112.8625,36.4746],
  509. '阳泉': [113.4778,38.0951],
  510. '青岛': [120.4651,36.3373],
  511. '韶关': [113.7964,24.7028]
  512. },
  513. markLine : {
  514. smooth:true,
  515. effect : {
  516. show: true,
  517. scaleSize: 1,
  518. period: 30,
  519. color: '#fff',
  520. shadowBlur: 10
  521. },
  522. itemStyle : {
  523. normal: {
  524. borderWidth:1,
  525. lineStyle: {
  526. type: 'solid',
  527. shadowBlur: 10
  528. }
  529. }
  530. },
  531. data : [
  532. [{name:'北京'}, {name:'上海',value:95}],
  533. [{name:'北京'}, {name:'广州',value:90}],
  534. [{name:'北京'}, {name:'大连',value:80}],
  535. [{name:'北京'}, {name:'南宁',value:70}],
  536. [{name:'北京'}, {name:'南昌',value:60}],
  537. [{name:'北京'}, {name:'拉萨',value:50}],
  538. [{name:'北京'}, {name:'长春',value:40}],
  539. [{name:'北京'}, {name:'包头',value:30}],
  540. [{name:'北京'}, {name:'重庆',value:20}],
  541. [{name:'北京'}, {name:'常州',value:10}]
  542. ]
  543. },
  544. markPoint : {
  545. symbol:'emptyCircle',
  546. symbolSize : function (v){
  547. return 10 + v/10
  548. },
  549. effect : {
  550. show: true,
  551. shadowBlur : 0
  552. },
  553. itemStyle:{
  554. normal:{
  555. label:{show:false}
  556. },
  557. emphasis: {
  558. label:{position:'top'}
  559. }
  560. },
  561. data : [
  562. {name:'上海',value:95},
  563. {name:'广州',value:90},
  564. {name:'大连',value:80},
  565. {name:'南宁',value:70},
  566. {name:'南昌',value:60},
  567. {name:'拉萨',value:50},
  568. {name:'长春',value:40},
  569. {name:'包头',value:30},
  570. {name:'重庆',value:20},
  571. {name:'常州',value:10}
  572. ]
  573. }
  574. },
  575. {
  576. name: '上海 Top10',
  577. type: 'map',
  578. mapType: 'none',
  579. roam: false,//鼠标滚轮缩放
  580. data:[],
  581. markLine : {
  582. smooth:true,
  583. effect : {
  584. show: true,
  585. scaleSize: 1,
  586. period: 30,
  587. color: '#fff',
  588. shadowBlur: 10
  589. },
  590. itemStyle : {
  591. normal: {
  592. borderWidth:1,
  593. lineStyle: {
  594. type: 'solid',
  595. shadowBlur: 10
  596. }
  597. }
  598. },
  599. data : [
  600. [{name:'上海'},{name:'包头',value:95}],
  601. [{name:'上海'},{name:'昆明',value:90}],
  602. [{name:'上海'},{name:'广州',value:80}],
  603. [{name:'上海'},{name:'郑州',value:70}],
  604. [{name:'上海'},{name:'长春',value:60}],
  605. [{name:'上海'},{name:'重庆',value:50}],
  606. [{name:'上海'},{name:'长沙',value:40}],
  607. [{name:'上海'},{name:'北京',value:30}],
  608. [{name:'上海'},{name:'丹东',value:20}],
  609. [{name:'上海'},{name:'大连',value:10}]
  610. ]
  611. },
  612. markPoint : {
  613. symbol:'emptyCircle',
  614. symbolSize : function (v){
  615. return 10 + v/10
  616. },
  617. effect : {
  618. show: true,
  619. shadowBlur : 0
  620. },
  621. itemStyle:{
  622. normal:{
  623. label:{show:false}
  624. },
  625. emphasis: {
  626. label:{position:'top'}
  627. }
  628. },
  629. data : [
  630. {name:'包头',value:95},
  631. {name:'昆明',value:90},
  632. {name:'广州',value:80},
  633. {name:'郑州',value:70},
  634. {name:'长春',value:60},
  635. {name:'重庆',value:50},
  636. {name:'长沙',value:40},
  637. {name:'北京',value:30},
  638. {name:'丹东',value:20},
  639. {name:'大连',value:10}
  640. ]
  641. }
  642. },
  643. {
  644. name: '广州 Top10',
  645. type: 'map',
  646. mapType: 'none',
  647. roam: false,//鼠标滚轮缩放
  648. data:[],
  649. markLine : {
  650. smooth:true,
  651. effect : {
  652. show: true,
  653. scaleSize: 1,
  654. period: 30,
  655. color: '#fff',
  656. shadowBlur: 10
  657. },
  658. itemStyle : {
  659. normal: {
  660. borderWidth:1,
  661. lineStyle: {
  662. type: 'solid',
  663. shadowBlur: 10
  664. }
  665. }
  666. },
  667. data : [
  668. [{name:'广州'},{name:'福州',value:95}],
  669. [{name:'广州'},{name:'太原',value:90}],
  670. [{name:'广州'},{name:'长春',value:80}],
  671. [{name:'广州'},{name:'重庆',value:70}],
  672. [{name:'广州'},{name:'西安',value:60}],
  673. [{name:'广州'},{name:'成都',value:50}],
  674. [{name:'广州'},{name:'常州',value:40}],
  675. [{name:'广州'},{name:'北京',value:30}],
  676. [{name:'广州'},{name:'北海',value:20}],
  677. [{name:'广州'},{name:'海口',value:10}]
  678. ]
  679. },
  680. markPoint : {
  681. symbol:'emptyCircle',
  682. symbolSize : function (v){
  683. return 10 + v/10
  684. },
  685. effect : {
  686. show: true,
  687. shadowBlur : 0
  688. },
  689. itemStyle:{
  690. normal:{
  691. label:{show:false}
  692. },
  693. emphasis: {
  694. label:{position:'top'}
  695. }
  696. },
  697. data : [
  698. {name:'福州',value:95},
  699. {name:'太原',value:90},
  700. {name:'长春',value:80},
  701. {name:'重庆',value:70},
  702. {name:'西安',value:60},
  703. {name:'成都',value:50},
  704. {name:'常州',value:40},
  705. {name:'北京',value:30},
  706. {name:'北海',value:20},
  707. {name:'海口',value:10}
  708. ]
  709. }
  710. }
  711. ]
  712. };
  713. require([
  714. 'echarts',
  715. 'echarts/chart/map'
  716. ], function (echart) {
  717. echartlayer = new OpenLayers.Layer.EchartLayer("echartlayer",map,echart,{
  718. option:option
  719. });
  720. map.addLayer(echartlayer);
  721. echartlayer.updateLayer();
  722. });
  723. }
  724. </script>
  725. </head>
  726. <body οnlοad="init()">
  727. <div id="map">
  728. </div>
  729. </body>
  730. </html>


查看示例


传播GIS知识 | 交流GIS经验 | 分享GIS价值 | 专注GIS发展

技术博客

http://blog.csdn.net/gisshixisheng

在线教程

http://edu.csdn.net/course/detail/799
Github

https://github.com/lzugis/

联系方式

q       q:1004740957

e-mail:niujp08@qq.com

公众号:lzugis15

Q Q 群:452117357(webgis)
             337469080(Android)




转载于:https://www.cnblogs.com/lzugis/p/6539773.html

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号