Keine Beschreibung

map3.html 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. </head>
  7. <body>
  8. <div id="main" style="width: 1000px;height: 600px;"></div>
  9. </body>
  10. <script src="js/echarts.min.js"></script>
  11. <script src="js/jquery.min.js"></script>
  12. <script type="text/javascript">
  13. var uploadedDataURL = "format.1629790904713.json";
  14. var myChart = echarts.init(document.getElementById('main'));
  15. var geoCoordMap = {
  16. "安阳县": [114.295989, 36.231785],
  17. "北关区": [114.379621, 36.137115],
  18. "滑县": [114.667181, 35.465867],
  19. "龙安区": [114.254489, 36.044375],
  20. "高新区": [114.310095, 36.115555],
  21. "殷都区": [114.289197, 36.133648],
  22. "文峰区": [114.418257, 36.034251],
  23. "汤阴县": [114.455689, 35.902302],
  24. "内黄县": [114.8165, 35.900576],
  25. "林州市": [113.854634, 36.010256]
  26. }
  27. var customerBatteryCityData = [{
  28. name: "安阳县",
  29. value: 70
  30. },
  31. {
  32. name: "北关区",
  33. value: 20
  34. },
  35. {
  36. name: "滑县",
  37. value: 70
  38. },
  39. {
  40. name: "龙安区",
  41. value: 70
  42. },
  43. {
  44. name: "高新区",
  45. value: 120
  46. },
  47. {
  48. name: "殷都区",
  49. value: 70
  50. },
  51. {
  52. name: "文峰区",
  53. value: 70
  54. },
  55. {
  56. name: "汤阴县",
  57. value: 0
  58. },
  59. {
  60. name: "内黄县",
  61. value: 70
  62. },
  63. {
  64. name: "林州市",
  65. value: 10
  66. }
  67. ]
  68. $.getJSON(uploadedDataURL, function(geoJson) {
  69. echarts.registerMap('guangdong', geoJson);
  70. option = {
  71. // backgroundColor: '#131C38',
  72. // tooltip: {
  73. // trigger: 'item',
  74. // show: true,
  75. // enterable: true,
  76. // textStyle: {
  77. // fontSize: 20,
  78. // color: '#fff'
  79. // },
  80. // backgroundColor: 'rgba(0,2,89,0.8)',
  81. // formatter: '{b}<br />{c}'
  82. // },
  83. geo: [{
  84. map: 'guangdong',
  85. aspectScale: 0.9,
  86. roam: false, // 是否允许缩放
  87. zoom: 1.0, // 默认显示级别
  88. layoutSize: '95%',
  89. layoutCenter: ['55%', '50%'],
  90. itemStyle: {
  91. normal: {
  92. areaColor: {
  93. type: 'linear-gradient',
  94. x: 0,
  95. y: 400,
  96. x2: 0,
  97. y2: 0,
  98. colorStops: [{
  99. offset: 0,
  100. color: 'rgba(37,108,190,0.3)' // 0% 处的颜色
  101. }, {
  102. offset: 1,
  103. color: 'rgba(15,169,195,0.3)' // 50% 处的颜色
  104. }],
  105. global: true // 缺省为 false
  106. },
  107. borderColor: '#4ecee6',
  108. borderWidth: 1
  109. }
  110. },
  111. zlevel: 3
  112. }
  113. ],
  114. series: [
  115. // map
  116. {
  117. geoIndex: 0,
  118. // coordinateSystem: 'geo',
  119. showLegendSymbol: true,
  120. type: 'map',
  121. roam: true,
  122. label: {
  123. normal: {
  124. show: false,
  125. textStyle: {
  126. color: '#fff'
  127. }
  128. },
  129. emphasis: {
  130. show: false,
  131. textStyle: {
  132. color: '#fff'
  133. }
  134. }
  135. },
  136. itemStyle: {
  137. normal: {
  138. borderColor: '#2ab8ff',
  139. borderWidth: 1.5,
  140. areaColor: '#12235c'
  141. },
  142. emphasis: {
  143. show: false,
  144. areaColor: '#2AB8FF',
  145. borderWidth: 0,
  146. color: 'red'
  147. }
  148. },
  149. map: 'guangdong', // 使用
  150. data: customerBatteryCityData
  151. // data: this.difficultData //热力图数据 不同区域 不同的底色
  152. },
  153. // 柱状体的底部
  154. {
  155. type: 'scatter',
  156. coordinateSystem: 'geo',
  157. geoIndex: 0,
  158. zlevel: 4,
  159. label: {
  160. // 这儿是处理的
  161. formatter: '{b}',
  162. position: 'bottom',
  163. color: '#fff',
  164. fontSize: 12,
  165. distance: 10,
  166. show: true
  167. },
  168. symbol: 'circle',
  169. symbolSize: [20, 10],
  170. itemStyle: {
  171. // color: '#F7AF21',
  172. color: 'rgb(22,255,255, 1)',
  173. opacity: 1
  174. },
  175. silent: true,
  176. data: scatterData2()
  177. },
  178. // 底部外框
  179. {
  180. type: 'scatter',
  181. coordinateSystem: 'geo',
  182. geoIndex: 0,
  183. zlevel: 4,
  184. label: {
  185. show: false
  186. },
  187. symbol: 'circle',
  188. symbolSize: [40, 20],
  189. itemStyle: {
  190. color: {
  191. type: 'radial',
  192. x: 0.5,
  193. y: 0.5,
  194. r: 0.5,
  195. colorStops: [{
  196. offset: 0,
  197. color: 'rgb(22,255,255, 0)' // 0% 处的颜色
  198. },
  199. {
  200. offset: .75,
  201. color: 'rgb(22,255,255, 0)' // 100% 处的颜色
  202. },
  203. {
  204. offset: .751,
  205. color: 'rgb(22,255,255, 1)' // 100% 处的颜色
  206. },
  207. {
  208. offset: 1,
  209. color: 'rgb(22,255,255, 1)' // 100% 处的颜色
  210. }
  211. ],
  212. global: false // 缺省为 false
  213. },
  214. opacity: 1
  215. },
  216. silent: true,
  217. data: scatterData2()
  218. }
  219. ]
  220. }
  221. myChart.setOption(option);
  222. })
  223. // // 动态计算柱形图的高度(定一个max)
  224. // function lineMaxHeight () {
  225. // const maxValue = Math.max(...customerBatteryCityData.map(item => item.value))
  226. // return 0.9/maxValue
  227. // }
  228. // // 柱状体的主干
  229. // function lineData () {
  230. // return customerBatteryCityData.map((item) => {
  231. // return {
  232. // coords: [geoCoordMap[item.name], [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * lineMaxHeight()]]
  233. // }
  234. // })
  235. // }
  236. // // 柱状体的顶部
  237. // function scatterData () {
  238. // return customerBatteryCityData.map((item) => {
  239. // return [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * lineMaxHeight()]
  240. // })
  241. // }
  242. // 柱状体的底部
  243. function scatterData2() {
  244. return customerBatteryCityData.map((item) => {
  245. return {
  246. name: item.name,
  247. value: geoCoordMap[item.name]
  248. }
  249. })
  250. }
  251. </script>
  252. </html>