AddLayer.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. import { myBridge } from './map';
  2. import { handleRegionLayerWithOutLabel } from '@/utils/map/baseMethod.js';
  3. export function invokeParams(ActionName, params) {
  4. if (import.meta.env.VITE_OPEN_UE === 'open') return;
  5. console.log(ActionName, params);
  6. myBridge.bridgeContent.Invoke({
  7. ActionName: ActionName,
  8. Parameters: {
  9. ...params,
  10. },
  11. });
  12. }
  13. export function changeViewType(ViewType) {
  14. let d = ViewType || '2D';
  15. invokeParams('ChangeViewType', {
  16. type: d,
  17. });
  18. // if (d === '2D') {
  19. // addPointSearch();
  20. // }
  21. addPointSearch();
  22. }
  23. export function setCamera(params) {
  24. invokeParams(
  25. 'SetCamera',
  26. params,
  27. // ||{
  28. // position: {
  29. // spatialReference: {
  30. // wkid: 102100
  31. // },
  32. // x: 2598.4722313159023,
  33. // y: -927.2818635861828,
  34. // z: 73.09940296852281
  35. // },
  36. // heading: 266.84124349722583,
  37. // tilt: 70.95259138002815
  38. // }
  39. );
  40. }
  41. export function addMyGraph(params) {
  42. invokeParams('AddGraphic', params);
  43. }
  44. export function addMyGraphByData_TJ(params, bol = true) {
  45. // handleRegionLayerWithOutLabel(bol);
  46. invokeParams('AddGraphicByData_TJ', {
  47. ...params,
  48. status: bol,
  49. });
  50. }
  51. export function addPointMap(pointsArr) {
  52. invokeParams('AddGraphic', {
  53. is_clear: false,
  54. is_goto: true,
  55. is_edit: false,
  56. is_temp: true,
  57. type: 'points',
  58. data: pointsArr,
  59. attributes: [],
  60. symbol: {
  61. type: 'simple-marker',
  62. color: '#fff',
  63. size: 14,
  64. },
  65. });
  66. }
  67. export function addPointMapSingle(pointsArr, is_goto) {
  68. invokeParams('AddGraphic', {
  69. is_clear: true,
  70. is_goto: is_goto,
  71. type: 'point',
  72. data: pointsArr,
  73. attributes: [],
  74. symbol: {
  75. type: 'picture-marker',
  76. url: 'images/marker.png',
  77. width: '50px',
  78. height: '50px',
  79. },
  80. // layerID: 'tempLayer'
  81. });
  82. }
  83. export function gldbMap(isShow, leadingLayers, trailingLayers) {
  84. console.log('dasdasdassad', isShow, leadingLayers, trailingLayers);
  85. invokeParams('ChangeShowSwipe', {
  86. status: isShow ? 'show' : 'hide',
  87. leadingLayers: trailingLayers,
  88. trailingLayers: leadingLayers,
  89. direction: 'horizontal',
  90. });
  91. }
  92. export function emptyAllLayers() {
  93. invokeParams('ClearMapLayers', {});
  94. }
  95. export function SetExtent(params) {
  96. invokeParams('SetExtent', {
  97. ...params,
  98. });
  99. }
  100. export function addPolygons(geos, is_clear, layerID, symbol) {
  101. invokeParams('AddGraphic', {
  102. type: 'polygons',
  103. is_edit: false,
  104. is_temp: true,
  105. is_clear: is_clear,
  106. is_goto: false,
  107. layerID: layerID,
  108. data: geos,
  109. symbol: symbol || {
  110. type: 'simple-fill',
  111. color: [239, 132, 9, 0.7],
  112. outline: {
  113. color: [255, 255, 255, 1],
  114. width: 1,
  115. },
  116. },
  117. });
  118. }
  119. export function layerControl(layerID, visible, opacity = 1, where = '1=1') {
  120. invokeParams('LayerControl', {
  121. title: layerID,
  122. visible: visible,
  123. opacity: opacity,
  124. islegend: false,
  125. where: where,
  126. });
  127. }
  128. export function clearTownAndVillageMap() {
  129. clearMap();
  130. // layerControl('temp',false)
  131. }
  132. export function clearMap(params = {}) {
  133. invokeParams('ClearMap', {
  134. is_draw: true,
  135. is_search: true,
  136. is_position: true,
  137. ...params,
  138. });
  139. }
  140. export function addPointMarker(pointsArr, href, size) {
  141. invokeParams('AddGraphic', {
  142. is_clear: false,
  143. is_goto: false,
  144. type: 'point',
  145. data: pointsArr,
  146. attributes: [],
  147. symbol: {
  148. type: 'picture-marker',
  149. url: href,
  150. width: size,
  151. height: size,
  152. },
  153. is_temp: true,
  154. layerID: 'zhgc_temp',
  155. });
  156. }
  157. export function addPointMarkerImage(
  158. layerID,
  159. pointsArr = [],
  160. href = '',
  161. size = 20,
  162. is_clear = false,
  163. attributes = {},
  164. ) {
  165. invokeParams('AddGraphic', {
  166. is_clear: is_clear,
  167. is_goto: false,
  168. type: 'point',
  169. data: pointsArr,
  170. attributes: attributes,
  171. symbol: {
  172. type: 'picture-marker',
  173. url: href,
  174. width: size,
  175. height: size,
  176. },
  177. is_temp: true,
  178. layerID: layerID,
  179. });
  180. }
  181. export function addMultiPointsMarkerImage(params, href = '', size = 20) {
  182. invokeParams('AddGraphic', {
  183. is_clear: false,
  184. is_goto: false,
  185. type: 'points',
  186. data: [],
  187. attributes: null,
  188. symbol: {
  189. type: 'picture-marker',
  190. url: href,
  191. width: size,
  192. height: size,
  193. },
  194. is_temp: true,
  195. layerID: 'addImagePoint',
  196. ...params,
  197. });
  198. }
  199. export function layerDef(title, sql, type = 'feature') {
  200. invokeParams('LayerDefinitions', {
  201. title,
  202. sql,
  203. type,
  204. });
  205. }
  206. export function positionByPoint(x, y, is_goto = false, is_draw = true, size = 50, scale = 1000) {
  207. invokeParams('Position', {
  208. type: 'point',
  209. position: [
  210. {
  211. id: '4065',
  212. mapx: x,
  213. mapy: y,
  214. },
  215. ],
  216. is_draw: is_draw,
  217. is_clear: true,
  218. is_goto,
  219. size: size,
  220. scale: scale,
  221. heading: 360,
  222. tilt: 0,
  223. easing: 'ease',
  224. duration: 7000,
  225. });
  226. }
  227. export function resultGoto(layerID, id, scale = 2000) {
  228. invokeParams('ResultGoto', {
  229. layerID,
  230. id,
  231. scale,
  232. });
  233. }
  234. export function addPointSearch(status = true) {
  235. invokeParams('MapClickAll', {
  236. status,
  237. is_draw: false,
  238. is_code: false,
  239. });
  240. }
  241. export function layerControlNew(layerID, visible, opacity = 1, where) {
  242. console.log('我的opacity', opacity);
  243. invokeParams('LayerControl', {
  244. title: layerID,
  245. visible: visible,
  246. opacity: opacity,
  247. islegend: false,
  248. where: where,
  249. });
  250. }
  251. export function LayerStatistics(title, field) {
  252. invokeParams('LayerStatistics', {
  253. title: title,
  254. field: field,
  255. type: 'count',
  256. });
  257. }
  258. export function toolUploadSheepFileMap(shapeType, shapeData) {
  259. invokeParams('LoadSHPFile', {
  260. shapeType: shapeType,
  261. shapeData: shapeData,
  262. is_goto: true,
  263. });
  264. }
  265. export function setScale(scale) {
  266. invokeParams('SetScale', {
  267. scale: scale,
  268. });
  269. }
  270. export function addMapLayer(params) {
  271. invokeParams('AddLayer', {
  272. // scale: scale,
  273. // id: id,
  274. // title: id,
  275. // visible: visible,
  276. // opacity: 1,
  277. // url: url,
  278. // type: type,
  279. // is_goto: false,
  280. // is_legend: false,
  281. ...params,
  282. });
  283. }
  284. export function LayerQuery(params) {
  285. invokeParams('LayerQuery', {
  286. // geometry: {
  287. // type: 'polygon',
  288. // rings: [
  289. // [-829.6023411144151, 2768.940532081816],
  290. // [6106.907801275349, 2953.548570047385],
  291. // [5463.077127821732, -2051.867891674905],
  292. // [-570.7552398098007, -1867.805762451227],
  293. // [-829.6023411144151, 2768.940532081816],
  294. // ],
  295. // spatialReference: {
  296. // wkid: 102100,
  297. // },
  298. // },
  299. // spatialRelationship: 'disjoint',
  300. outFields: ['*'],
  301. returnGeometry: true,
  302. is_draw: true,
  303. is_goto: false,
  304. is_clear: false,
  305. symbol: {
  306. type: 'simple-fill',
  307. // style: 'circle',
  308. color: [255, 0, 0, 0],
  309. // size: 10,
  310. outline: {
  311. color: [255, 191, 0],
  312. // color: [1, 255, 1],
  313. width: 3,
  314. },
  315. },
  316. ...params,
  317. });
  318. }
  319. export function ClearMap(is_draw = true, is_search = true, is_position = true) {
  320. invokeParams('ClearMap', {
  321. is_draw: true,
  322. is_search: true,
  323. is_position: true,
  324. is_temp: true,
  325. });
  326. }
  327. export function ChangeBaseMap(type) {
  328. invokeParams('ChangeBaseMap', {
  329. title: type,
  330. opacity: 1,
  331. });
  332. }
  333. export function clearTongjiLayer() {
  334. invokeParams('RemoveMapLayers', {
  335. id: 'tongjiLayer',
  336. type: '',
  337. });
  338. }
  339. export function removeMapLayers(title) {
  340. invokeParams('RemoveMapLayers', {
  341. id: title,
  342. type: '',
  343. });
  344. }
  345. export function calculation() {
  346. invokeParams('Calculation', {
  347. type: 'polyline',
  348. is_show: false,
  349. is_dtzz: false,
  350. });
  351. }
  352. export function layerShade(title, where) {
  353. invokeParams('LayerShade', {
  354. "title": title,
  355. "where": where,
  356. "effect": "opacity(0.9) blur(5px)"
  357. });
  358. }
  359. export function drawCircle(point, radius, layerId, returnParams = false) {
  360. invokeParams('AddGraphic', {
  361. type: 'circle',
  362. is_edit: false,
  363. is_temp: true,
  364. is_clear: true,
  365. is_goto: false,
  366. is_return: returnParams,
  367. data: point,
  368. attributes: [],
  369. symbol: {
  370. type: 'simple-fill',
  371. color: [50, 205, 205, 0.5],
  372. outline: {
  373. width: 2,
  374. },
  375. },
  376. radius: radius,
  377. unit: 'meters',
  378. layerID: layerId,
  379. });
  380. }
  381. export function changeMapType(mapType) {
  382. invokeParams('ChangeMapType', {
  383. "mapType": mapType,
  384. "viewType": "2D"
  385. });
  386. }
  387. export function createMap() {
  388. invokeParams('CreateMap', {
  389. });
  390. }
  391. export function resultHighlight(layerId, objectId) {
  392. invokeParams('ResultHighlight', {
  393. "layerId": layerId,
  394. "objectId": objectId
  395. });
  396. }
  397. export function setHeatmap(show, data) {
  398. invokeParams('SetHeatmap', {
  399. "show": show,
  400. "data": data,
  401. "heatmapRenderer": {},
  402. "simpleRenderer": {}
  403. });
  404. }
  405. export function setDistrictResult(show, data) {
  406. invokeParams('SetDistrictResult', {
  407. "show": show,
  408. "data": data,
  409. // "renderer": {}
  410. });
  411. }
  412. export function draw(type) {
  413. invokeParams('Draw', {
  414. "type": type
  415. });
  416. }
  417. export function drawHistory(bol, data) {
  418. invokeParams('DrawHistory', {
  419. "show": bol,
  420. "data": data
  421. });
  422. }
  423. export function playHistory(status) {
  424. invokeParams('PlayHistory', {
  425. "status": status
  426. });
  427. }