components_basic_vue.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n='resources.title_componentsBasic_Vue'></title>
  9. <script type="text/javascript" include="vue" src="../js/include-web.js"></script>
  10. <script include="echarts,iclient-mapboxgl-vue,mapbox-gl-enhance" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  11. <style>
  12. body {
  13. margin: 0;
  14. overflow: hidden;
  15. background: #fff;
  16. width: 100%;
  17. height: 100%;
  18. position: absolute;
  19. top: 0;
  20. }
  21. #main {
  22. margin: 0 auto;
  23. width: 100%;
  24. height: 100%;
  25. }
  26. .box-card {
  27. width: 280px;
  28. position: absolute;
  29. top: 10px;
  30. left: 10px;
  31. z-index: 1000;
  32. overflow: hidden;
  33. }
  34. .sm-progress-wrap {
  35. height: 100px;
  36. }
  37. .sm-progress-wrap, .sm-component-liquidFill {
  38. width: 110px;
  39. height: 110px;
  40. display: inline-block;
  41. vertical-align: middle;
  42. }
  43. .sm-component-indicator {
  44. padding-left: 0px;
  45. }
  46. .sm-component-indicator .sm-component-indicator__head{
  47. padding-left: 0px;
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <div id="main">
  53. <sm-web-map server-url="https://iportal.supermap.io/iportal" map-id="801571284" ref="map" @load.once='load'></sm-web-map>
  54. <sm-card class="box-card">
  55. <!-- 图标组件 -->
  56. <sm-icon icon-class="marker-layer" size="18px" text-color='rgb(63, 177, 227)' :style="{float: 'left'}">
  57. </sm-icon>
  58. <!-- 文本组件 -->
  59. <sm-text title="点击图上点切换显示机场数据" :font-style='{ fontSize: "14px"}' text-color="#333">
  60. </sm-text>
  61. <sm-text title="机场" :font-style='{ fontSize: "12px",fontWeight: "bolder",display: "block"}' text-color="rgb(51,51,51)">
  62. </sm-text>
  63. <sm-text :title="name" :font-style='{ fontSize: "18px", fontWeight: "700" ,display: "block"}' text-color="#333">
  64. </sm-text>
  65. <!-- 指标组件 -->
  66. <sm-indicator title="2017旅客吞吐量" unit="人次" :num="passengerNumber" text-color="#333"></sm-indicator>
  67. <sm-indicator title="2017货邮吞吐量" unit="吨" :num="goodsNumber" text-color="#333"></sm-indicator>
  68. <sm-text title="同比增速" :font-style='{ fontSize: "12px",fontWeight: "bolder",display: "block"}' text-color="rgb(51,51,51)"></sm-text>
  69. <!-- 水球组件 -->
  70. <sm-liquid-fill :value="speedIncreaseValue" :wave-count="3" :wave-animation="true">
  71. </sm-liquid-fill>
  72. <!-- 进度条组件 -->
  73. <div class="sm-progress-wrap">
  74. <sm-progress type="circle" :percent="speedIncrease">
  75. </sm-progress>
  76. </div>
  77. <!-- 时间组件 -->
  78. <sm-time-text :font-style='{ fontSize: "12px"}' text-color="#333" time-type="date+second" style="float:right">
  79. </sm-time-text>
  80. </sm-card>
  81. </div>
  82. <script>
  83. new Vue({
  84. el: '#main',
  85. data() {
  86. return {
  87. name: "北京/首都",
  88. passengerNumber: 95786296,
  89. goodsNumber: 94393454,
  90. speedIncrease: 5
  91. }
  92. },
  93. computed: {
  94. speedIncreaseValue() {
  95. return this.speedIncrease / 100.0;
  96. }
  97. },
  98. methods: {
  99. load(obj) {
  100. var vm = this;
  101. map = obj.map;
  102. map.on('click', function(e) {
  103. var bbox = [[e.point.x - 2, e.point.y - 2], [e.point.x + 2, e.point.y + 2]];
  104. var features = map.queryRenderedFeatures(bbox);
  105. if (features.length > 0) {
  106. var properties = features[0].properties;
  107. vm.name = properties['机场'];
  108. vm.passengerNumber = properties['2017旅客吞吐量(人次)'] || 0;
  109. vm.goodsNumber = properties['2017货邮吞吐量(吨)'] || 0;
  110. vm.speedIncrease = properties['同比增速%'] || 0;
  111. }
  112. });
  113. }
  114. }
  115. })
  116. </script>
  117. </body>
  118. </html>