• Leaflet结合Echarts实现迁徙图


    效果图如下:

    1. html>
    2. <html>
    3. <head>
    4. <title>Leaflet结合Echarts4实现迁徙图title>
    5. <meta charset="utf-8" />
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <style>
    8. html,
    9. body,
    10. #map {
    11. height: 100%;
    12. padding: 0;
    13. margin: 0;
    14. }
    15. style>
    16. <script src="../../js/prjconfig.js" maptype="leaflet">script>
    17. head>
    18. <body>
    19. <div id="map">div>
    20. <script>
    21. var map = L.map('map', {
    22. crs: L.CRS.EPSG4326, //L.CRS.EPSG3857
    23. center: [MAPINIT.Location.lat, MAPINIT.Location.lon], //[40.76339, 106.9477844],
    24. zoom: MAPINIT.Location.zoom,
    25. minZoom: MAPINIT.zoomsExtent[0],
    26. maxZoom: MAPINIT.zoomsExtent[1],
    27. zoomControl: true
    28. });
    29. //使用WMTS Key-Value加载地图服务
    30. let _getc = "http://192.168.1.212:8095/server/default/getTile/wmts?request=GetCapabilities&service=wmts&layer=yx";
    31. MAPCONFIG.MAPWMTS_IMG = "http://192.168.1.212:8095/server/vtile/getTile/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=yx&STYLE=default&TILEMATRIXSET=w&FORMAT=image/png&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}&tk=''";
    32. L.tileLayer(MAPCONFIG.MAPWMTS_IMG, {
    33. zoomOffset: 1
    34. }).addTo(map);
    35. map.setView(L.latLng(37.550339, 104.114129), 4); //设置缩放级别及中心点
    36. //Echarts相关options配置
    37. var geoCoordMap = {
    38. "海门": [121.15, 31.89],
    39. "鄂尔多斯": [109.781327, 39.608266],
    40. "招远": [120.38, 37.35],
    41. "舟山": [122.207216, 29.985295],
    42. "齐齐哈尔": [123.97, 47.33],
    43. "盐城": [120.13, 33.38],
    44. "赤峰": [118.87, 42.28],
    45. "青岛": [120.33, 36.07],
    46. "乳山": [121.52, 36.89],
    47. "金昌": [102.188043, 38.520089],
    48. "泉州": [118.58, 24.93],
    49. "莱西": [120.53, 36.86],
    50. "日照": [119.46, 35.42],
    51. "胶南": [119.97, 35.88],
    52. "南通": [121.05, 32.08],
    53. "拉萨": [91.11, 29.97],
    54. "云浮": [112.02, 22.93],
    55. "梅州": [116.1, 24.55],
    56. "文登": [122.05, 37.2],
    57. "上海": [121.48, 31.22],
    58. "攀枝花": [101.718637, 26.582347],
    59. "威海": [122.1, 37.5],
    60. "承德": [117.93, 40.97],
    61. "厦门": [118.1, 24.46],
    62. "汕尾": [115.375279, 22.786211],
    63. "潮州": [116.63, 23.68],
    64. "丹东": [124.37, 40.13],
    65. "太仓": [121.1, 31.45],
    66. "曲靖": [103.79, 25.51],
    67. "烟台": [121.39, 37.52],
    68. "福州": [119.3, 26.08],
    69. "瓦房店": [121.979603, 39.627114],
    70. "即墨": [120.45, 36.38],
    71. "抚顺": [123.97, 41.97],
    72. "玉溪": [102.52, 24.35],
    73. "张家口": [114.87, 40.82],
    74. "阳泉": [113.57, 37.85],
    75. "莱州": [119.942327, 37.177017],
    76. "湖州": [120.1, 30.86],
    77. "汕头": [116.69, 23.39],
    78. "昆山": [120.95, 31.39],
    79. "宁波": [121.56, 29.86],
    80. "湛江": [110.359377, 21.270708],
    81. "揭阳": [116.35, 23.55],
    82. "荣成": [122.41, 37.16],
    83. "连云港": [119.16, 34.59],
    84. "葫芦岛": [120.836932, 40.711052],
    85. "常熟": [120.74, 31.64],
    86. "东莞": [113.75, 23.04],
    87. "河源": [114.68, 23.73],
    88. "淮安": [119.15, 33.5],
    89. "泰州": [119.9, 32.49],
    90. "南宁": [108.33, 22.84],
    91. "营口": [122.18, 40.65],
    92. "惠州": [114.4, 23.09],
    93. "江阴": [120.26, 31.91],
    94. "蓬莱": [120.75, 37.8],
    95. "韶关": [113.62, 24.84],
    96. "嘉峪关": [98.289152, 39.77313],
    97. "广州": [113.23, 23.16],
    98. "延安": [109.47, 36.6],
    99. "太原": [112.53, 37.87],
    100. "清远": [113.01, 23.7],
    101. "中山": [113.38, 22.52],
    102. "昆明": [102.73, 25.04],
    103. "寿光": [118.73, 36.86],
    104. "盘锦": [122.070714, 41.119997],
    105. "长治": [113.08, 36.18],
    106. "深圳": [114.07, 22.62],
    107. "珠海": [113.52, 22.3],
    108. "宿迁": [118.3, 33.96],
    109. "咸阳": [108.72, 34.36],
    110. "铜川": [109.11, 35.09],
    111. "平度": [119.97, 36.77],
    112. "佛山": [113.11, 23.05],
    113. "海口": [110.35, 20.02],
    114. "江门": [113.06, 22.61],
    115. "章丘": [117.53, 36.72],
    116. "肇庆": [112.44, 23.05],
    117. "大连": [121.62, 38.92],
    118. "临汾": [111.5, 36.08],
    119. "吴江": [120.63, 31.16],
    120. "石嘴山": [106.39, 39.04],
    121. "沈阳": [123.38, 41.8],
    122. "苏州": [120.62, 31.32],
    123. "茂名": [110.88, 21.68],
    124. "嘉兴": [120.76, 30.77],
    125. "长春": [125.35, 43.88],
    126. "胶州": [120.03336, 36.264622],
    127. "银川": [106.27, 38.47],
    128. "张家港": [120.555821, 31.875428],
    129. "三门峡": [111.19, 34.76],
    130. "锦州": [121.15, 41.13],
    131. "南昌": [115.89, 28.68],
    132. "柳州": [109.4, 24.33],
    133. "三亚": [109.511909, 18.252847],
    134. "自贡": [104.778442, 29.33903],
    135. "吉林": [126.57, 43.87],
    136. "阳江": [111.95, 21.85],
    137. "泸州": [105.39, 28.91],
    138. "西宁": [101.74, 36.56],
    139. "宜宾": [104.56, 29.77],
    140. "呼和浩特": [111.65, 40.82],
    141. "成都": [104.06, 30.67],
    142. "大同": [113.3, 40.12],
    143. "镇江": [119.44, 32.2],
    144. "桂林": [110.28, 25.29],
    145. "张家界": [110.479191, 29.117096],
    146. "宜兴": [119.82, 31.36],
    147. "北海": [109.12, 21.49],
    148. "西安": [108.95, 34.27],
    149. "金坛": [119.56, 31.74],
    150. "东营": [118.49, 37.46],
    151. "牡丹江": [129.58, 44.6],
    152. "遵义": [106.9, 27.7],
    153. "绍兴": [120.58, 30.01],
    154. "扬州": [119.42, 32.39],
    155. "常州": [119.95, 31.79],
    156. "潍坊": [119.1, 36.62],
    157. "重庆": [106.54, 29.59],
    158. "台州": [121.420757, 28.656386],
    159. "南京": [118.78, 32.04],
    160. "滨州": [118.03, 37.36],
    161. "贵阳": [106.71, 26.57],
    162. "无锡": [120.29, 31.59],
    163. "本溪": [123.73, 41.3],
    164. "克拉玛依": [84.77, 45.59],
    165. "渭南": [109.5, 34.52],
    166. "马鞍山": [118.48, 31.56],
    167. "宝鸡": [107.15, 34.38],
    168. "焦作": [113.21, 35.24],
    169. "句容": [119.16, 31.95],
    170. "北京": [116.46, 39.92],
    171. "徐州": [117.2, 34.26],
    172. "衡水": [115.72, 37.72],
    173. "包头": [110, 40.58],
    174. "绵阳": [104.73, 31.48],
    175. "乌鲁木齐": [87.68, 43.77],
    176. "枣庄": [117.57, 34.86],
    177. "杭州": [120.19, 30.26],
    178. "淄博": [118.05, 36.78],
    179. "鞍山": [122.85, 41.12],
    180. "溧阳": [119.48, 31.43],
    181. "库尔勒": [86.06, 41.68],
    182. "安阳": [114.35, 36.1],
    183. "开封": [114.35, 34.79],
    184. "济南": [117, 36.65],
    185. "德阳": [104.37, 31.13],
    186. "温州": [120.65, 28.01],
    187. "九江": [115.97, 29.71],
    188. "邯郸": [114.47, 36.6],
    189. "临安": [119.72, 30.23],
    190. "兰州": [103.73, 36.03],
    191. "沧州": [116.83, 38.33],
    192. "临沂": [118.35, 35.05],
    193. "南充": [106.110698, 30.837793],
    194. "天津": [117.2, 39.13],
    195. "富阳": [119.95, 30.07],
    196. "泰安": [117.13, 36.18],
    197. "诸暨": [120.23, 29.71],
    198. "郑州": [113.65, 34.76],
    199. "哈尔滨": [126.63, 45.75],
    200. "聊城": [115.97, 36.45],
    201. "芜湖": [118.38, 31.33],
    202. "唐山": [118.02, 39.63],
    203. "平顶山": [113.29, 33.75],
    204. "邢台": [114.48, 37.05],
    205. "德州": [116.29, 37.45],
    206. "济宁": [116.59, 35.38],
    207. "荆州": [112.239741, 30.335165],
    208. "宜昌": [111.3, 30.7],
    209. "义乌": [120.06, 29.32],
    210. "丽水": [119.92, 28.45],
    211. "洛阳": [112.44, 34.7],
    212. "秦皇岛": [119.57, 39.95],
    213. "株洲": [113.16, 27.83],
    214. "石家庄": [114.48, 38.03],
    215. "莱芜": [117.67, 36.19],
    216. "常德": [111.69, 29.05],
    217. "保定": [115.48, 38.85],
    218. "湘潭": [112.91, 27.87],
    219. "金华": [119.64, 29.12],
    220. "岳阳": [113.09, 29.37],
    221. "长沙": [113, 28.21],
    222. "衢州": [118.88, 28.97],
    223. "廊坊": [116.7, 39.53],
    224. "菏泽": [115.480656, 35.23375],
    225. "合肥": [117.27, 31.86],
    226. "武汉": [114.31, 30.52],
    227. "大庆": [125.03, 46.58]
    228. };
    229. var BJData = [
    230. [{
    231. name: '北京'
    232. }, {
    233. name: '上海',
    234. value: 95
    235. }],
    236. [{
    237. name: '北京'
    238. }, {
    239. name: '广州',
    240. value: 90
    241. }],
    242. [{
    243. name: '北京'
    244. }, {
    245. name: '大连',
    246. value: 80
    247. }],
    248. [{
    249. name: '北京'
    250. }, {
    251. name: '南宁',
    252. value: 70
    253. }],
    254. [{
    255. name: '北京'
    256. }, {
    257. name: '南昌',
    258. value: 60
    259. }],
    260. [{
    261. name: '北京'
    262. }, {
    263. name: '拉萨',
    264. value: 50
    265. }],
    266. [{
    267. name: '北京'
    268. }, {
    269. name: '长春',
    270. value: 40
    271. }],
    272. [{
    273. name: '北京'
    274. }, {
    275. name: '包头',
    276. value: 30
    277. }],
    278. [{
    279. name: '北京'
    280. }, {
    281. name: '重庆',
    282. value: 20
    283. }],
    284. [{
    285. name: '北京'
    286. }, {
    287. name: '常州',
    288. value: 10
    289. }]
    290. ];
    291. var SHData = [
    292. [{
    293. name: '上海'
    294. }, {
    295. name: '包头',
    296. value: 95
    297. }],
    298. [{
    299. name: '上海'
    300. }, {
    301. name: '昆明',
    302. value: 90
    303. }],
    304. [{
    305. name: '上海'
    306. }, {
    307. name: '广州',
    308. value: 80
    309. }],
    310. [{
    311. name: '上海'
    312. }, {
    313. name: '郑州',
    314. value: 70
    315. }],
    316. [{
    317. name: '上海'
    318. }, {
    319. name: '长春',
    320. value: 60
    321. }],
    322. [{
    323. name: '上海'
    324. }, {
    325. name: '重庆',
    326. value: 50
    327. }],
    328. [{
    329. name: '上海'
    330. }, {
    331. name: '长沙',
    332. value: 40
    333. }],
    334. [{
    335. name: '上海'
    336. }, {
    337. name: '北京',
    338. value: 30
    339. }],
    340. [{
    341. name: '上海'
    342. }, {
    343. name: '丹东',
    344. value: 20
    345. }],
    346. [{
    347. name: '上海'
    348. }, {
    349. name: '大连',
    350. value: 10
    351. }]
    352. ];
    353. var GZData = [
    354. [{
    355. name: '广州'
    356. }, {
    357. name: '福州',
    358. value: 95
    359. }],
    360. [{
    361. name: '广州'
    362. }, {
    363. name: '太原',
    364. value: 90
    365. }],
    366. [{
    367. name: '广州'
    368. }, {
    369. name: '长春',
    370. value: 80
    371. }],
    372. [{
    373. name: '广州'
    374. }, {
    375. name: '重庆',
    376. value: 70
    377. }],
    378. [{
    379. name: '广州'
    380. }, {
    381. name: '西安',
    382. value: 60
    383. }],
    384. [{
    385. name: '广州'
    386. }, {
    387. name: '成都',
    388. value: 50
    389. }],
    390. [{
    391. name: '广州'
    392. }, {
    393. name: '常州',
    394. value: 40
    395. }],
    396. [{
    397. name: '广州'
    398. }, {
    399. name: '北京',
    400. value: 30
    401. }],
    402. [{
    403. name: '广州'
    404. }, {
    405. name: '北海',
    406. value: 20
    407. }],
    408. [{
    409. name: '广州'
    410. }, {
    411. name: '海口',
    412. value: 10
    413. }]
    414. ];
    415. var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
    416. var convertData = function(data) {
    417. var res = [];
    418. for(var i = 0; i < data.length; i++) {
    419. var dataItem = data[i];
    420. var fromCoord = geoCoordMap[dataItem[0].name];
    421. var toCoord = geoCoordMap[dataItem[1].name];
    422. if(fromCoord && toCoord) {
    423. res.push({
    424. fromName: dataItem[0].name,
    425. toName: dataItem[1].name,
    426. coords: [fromCoord, toCoord],
    427. value: dataItem[1].value
    428. });
    429. }
    430. }
    431. return res;
    432. };
    433. var color = ['#a6c84c', '#ffa022', '#46bee9'];
    434. var series = [];
    435. [
    436. ['北京', BJData],
    437. ['上海', SHData],
    438. ['广州', GZData]
    439. ].forEach(function(item, i) {
    440. series.push({
    441. name: item[0] + ' Top10',
    442. type: 'lines',
    443. coordinateSystem: 'geo',
    444. zlevel: 1,
    445. effect: {
    446. show: true,
    447. period: 6,
    448. trailLength: 0.7,
    449. color: '#fff',
    450. symbolSize: 3
    451. },
    452. lineStyle: {
    453. normal: {
    454. color: color[i],
    455. width: 0,
    456. curveness: 0.2
    457. }
    458. },
    459. data: convertData(item[1])
    460. }, {
    461. name: item[0] + ' Top10',
    462. type: 'lines',
    463. coordinateSystem: 'geo',
    464. zlevel: 2,
    465. symbol: ['none', 'arrow'],
    466. symbolSize: 10,
    467. effect: {
    468. show: true,
    469. period: 6,
    470. trailLength: 0,
    471. symbol: planePath,
    472. symbolSize: 15
    473. },
    474. lineStyle: {
    475. normal: {
    476. color: color[i],
    477. width: 1,
    478. opacity: 0.6,
    479. curveness: 0.2
    480. }
    481. },
    482. data: convertData(item[1])
    483. }, {
    484. name: item[0] + ' Top10',
    485. type: 'effectScatter',
    486. coordinateSystem: 'geo',
    487. zlevel: 2,
    488. rippleEffect: {
    489. brushType: 'stroke'
    490. },
    491. label: {
    492. normal: {
    493. show: true,
    494. position: 'right',
    495. formatter: '{b}'
    496. }
    497. },
    498. symbolSize: function(val) {
    499. return val[2] / 8;
    500. },
    501. itemStyle: {
    502. normal: {
    503. color: color[i]
    504. }
    505. },
    506. data: item[1].map(function(dataItem) {
    507. return {
    508. name: dataItem[1].name,
    509. value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
    510. };
    511. })
    512. });
    513. });
    514. var option = {
    515. title: {
    516. text: '模拟迁徙图',
    517. subtext: '',
    518. left: 'center',
    519. textStyle: {
    520. color: '#fff'
    521. }
    522. },
    523. tooltip: {
    524. trigger: 'item',
    525. formatter: '{b}'
    526. },
    527. geo: {
    528. //map: 'china',
    529. label: {
    530. emphasis: {
    531. show: false
    532. }
    533. },
    534. itemStyle: {
    535. normal: {
    536. areaColor: '#323c48',
    537. borderColor: '#111'
    538. },
    539. emphasis: {
    540. areaColor: '#2a333d'
    541. }
    542. }
    543. },
    544. series: series
    545. };
    546. //将Echarts加到地图上
    547. var layerWork = L.overlayEcharts(option).addTo(map);
    548. script>
    549. body>
    550. html>

  • 相关阅读:
    Tomcat8 任意写文件PUT方法 (CVE-2017-12615)
    利用亚马逊 云服务器 EC2 和S3免费套餐搭建私人网盘
    初学Bootstrap
    PTA 甲级 1044 Shopping in Mars
    云原生|kubernetes 你真的学废了吗---实战k8s 一(jsonpath实战)
    AWS无服务器 应用程序开发—第十六章 CI/CD CodeBuild
    淘宝/天猫按图搜索淘宝商品(拍立淘) API 返回值说明
    312.戳气球
    基本组网步骤
    springcloud+nacos+gateway约会
  • 原文地址:https://blog.csdn.net/czj_com/article/details/134557886