point.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import Bus from "@/utils/bus";
  2. /**
  3. * 添加点
  4. * @param data
  5. * @param type 样式
  6. */
  7. export function addPoint(data: any, type = "custom") {
  8. let descriptor = {
  9. "command": "AddCustomPOI",
  10. "data": {
  11. "obj": {
  12. "coord_type": 0,
  13. "cad_mapkey": "",
  14. "coord_z": 0,
  15. "coord_z_type": 0,
  16. "always_show_label": false,
  17. "show_label_range": "0,6000",
  18. "sort_order": false,
  19. "animation_type": "bounce",
  20. "duration_time": 0.7,
  21. "state": "state_1"
  22. },
  23. "subobj": data.map((p: any) => createPointObj(p, type))
  24. }
  25. };
  26. Bus.emit('emitUIInteraction', descriptor)
  27. console.log("-- 添加点", JSON.stringify(descriptor));
  28. }
  29. /**
  30. * 删除点
  31. * @param type id,type,all
  32. * @param data
  33. */
  34. export function deletePoint(type: string, data: any) {
  35. let descriptor = {
  36. "command": "DelCustomPOI",
  37. "data": {}
  38. };
  39. if (type === "id") {
  40. descriptor.data = {
  41. "id": data,
  42. "all": "false"
  43. }
  44. } else if (type === 'type') {
  45. descriptor.data = {
  46. "id": data,
  47. "all": "false"
  48. }
  49. } else if (type === "all") {
  50. descriptor.data = {
  51. "all": "true"
  52. }
  53. }
  54. Bus.emit('emitUIInteraction', descriptor)
  55. console.log("-- 删除点", JSON.stringify(descriptor));
  56. }
  57. function createPointObj(point: any, type = "custom") {
  58. switch (type) {
  59. case 'video':
  60. return {
  61. "id": point.id ? point.id : point.name,
  62. "type": point.type,
  63. "coord": `${point.x}, ${point.y}`,
  64. "label": {
  65. "bg_size": "70,20",
  66. "bg_offset": "-35,-60",
  67. "content": [
  68. {
  69. "text": [
  70. point.name,
  71. "fff",
  72. "12"
  73. ],
  74. "text_offset": "0,0",
  75. "text_boxwidth": 10,
  76. "text_centered": true,
  77. "scroll_speed": 1
  78. }
  79. ]
  80. },
  81. "marker": {
  82. "size": "40,40",
  83. "images": [
  84. {
  85. "define_state": "state_1",
  86. "normal_url": "TYPE3Blue.png",
  87. "activate_url": "TYPE3Blue.png"
  88. }
  89. ]
  90. }
  91. }
  92. case 'hydrologicStation':
  93. return {
  94. "id": point.name,
  95. "type": point.type,
  96. "coord": `${point.x}, ${point.y}`,
  97. "label": {
  98. "bg_size": "120,50",
  99. "bg_offset": "-60,-70",
  100. "content": [
  101. {
  102. "text": [
  103. point.name,
  104. "fff",
  105. "12"
  106. ],
  107. "text_offset": "0,0",
  108. "text_boxwidth": 10,
  109. "text_centered": true,
  110. "scroll_speed": 1
  111. }
  112. ]
  113. },
  114. "marker": {
  115. "size": "20,20",
  116. "images": [
  117. {
  118. "define_state": "state_1",
  119. "normal_url": "TYPE4Blue.png",
  120. "activate_url": "TYPE4Blue.png"
  121. }
  122. ]
  123. }
  124. }
  125. case 'custom':
  126. default:
  127. return {
  128. "id": point.name,
  129. "type": point.type,
  130. "coord": `${point.x}, ${point.y}`,
  131. "label": {
  132. "bg_size": "60,20",
  133. "bg_offset": "-25,-70",
  134. "content": [
  135. {
  136. "text": [
  137. point.name,
  138. "fff",
  139. "12"
  140. ],
  141. "text_offset": "0,0",
  142. "text_boxwidth": 10,
  143. "text_centered": true,
  144. "scroll_speed": 1
  145. }
  146. ]
  147. },
  148. "marker": {
  149. "size": "100,100",
  150. "images": [
  151. {
  152. "define_state": "state_1",
  153. "normal_url": "TYPE1Blue.png",
  154. "activate_url": "TYPE1Blue.png"
  155. }
  156. ]
  157. }
  158. }
  159. }
  160. }