center.map.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import {getImageUrl} from "@/utils/tools";
  2. const arrow = new Image();
  3. arrow.src = getImageUrl("home/map_select.png");
  4. const mapBg = new Image();
  5. mapBg.src = getImageUrl("home/map_bg.png");
  6. const onetow = new Image();
  7. onetow.src = getImageUrl("home/123.png");
  8. export const optionHandle = (regionCode: string,
  9. list: object[]) => {
  10. return {
  11. backgroundColor: "rgba(0,0,0,0)",
  12. tooltip: {
  13. trigger: 'item',
  14. position: function (point: any[], params: any, dom: any, rect: any, size: any) {
  15. let x = 0; // x坐标位置
  16. let y = 0; // y坐标位置
  17. // 当前鼠标位置
  18. const pointX = point[0];
  19. const pointY = point[1];
  20. // 提示框大小
  21. const boxWidth = size.contentSize[0];
  22. const boxHeight = size.contentSize[1];
  23. // boxWidth > pointX 说明鼠标左边放不下提示框
  24. if (boxWidth > pointX) {
  25. x = pointX + 10;
  26. } else { // 左边放的下
  27. x = pointX - boxWidth - 10;
  28. }
  29. // boxHeight > pointY 说明鼠标上边放不下提示框
  30. if (boxHeight > pointY) {
  31. y = 5;
  32. } else { // 上边放得下
  33. y = pointY - boxHeight;
  34. }
  35. return [x, y];
  36. },
  37. show: true,
  38. textStyle: {
  39. fontSize: 14,
  40. color: '#fff',
  41. },
  42. className: 'custom-tooltip-box',
  43. rich: {
  44. arrow: {
  45. backgroundColor: {
  46. image: getImageUrl("home/tool_tip_arrow.png")
  47. },
  48. }
  49. },
  50. formatter: function (params: any) {
  51. let tipHtml = '';
  52. tipHtml = `
  53. <div class="custom-tooltip-style">
  54. <div class='custom-tooltip-name'> <span class="custom-tooltip-arrow"></span> ${params.name}</div>
  55. <div class='custom-tooltip-style-box'>
  56. <div class="ball">
  57. <div class="ball-value">${params.data.satisfiedRate}<span>%</span></div>
  58. <div class="ball-text">满意率</div>
  59. </div>
  60. <div class="custom-tooltip-style-box-text">
  61. <div class="custom-tooltip-style-box-text-item">在办工单:<span>${params.data.handlingCount}</span> <b> 件</b></div>
  62. <div class="custom-tooltip-style-box-text-item">已办工单:<span>${params.data.filedCount}</span> <b> 件</b></div>
  63. <div class="custom-tooltip-style-box-text-item">超期工单:<span>${params.data.overTimeCount}</span> <b> 件</b></div>
  64. <div class="custom-tooltip-style-box-text-item">高频热点:<span class="last">${params.data.hotspotName}</span></div>
  65. </div>
  66. </div>
  67. </div>
  68. `
  69. return tipHtml;
  70. },
  71. },
  72. // geo: [
  73. // {
  74. // layoutCenter: ['50%', '50%'],//位置
  75. // layoutSize: '180%',//大小
  76. // show: true,
  77. // map: regionCode,
  78. // roam: false,
  79. // zoom: 0.65,
  80. // aspectScale: 1,
  81. // label: {
  82. // show: false,
  83. // },
  84. // itemStyle: {
  85. // areaColor: {
  86. // type: "linear",
  87. // x: 1200,
  88. // y: 0,
  89. // x2: 0,
  90. // y2: 0,
  91. // colorStops: [{
  92. // offset: 0,
  93. // color: "rgba(38,134,132,0.35)", // 0% 处的颜色
  94. // }, {
  95. // offset: 1,
  96. // color: "rgba(38,134,132,0.75)", // 50% 处的颜色
  97. // },],
  98. // global: true, // 缺省为 false
  99. // },
  100. // borderColor: "#c0f3fb",
  101. // borderWidth: 1,
  102. // shadowColor: "#8cd3ef",
  103. // shadowOffsetY: 10,
  104. // shadowBlur: 120,
  105. // }
  106. // },
  107. // {
  108. // type: "map",
  109. // map: regionCode,
  110. // aspectScale: 1,
  111. // zoom: 0.65,
  112. // layoutCenter: ["50%", "54%"],
  113. // layoutSize: "180%",
  114. // roam: false,
  115. // silent: true,
  116. // itemStyle: {
  117. // borderWidth: 2,
  118. // borderColor: "rgba( 38,134,132,0.8)",
  119. // shadowColor: "rgba(29, 111, 165,0.8)",
  120. // shadowOffsetY: 10,
  121. // shadowBlur: 2,
  122. // areaColor: "rgba(5,21,35,0.2)",
  123. // borderType: "dashed",
  124. // },
  125. // },
  126. // ],
  127. geo3D: [
  128. {
  129. show: false,
  130. map: regionCode, // 自定义扩展图表类型
  131. aspectScale: 1,
  132. showLegendSymbol: true,
  133. }
  134. ],
  135. series: [
  136. {
  137. type: "map3D",
  138. map: regionCode, // 自定义扩展图表类型
  139. aspectScale: 1,
  140. showLegendSymbol: true,
  141. boxDepth: 100, //地图倾斜度
  142. regionHeight: 4, //地图厚度
  143. label: {
  144. show: false,
  145. },
  146. itemStyle: {
  147. color: "rgba(32,155,252,.7)",
  148. borderColor: "#3CFFFD",
  149. borderWidth: 1,
  150. },
  151. emphasis: { // 选中的样式
  152. label: {
  153. formatter: [
  154. '{b|}',
  155. ].join('\n'),
  156. rich: {
  157. b: {
  158. backgroundColor: {
  159. image: arrow,
  160. },
  161. height: 60
  162. },
  163. }
  164. },
  165. itemStyle: {
  166. color: "rgba(255,255,255,0.3)",
  167. borderColor: "#fff",
  168. borderWidth: 2,
  169. }
  170. },
  171. layoutCenter: ["50%", "50%"],
  172. layoutSize: "180%",
  173. data: list,
  174. select: {
  175. disabled: true,
  176. },
  177. shading: 'realistic',
  178. // 真实感材质相关配置 shading: 'realistic'时有效
  179. realisticMaterial: {
  180. detailTexture: '#fff', // 纹理贴图
  181. textureTiling: 1, // 纹理平铺,1是拉伸,数字表示纹理平铺次数
  182. roughness: 0, // 材质粗糙度,0完全光滑,1完全粗糙
  183. metalness: 0, // 0材质是非金属 ,1金属
  184. roughnessAdjust: 0
  185. },
  186. viewControl: {
  187. distance: 110, // 地图视角 控制初始大小
  188. rotateSensitivity: 1, // 旋转
  189. zoomSensitivity: 1, // 缩放
  190. },
  191. instancing: true,
  192. },
  193. ],
  194. };
  195. }