map.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="viewmap">
  3. <chart
  4. :options="map"
  5. :init-options="initOptions"
  6. ref="map"
  7. autoresize
  8. className="chart"
  9. />
  10. <!-- <img src="../assets/images/map.png"/>
  11. <svg class="lines" width="895" height="632">
  12. <line
  13. v-for="(item, index) in links"
  14. :key="index"
  15. :x2="item[0]"
  16. :y2="item[1]"
  17. x1="630"
  18. y1="288"
  19. stroke="rgba(45, 199, 170, 0.5)"
  20. stroke-width="2"
  21. />
  22. </svg>
  23. <div class="icon">
  24. <div class="dot"></div>
  25. <div class="pluse"></div>
  26. <div class="pluse-big"></div>
  27. </div> -->
  28. </div>
  29. </template>
  30. <script>
  31. import ECharts from './ECharts.vue'
  32. import 'echarts/lib/component/geo'
  33. import 'echarts/lib/chart/map'
  34. import 'echarts/map/js/china'
  35. import china from './china.json'
  36. import mapOption from './map-data'
  37. // ECharts.registerMap('china', china)
  38. const links = [
  39. [185, 275],
  40. [485, 350],
  41. [770, 235],
  42. [785, 155],
  43. [725, 270],
  44. [522, 573],
  45. [676, 498],
  46. [335, 375],
  47. [432, 470],
  48. [405, 575],
  49. [612, 510],
  50. [185, 440],
  51. [497, 528],
  52. ]
  53. export default {
  54. name: 'viewmap',
  55. components: {
  56. chart: ECharts
  57. },
  58. data() {
  59. return {
  60. activeName: '北京',
  61. links,
  62. start: [190, 440],
  63. initOptions: {
  64. renderer: 'canvas'
  65. },
  66. }
  67. },
  68. computed: {
  69. map() {
  70. const { map } = this.$refs
  71. const option = mapOption(this.activeName)
  72. if (map && map.chart) {
  73. map.chart.clear()
  74. map.chart.setOption(option)
  75. }
  76. return option
  77. }
  78. },
  79. mounted() {
  80. const { map } = this.$refs
  81. if (map && map.chart) {
  82. map.chart.on('mousemove', evt => {
  83. if (evt.name && evt.name !== '南海诸岛') {
  84. this.activeName = evt.name
  85. }
  86. })
  87. }
  88. },
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. .viewmap{
  93. width: 1100px;
  94. margin: auto;
  95. margin-top: -120px;
  96. position: relative;
  97. .chart{
  98. width: 100%;
  99. height: 900px;
  100. }
  101. img{
  102. max-width: 100%;
  103. }
  104. .lines{
  105. position: absolute;
  106. top: 0;
  107. left: 0;
  108. width: 100%;
  109. height: 100%;
  110. }
  111. .line{
  112. position: absolute;
  113. }
  114. .icon{
  115. position: absolute;
  116. z-index: 999;
  117. width: 26px;
  118. height: 26px;
  119. top: 275px;
  120. left: 615px;
  121. .dot{
  122. position: absolute;
  123. width: 8px;
  124. height: 8px;
  125. left: 9px;
  126. top: 9px;
  127. border-radius: 50%;
  128. background: rgba(45, 199, 170, 0.7);
  129. animation: shink 1.4s ease-out infinite;
  130. }
  131. .pluse{
  132. position: absolute;
  133. width: 26px;
  134. height: 26px;
  135. border: 2px solid #09f;
  136. border-radius: 50%;
  137. z-index: 100;
  138. opacity: 0;
  139. background: rgba(45, 199, 170, 0.6);
  140. animation: warn 1.4s ease-out;
  141. animation-iteration-count: infinite;
  142. box-shadow: 1px 1px 30px rgba(45, 199, 170, 1);
  143. }
  144. .pluse-big{
  145. position: absolute;
  146. width: 20px;
  147. height: 20px;
  148. border: 2px solid #09f;
  149. border-radius: 50%;
  150. z-index: 100;
  151. opacity: 0;
  152. background: rgba(45, 199, 170, 0.6);
  153. animation: warn1 1.4s ease-out;
  154. animation-iteration-count: infinite;
  155. box-shadow: 1px 1px 30px #EF2D02;
  156. }
  157. }
  158. @keyframes warn{
  159. 0% {
  160. -moz-transform: scale(0);
  161. -webkit-transform: scale(0);
  162. transform: scale(0);
  163. opacity: 1;
  164. }
  165. 100% {
  166. -moz-transform: scale(1);
  167. -webkit-transform: scale(1);
  168. transform: scale(1);
  169. opacity: 0;
  170. }
  171. }
  172. @-webkit-keyframes warn{
  173. 0% {
  174. -moz-transform: scale(0);
  175. -webkit-transform: scale(0);
  176. transform: scale(0);
  177. opacity: 1;
  178. }
  179. 100% {
  180. -moz-transform: scale(1);
  181. -webkit-transform: scale(1);
  182. transform: scale(1);
  183. opacity: 0;
  184. }
  185. }
  186. @keyframes shink{
  187. 0% {
  188. opacity: 0;
  189. transform: scale(0.5);
  190. }
  191. 100% {
  192. opacity: 1;
  193. transform: scale(1);
  194. }
  195. }
  196. }
  197. line {
  198. stroke-dashoffset: 0;
  199. animation: dash 4s;
  200. }
  201. @keyframes dash {
  202. 0% {
  203. stroke-dashoffset: 0;
  204. }
  205. 1% {
  206. stroke-dasharray: 800;
  207. stroke-dashoffset: 800;
  208. }
  209. 100% {
  210. stroke-dashoffset: 0;
  211. }
  212. }
  213. </style>