Няма описание

map.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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: 800px;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 myChart = echarts.init(document.getElementById('main'));
  14. var aymap = "https://geo.datav.aliyun.com/areas_v2/bound/410500_full.json"
  15. var mapname = aymap
  16. var mapDate = [{
  17. name: '安阳县',
  18. value: [114.295989,36.231785]
  19. },
  20. {
  21. name: '北关区',
  22. value: [114.362125,36.113991]
  23. },
  24. {
  25. name: '滑县',
  26. value: [114.525642,35.581353]
  27. },
  28. {
  29. name: '龙安区',
  30. value: [114.307696,36.082559]
  31. },
  32. {
  33. name: '林州市123',
  34. value: [113.825847,36.089035]
  35. },
  36. {
  37. name: '内黄县',
  38. value: [114.907997,35.97751]
  39. },
  40. {
  41. name: '汤阴县',
  42. value: [114.364023,35.930939]
  43. },
  44. {
  45. name: '文峰区',
  46. value: [114.398996,36.104678]
  47. },
  48. {
  49. name: '殷都区',
  50. value:[114.310095,36.115555]
  51. },
  52. {
  53. name: '高新区',
  54. value:[114.310095,36.115555]
  55. }
  56. ];
  57. // let index = -1;
  58. // myChart.dispatchAction({
  59. // type: 'showTip',
  60. // seriesIndex: 0,
  61. // dataIndex: index + 1
  62. // });
  63. setTimeout(function() {
  64. mapInit()
  65. }, 1000);
  66. var mapInit = () => {
  67. $.getJSON(mapname, function(geoJson) {
  68. echarts.registerMap('hanzhou', geoJson);
  69. myChart.hideLoading();
  70. option = {
  71. backgroundColor: '#020933',
  72. geo: {
  73. map: 'hanzhou',
  74. aspectScale: 0.75, //长宽比
  75. zoom: 1.1,
  76. roam: false,
  77. itemStyle: {
  78. normal: {
  79. areaColor: '#013C62',
  80. shadowColor: '#182f68',
  81. shadowOffsetX: 0,
  82. shadowOffsetY: 25
  83. },
  84. emphasis: {
  85. show:false,
  86. borderColor: '#f8e107', //边框颜色
  87. areaColor: '#0a2944', //鼠标移上去的颜色
  88. borderWidth: 1
  89. }
  90. }
  91. },
  92. visualMap: {
  93. show: false,
  94. max: 100,
  95. seriesIndex: [3],
  96. inRange: {
  97. color: ['#A5DCF4', '#006edd']
  98. }
  99. },
  100. series: [{
  101. type: 'map',
  102. roam: true,
  103. label: {
  104. normal: {
  105. show: true,
  106. textStyle: {
  107. color: '#fff'
  108. }
  109. },
  110. emphasis: {
  111. show:false,
  112. textStyle: {
  113. color: '#fff'
  114. }
  115. }
  116. },
  117. itemStyle: {
  118. normal: {
  119. borderColor: '#2ab8ff',
  120. borderWidth: 1.5,
  121. areaColor: '#12235c'
  122. },
  123. emphasis: {
  124. show:false,
  125. borderColor: '#f8e107', //边框颜色
  126. areaColor: '#0a2944', //鼠标移上去的颜色
  127. borderWidth: 1,
  128. }
  129. },
  130. zoom: 1.1,
  131. roam: false,
  132. map: 'hanzhou' //使用
  133. // data: this.difficultData //热力图数据 不同区域 不同的底色
  134. },
  135. {
  136. type: 'effectScatter',
  137. coordinateSystem: 'geo',
  138. showEffectOn: 'render',
  139. rippleEffect: {
  140. period: 15,
  141. scale: 4,
  142. brushType: 'fill'
  143. },
  144. hoverAnimation: true,
  145. itemStyle: {
  146. normal: {
  147. color: '#f0f',
  148. shadowBlur: 10,
  149. shadowColor: '#ff0'
  150. }
  151. },
  152. data: mapDate
  153. }
  154. ]
  155. };
  156. myChart.setOption(option);
  157. });
  158. }
  159. </script>
  160. <!-- <script>
  161. var myChart = echarts.init(document.getElementById('main'));
  162. var uploadedDataURL = "format.1629790904713.json";
  163. var center = {
  164. "安阳县":[114.295989,36.231785],
  165. "北关区":[114.362125,36.113991],
  166. "滑县":[114.525642,35.581353],
  167. "龙安区":[114.307696,36.082559],
  168. "高新区":[114.310095,36.115555],
  169. "殷都区":[114.310095,36.115555],
  170. "文峰区":[114.398996,36.104678],
  171. "汤阴县":[114.364023,35.930939],
  172. "内黄县":[114.907997,35.97751],
  173. "林州市":[113.825847,36.089035]}
  174. var option = null;
  175. $.get(uploadedDataURL, function(json) {
  176. echarts.registerMap('js', json);
  177. option = {
  178. visualMap: {
  179. show: false,
  180. max: 100,
  181. seriesIndex: [3],
  182. inRange: {
  183. color: ['#A5DCF4', '#006edd']
  184. }
  185. },
  186. geo: [{
  187. map: 'js',
  188. roam: false, //是否允许缩放
  189. zoom: 1.1, //默认显示级别
  190. scaleLimit: {
  191. min: 0,
  192. max: 3
  193. }, //缩放级别
  194. itemStyle: {
  195. normal: {
  196. areaColor: '#013C62',
  197. shadowColor: '#013C62',
  198. shadowBlur: 20,
  199. shadowOffsetX: -5,
  200. shadowOffsetY: 15,
  201. }
  202. },
  203. tooltip: {
  204. show: false
  205. }
  206. }],
  207. series: [{
  208. type: 'effectScatter',
  209. coordinateSystem: 'geo',
  210. z: 5,
  211. data: [],
  212. symbolSize: 14,
  213. label: {
  214. normal: {
  215. show: true,
  216. formatter: function(params) {
  217. return '{fline|地点:'+ params.data.city +'}\n{tline|'+ (params.data.info || '发生xx集件') +'}';
  218. },
  219. position: 'top',
  220. backgroundColor: 'rgba(254,174,33,.8)',
  221. padding: [0, 0],
  222. borderRadius: 3,
  223. lineHeight: 32,
  224. color: '#f7fafb',
  225. rich: {
  226. fline: {
  227. padding: [0, 10, 10, 10],
  228. color: '#ffffff'
  229. },
  230. tline: {
  231. padding: [10, 10, 0, 10],
  232. color: '#ffffff'
  233. }
  234. }
  235. },
  236. emphasis: {
  237. show: true
  238. }
  239. },
  240. itemStyle: {
  241. color: '#feae21',
  242. }
  243. },
  244. {
  245. type: 'effectScatter',
  246. coordinateSystem: 'geo',
  247. z: 5,
  248. data: [],
  249. symbolSize: 14,
  250. label: {
  251. normal: {
  252. show: true,
  253. formatter: function(params) {
  254. return '{fline|地点:'+ params.data.city +'}\n{tline|'+ (params.data.info || '发生xx集件') +'}';
  255. },
  256. position: 'top',
  257. backgroundColor: 'rgba(233,63,66,.9)',
  258. padding: [0, 0],
  259. borderRadius: 3,
  260. lineHeight: 32,
  261. color: '#ffffff',
  262. rich: {
  263. fline: {
  264. padding: [0, 10, 10, 10],
  265. color: '#ffffff'
  266. },
  267. tline: {
  268. padding: [10, 10, 0, 10],
  269. color: '#ffffff'
  270. }
  271. }
  272. },
  273. emphasis: {
  274. show: true
  275. }
  276. },
  277. itemStyle: {
  278. color: '#e93f42',
  279. }
  280. },
  281. {
  282. type: 'effectScatter',
  283. coordinateSystem: 'geo',
  284. z: 5,
  285. data: [],
  286. symbolSize: 14,
  287. label: {
  288. normal: {
  289. show: true,
  290. formatter: function(params) {
  291. return '{fline|地点:'+ params.data.city +'}\n{tline|'+ (params.data.info || '发生xx集件') +'}';
  292. },
  293. position: 'top',
  294. backgroundColor: 'rgba(8,186,236,.9)',
  295. padding: [0, 0],
  296. borderRadius: 3,
  297. lineHeight: 32,
  298. color: '#ffffff',
  299. rich: {
  300. fline: {
  301. padding: [0, 10, 10, 10],
  302. color: '#ffffff'
  303. },
  304. tline: {
  305. padding: [10, 10, 0, 10],
  306. color: '#ffffff'
  307. }
  308. }
  309. },
  310. emphasis: {
  311. show: true
  312. }
  313. },
  314. itemStyle: {
  315. color: '#08baec',
  316. }
  317. },
  318. //地图
  319. {
  320. type: 'map',
  321. mapType: 'js',
  322. geoIndex: -1,
  323. zoom: 1.1, //默认显示级别
  324. label: {
  325. show: true,
  326. color: '#ffffff',
  327. emphasis: {
  328. color: 'white',
  329. show: false
  330. }
  331. },
  332. itemStyle: {
  333. normal: {
  334. borderColor: '#2980b9',
  335. borderWidth: 1,
  336. areaColor: '#12235c'
  337. },
  338. emphasis: {
  339. areaColor: '#FA8C16',
  340. borderWidth: 0,
  341. color: 'green'
  342. }
  343. },
  344. data: Object.keys(center).map(name => {return {
  345. name: name,
  346. value: Math.random()*100
  347. }})
  348. }
  349. ]
  350. };
  351. myChart.setOption(option);
  352. });
  353. // var timer = setInterval(() => {
  354. // //数据情况重绘,清除formatter移动效果,也可根据自身需求是否需要,删除这两行代码
  355. // /*option.series[seriesjson[runidx].createType-1].data = [];
  356. // myChart.setOption(option, true);*/
  357. // for(var i=0; i<3; i++){
  358. // option.series[i].data = [];
  359. // }
  360. // var cityIndex = Math.floor(Math.random() * 13);
  361. // var runidx = Math.floor(Math.random() * 3);
  362. // var coordCity = Object.keys(center)[cityIndex];
  363. // var coord = center[coordCity];
  364. // option.series[runidx].data = [{
  365. // city: coordCity,
  366. // value: coord
  367. // }];
  368. // // console.log(option.series[runidx].data)
  369. // // option.series[4].data = option.series[4].data.sort(function(a,b){
  370. // // return b.value-a.value;
  371. // // });
  372. // myChart.setOption(option, true);
  373. // }, Math.floor(Math.random() * 10000) + 3000);
  374. </script> -->
  375. </html>