addTool.js 2.9 KB

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