addTool.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { myBridge, previewMapBridge } from './map.js'
  2. import { getMapToken, getServiceToken } from '@/service/map.js'
  3. export function invokeParams(ActionName, params) {
  4. console.log('invokeParams', ActionName, params)
  5. myBridge.bridgeContent.Invoke({
  6. ActionName: ActionName,
  7. Parameters: {
  8. ...params,
  9. },
  10. })
  11. }
  12. export function previewInvokeParams(ActionName, params) {
  13. getMapToken().then((res) => {
  14. let token = res.data.msg[0].Rows[0].token
  15. previewMapBridge.bridgeContent.Invoke({
  16. ActionName: ActionName,
  17. Parameters: {
  18. token: token,
  19. ...params,
  20. },
  21. })
  22. })
  23. }
  24. async function returnProxyUrl(url) {
  25. let arr = url.split('/')
  26. let username = ''
  27. let password = ''
  28. if (arr.indexOf('MapProxyApi') !== -1) {
  29. //不需要授权服务
  30. for (let i = 0; i < arr.length; i++) {
  31. if (arr[i] === 'getSceneServer') {
  32. username = arr[i + 1]
  33. password = arr[i + 2]
  34. const response = await getServiceToken(username, password)
  35. if (response?.data.length > 0) {
  36. arr.splice(i - 1, 4)
  37. return arr.join('/') + '/MapServiceProxy/' + response.data
  38. }
  39. }
  40. }
  41. } else {
  42. return url
  43. }
  44. }
  45. //回显各类集合体
  46. export async function geometryMeshEffect(params) {
  47. invokeParams('GeometryMeshEffect', {
  48. status: params.status,
  49. id: params.id,
  50. data: params.data,
  51. })
  52. }
  53. //回显二次绘制航线
  54. export async function showAndRedrawPath(params) {
  55. invokeParams('Draw', {
  56. type: 'polyline',
  57. hasZ: true,
  58. status: params.status,
  59. path: params.path,
  60. symbol: {
  61. type: 'line-3d',
  62. symbolLayers: [
  63. {
  64. type: 'path',
  65. profile: 'circle',
  66. material: {
  67. color: params.color ? params.color : [0, 255, 0, 0.3],
  68. },
  69. width: params.radius ? params.radius * 2 : 10,
  70. height: params.radius ? params.radius * 2 : 10,
  71. },
  72. ],
  73. },
  74. })
  75. }
  76. //查询航线网格
  77. export async function getPathCube(params) {
  78. invokeParams('GetPathCube', {
  79. id: 'pathCube',
  80. status: params.status,
  81. level: 15,
  82. paths: params.paths,
  83. radius: 5,
  84. })
  85. }
  86. //查询态势1
  87. export async function movePoint(params) {
  88. invokeParams('MovePoint', {
  89. status: params.status ? 'show' : 'hide',
  90. })
  91. }