map-province.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <script src="lib/esl.js"></script>
  7. <script src="lib/config.js"></script>
  8. <script src="lib/jquery.min.js"></script>
  9. <script src="lib/facePrint.js"></script>
  10. <script src="lib/testHelper.js"></script>
  11. <link rel="stylesheet" href="lib/reset.css">
  12. </head>
  13. <body>
  14. <style>
  15. .test-title {
  16. background: #146402;
  17. color: #fff;
  18. }
  19. </style>
  20. <div id="main0"></div>
  21. <script>
  22. var chart;
  23. require([
  24. 'echarts'/*, 'map/js/china' */
  25. ], function (echarts) {
  26. var provinces = ['shanghai', 'hebei','shanxi','neimenggu','liaoning','jilin','heilongjiang','jiangsu','zhejiang','anhui','fujian','jiangxi','shandong','henan','hubei','hunan','guangdong','guangxi','hainan','sichuan','guizhou','yunnan','xizang','shanxi1','gansu','qinghai','ningxia','xinjiang', 'beijing', 'tianjin', 'chongqing', 'xianggang', 'aomen'];
  27. var provincesText = ['上海', '河北', '山西', '内蒙古', '辽宁', '吉林','黑龙江', '江苏', '浙江', '安徽', '福建', '江西', '山东','河南', '湖北', '湖南', '广东', '广西', '海南', '四川', '贵州', '云南', '西藏', '陕西', '甘肃', '青海', '宁夏', '新疆', '北京', '天津', '重庆', '香港', '澳门'];
  28. function showProvince() {
  29. var name = provinces[currentIdx];
  30. // myChart.showLoading();
  31. $.get('../map/json/province/' + name + '.json', function (geoJson) {
  32. // myChart.hideLoading();
  33. echarts.registerMap(name, geoJson);
  34. chart.setOption({
  35. backgroundColor: '#404a59',
  36. title: {
  37. text: provincesText[currentIdx],
  38. left: 'center',
  39. textStyle: {
  40. color: '#fff'
  41. }
  42. },
  43. series: [
  44. {
  45. type: 'map',
  46. mapType: name,
  47. label: {
  48. emphasis: {
  49. textStyle: {
  50. color: '#fff'
  51. }
  52. }
  53. },
  54. itemStyle: {
  55. normal: {
  56. borderColor: '#389BB7',
  57. areaColor: '#fff',
  58. },
  59. emphasis: {
  60. areaColor: '#389BB7',
  61. borderWidth: 0
  62. }
  63. },
  64. animation: false
  65. // animationDurationUpdate: 1000,
  66. // animationEasingUpdate: 'quinticInOut'
  67. }
  68. ]
  69. });
  70. });
  71. }
  72. var currentIdx = 0;
  73. var option = {
  74. graphic: [{
  75. id: 'left-btn',
  76. type: 'circle',
  77. shape: { r: 20 },
  78. style: {
  79. text: '<',
  80. fill: '#eee'
  81. },
  82. left: 10,
  83. top: 'middle',
  84. onclick: function () {
  85. currentIdx -= 1;
  86. if (currentIdx < 0) {
  87. currentIdx += provinces.length;
  88. }
  89. showProvince();
  90. }
  91. }, {
  92. id: 'right-btn',
  93. type: 'circle',
  94. shape: { r: 20 },
  95. style: {
  96. text: '>',
  97. fill: '#eee'
  98. },
  99. top: 'middle',
  100. right: 10,
  101. onclick: function () {
  102. currentIdx = (currentIdx + 1) % provinces.length;
  103. showProvince();
  104. }
  105. }],
  106. series: []
  107. };
  108. chart = testHelper.create(echarts, 'main0', {
  109. option: option
  110. });
  111. showProvince();
  112. });
  113. </script>
  114. </body>
  115. </html>