hn_map.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // var uploadedDataURL = "/public/data/410000_city.json";
  2. var uploadedDataURL = "https://geo.datav.aliyun.com/areas/bound/410000_full.json";
  3. var myChart = echarts.init(document.getElementById('henan-map'));
  4. $.get(uploadedDataURL, function(geoJson) {
  5. echarts.registerMap('河南', geoJson);
  6. var allData = {
  7. "citys": [{
  8. "name": "郑州市",
  9. "value": [113.665412,34.757975],
  10. "symbolSize": 3,
  11. "itemStyle": {
  12. "normal": {
  13. "color": "#04b9ff"
  14. }
  15. }
  16. },
  17. {
  18. "name": "洛阳市",
  19. "value": [112.434468,34.663041],
  20. "symbolSize": 1,
  21. "itemStyle": {
  22. "normal": {
  23. "color": "#04b9ff"
  24. }
  25. }
  26. },
  27. {
  28. "name": "新乡市",
  29. "value": [113.883991,35.302616],
  30. "symbolSize": 1,
  31. "itemStyle": {
  32. "normal": {
  33. "color": "#04b9ff"
  34. }
  35. }
  36. },
  37. {
  38. "name": "开封市",
  39. "value": [114.341447,34.797049],
  40. "symbolSize": 1,
  41. "itemStyle": {
  42. "normal": {
  43. "color": "#04b9ff"
  44. }
  45. }
  46. },
  47. {
  48. "name": "南阳市",
  49. "value": [112.540918,32.999082],
  50. "symbolSize": 1,
  51. "itemStyle": {
  52. "normal": {
  53. "color": "#04b9ff"
  54. }
  55. }
  56. },
  57. {
  58. "name": "鹤壁市",
  59. "value": [114.295444,35.748236],
  60. "symbolSize": 1,
  61. "itemStyle": {
  62. "normal": {
  63. "color": "#04b9ff"
  64. }
  65. }
  66. },
  67. {
  68. "name": "濮阳市",
  69. "value": [115.041299,35.768234],
  70. "symbolSize": 1,
  71. "itemStyle": {
  72. "normal": {
  73. "color": "#04b9ff"
  74. }
  75. }
  76. },
  77. {
  78. "name": "驻马店市",
  79. "value": [114.024736,32.980169],
  80. "symbolSize": 1,
  81. "itemStyle": {
  82. "normal": {
  83. "color": "#04b9ff"
  84. }
  85. }
  86. }
  87. ],
  88. "moveLines": [{
  89. "fromName": "郑州市",
  90. "toName": "洛阳市",
  91. "coords": [
  92. [113.665412,34.757975],
  93. [112.434468,34.663041]
  94. ]
  95. },
  96. {
  97. "fromName": "郑州市",
  98. "toName": "新乡市",
  99. "coords": [
  100. [113.665412,34.757975],
  101. [113.883991,35.302616]
  102. ]
  103. },
  104. {
  105. "fromName": "郑州市",
  106. "toName": "开封市",
  107. "coords": [
  108. [113.665412,34.757975],
  109. [114.341447,34.797049]
  110. ]
  111. },
  112. {
  113. "fromName": "郑州市",
  114. "toName": "南阳市",
  115. "coords": [
  116. [113.665412,34.757975],
  117. [112.540918,32.999082]
  118. ]
  119. },
  120. {
  121. "fromName": "郑州市",
  122. "toName": "鹤壁市",
  123. "coords": [
  124. [113.665412,34.757975],
  125. [114.295444,35.748236]
  126. ]
  127. },
  128. {
  129. "fromName": "郑州市",
  130. "toName": "濮阳市",
  131. "coords": [
  132. [113.665412,34.757975],
  133. [115.041299,35.768234]
  134. ]
  135. },
  136. {
  137. "fromName": "郑州市",
  138. "toName": "驻马店市",
  139. "coords": [
  140. [113.665412,34.757975],
  141. [114.024736,32.980169]
  142. ]
  143. }
  144. ]
  145. };
  146. option = {
  147. backgroundColor:'rgba(128, 128, 128, 0.1)', //rgba设置透明度0.1
  148. title: {
  149. text: '',
  150. left: 'center',
  151. textStyle: {
  152. color: '#fff'
  153. }
  154. },
  155. legend: {
  156. show: false,
  157. orient: 'vertical',
  158. top: 'auto',
  159. left: 'right',
  160. data: ['地点', '线路'],
  161. textStyle: {
  162. color: '#fff'
  163. }
  164. },
  165. geo: {
  166. map: '河南',
  167. label: {
  168. emphasis: {
  169. show: false,
  170. textStyle: {
  171. color: '#fff',
  172. }
  173. }
  174. },
  175. roam: true,
  176. itemStyle: {
  177. normal: {
  178. borderColor: 'rgba(147, 235, 248, 1)',
  179. borderWidth: 1,
  180. areaColor: {
  181. type: 'radial',
  182. x: 0.5,
  183. y: 0.5,
  184. r: 0.8,
  185. colorStops: [{
  186. offset: 0,
  187. color: 'rgba(147, 235, 248, 0)' // 0% 处的颜色
  188. }, {
  189. offset: 1,
  190. color: 'rgba(147, 235, 248, .2)' // 100% 处的颜色
  191. }],
  192. globalCoord: false // 缺省为 false
  193. },
  194. shadowColor: 'rgba(128, 217, 248, 1)',
  195. // shadowColor: 'rgba(255, 255, 255, 1)',
  196. shadowOffsetX: -2,
  197. shadowOffsetY: 2,
  198. shadowBlur: 10
  199. },
  200. emphasis: {
  201. areaColor: '#389BB7',
  202. borderWidth: 0
  203. }
  204. }
  205. },
  206. series: [{
  207. name: '地点',
  208. type: 'effectScatter',
  209. coordinateSystem: 'geo',
  210. zlevel: 1,
  211. rippleEffect: {
  212. brushType: 'stroke',
  213. period: 7,
  214. scale: 26
  215. },
  216. label: {
  217. normal: {
  218. show: true,
  219. position: 'right',
  220. formatter: '{b}',
  221. textStyle:{
  222. fontSize: 14,
  223. color: '#fff'
  224. }
  225. },
  226. emphasis: {
  227. show: true,
  228. position: 'right',
  229. formatter: '{b}'
  230. }
  231. },
  232. symbolSize: 2,
  233. showEffectOn: 'render',
  234. itemStyle: {
  235. normal: {
  236. color: '#04b9ff',
  237. shadowBlur: 10,
  238. shadowColor: '#04b9ff'
  239. }
  240. },
  241. data: allData.citys
  242. }, {
  243. name: '线路',
  244. type: 'lines',
  245. coordinateSystem: 'geo',
  246. zlevel: 2,
  247. large: true,
  248. effect: {
  249. show: true,
  250. period: 4, //箭头指向速度,值越小速度越快
  251. trailLength: 0.02, //特效尾迹长度[0,1]值越大,尾迹越长重
  252. symbol: 'arrow', //箭头图标
  253. symbolSize: 5, //图标大小
  254. },
  255. lineStyle: {
  256. normal: {
  257. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  258. offset: 0,
  259. color: '#04b9ff'
  260. }, {
  261. offset: 1,
  262. color: '#04b9ff'
  263. }], false),
  264. width: 1, //尾迹线条宽度
  265. opacity: 1, //尾迹线条透明度
  266. curveness: .3 //尾迹线条曲直度
  267. }
  268. },
  269. data: allData.moveLines
  270. }]
  271. };
  272. myChart.setOption(option);
  273. });