mapOperation.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. import { myBridge } from './map';
  2. import test2 from './test2.json';
  3. export function invokeParams(ActionName, params) {
  4. console.log(ActionName, params);
  5. myBridge.bridgeContent.Invoke({
  6. ActionName: ActionName,
  7. Parameters: {
  8. ...params
  9. }
  10. });
  11. }
  12. export function invokeParamsMap(mapId, ActionName, params) {
  13. console.log(ActionName, params);
  14. let map = mapId ? 'splitBridgeContent' + mapId : 'bridgeContent';
  15. myBridge[map].Invoke({
  16. ActionName: ActionName,
  17. Parameters: {
  18. ...params
  19. }
  20. });
  21. }
  22. export function addJuHePointSearchFun(mapId) {
  23. invokeParamsMap(mapId, 'MapClickAll', {
  24. status: true,
  25. is_draw: true,
  26. is_code: false
  27. });
  28. }
  29. export function addJuHePointSearch() {
  30. invokeParams('MapClickAll', {
  31. status: true,
  32. is_draw: true,
  33. is_code: false
  34. });
  35. }
  36. /**
  37. * 打点
  38. * @param {*} name 打点方法name,关闭时可做标识用
  39. * @param {*} param.imageUrl 打点图标,需要使用new URL(``, import.meta.url).href转为链接
  40. * @param {*} param.url 数据源接口地址
  41. */
  42. export function addJuHePoint(name, data, params) {
  43. invokeParams('ShowData', {
  44. name: name,
  45. data: {
  46. content: data,
  47. parsegeometry: 'function(item){return {x:Number(item.x),y:Number(item.y)}}'
  48. },
  49. legendVisible: false,
  50. popupEnabled: false,
  51. renderer: {
  52. type: 'simple',
  53. label: params?.label || '',
  54. visualVariables: [],
  55. symbol: {
  56. type: 'simple-marker',
  57. size: 15,
  58. color: params?.color || 'rgba(0,128,255,0.4)',
  59. outline: {
  60. width: 0.5,
  61. color: params?.borderColor || '#0080FF'
  62. }
  63. // type: 'picture-marker',
  64. // url: new URL(`@/assets/image/mapTools/2.png`, import.meta.url).href,
  65. // width: '64px',
  66. // height: '64px'
  67. }
  68. },
  69. featureReduction: {
  70. type: 'cluster',
  71. clusterRadius: '150px',
  72. popupTemplate: {
  73. title: 'Cluster summary',
  74. content: 'This cluster represents {cluster_count} earthquakes.',
  75. fieldInfos: [
  76. {
  77. fieldName: 'cluster_count',
  78. format: {
  79. places: 0,
  80. digitSeparator: true
  81. }
  82. }
  83. ]
  84. },
  85. clusterMinSize: '20px',
  86. clusterMaxSize: '50px',
  87. labelingInfo: [
  88. {
  89. deconflictionStrategy: 'none',
  90. labelExpressionInfo: {
  91. expression: "Text($feature.cluster_count, '#,###')"
  92. },
  93. symbol: {
  94. type: 'text',
  95. color: '#ffffff',
  96. font: {
  97. weight: 'bold',
  98. // family: 'Noto Sans',
  99. size: '16px'
  100. }
  101. },
  102. labelPlacement: 'center-center'
  103. }
  104. ]
  105. }
  106. });
  107. }
  108. // 简单打点
  109. export function addPoint(data, name, params) {
  110. invokeParams('ShowData', {
  111. name: name,
  112. data: {
  113. content: data,
  114. parsegeometry: 'function(item){return {x:Number(item.x),y:Number(item.y)}}'
  115. },
  116. legendVisible: false,
  117. popupEnabled: false,
  118. renderer: {
  119. type: 'simple',
  120. label: '测试车辆',
  121. visualVariables: [],
  122. symbol: {
  123. type: 'simple-marker',
  124. size: 10,
  125. color: params?.color || 'rgba(0,128,255,0.4)',
  126. outline: {
  127. width: 0.5,
  128. color: params?.barderColor || 'rgba(0,128,255,0.8)'
  129. }
  130. }
  131. }
  132. });
  133. }
  134. // 简单打点
  135. export function replacePoint(data, name) {
  136. invokeParams('ShowData', {
  137. name: name,
  138. mode: 'replace',
  139. data: {
  140. content: data,
  141. parsegeometry: 'function(item){return {x:Number(item.x),y:Number(item.y)}}'
  142. },
  143. legendVisible: false,
  144. popupEnabled: false,
  145. renderer: {
  146. type: 'simple',
  147. label: '测试车辆',
  148. visualVariables: [],
  149. symbol: {
  150. type: 'simple-marker',
  151. size: 10,
  152. color: 'rgba(0,128,255,0.4)',
  153. outline: {
  154. width: 0.5,
  155. color: '#0080FF'
  156. }
  157. }
  158. }
  159. });
  160. }
  161. /**
  162. * 带图标打点
  163. * @param {*} name 打点方法name,关闭时可做标识用
  164. * @param {*} param.imageUrl 打点图标,需要使用new URL(``, import.meta.url).href转为链接
  165. * @param {*} param.url 数据源接口地址
  166. */
  167. export function addImagePoint(name, data, params) {
  168. invokeParams('ShowData', {
  169. name: name,
  170. data: {
  171. content: data,
  172. parsegeometry: 'function(item){return {x:Number(item.x),y:Number(item.y)}}'
  173. },
  174. legendVisible: false,
  175. popupEnabled: false,
  176. renderer: {
  177. type: 'simple',
  178. label: '测试车辆',
  179. visualVariables: [],
  180. symbol: {
  181. type: 'picture-marker',
  182. url: params.imageUrl,
  183. width: '36px',
  184. height: '36px'
  185. }
  186. },
  187. labels: [
  188. {
  189. fields: ['#.size'],
  190. color: [255, 255, 255, 1],
  191. size: 15,
  192. labelPlacement: 'center-center'
  193. }
  194. ]
  195. });
  196. }
  197. //点线面隐藏
  198. export function closePoint(name) {
  199. invokeParams('ShowData', {
  200. name: name,
  201. mode: 'visible',
  202. visible: false
  203. });
  204. }
  205. //轨迹
  206. export function addTrajectory(data, id) {
  207. invokeParams('ShowData', {
  208. name: 'car_layer' + id,
  209. type: 'track',
  210. isLocate: true,
  211. data: {
  212. isComputingRote: false,
  213. content: data,
  214. parsegeometry: 'function(item){return {x:Number(item.x),y:Number(item.y)}}'
  215. },
  216. legendVisible: true,
  217. popupEnabled: true,
  218. renderer: {
  219. type: 'unique-value',
  220. uniqueValueInfos: [
  221. {
  222. value: 'line',
  223. symbol: {
  224. type: 'line-3d',
  225. symbolLayers: [
  226. {
  227. type: 'line',
  228. size: 2,
  229. material: {
  230. color: 'black'
  231. },
  232. cap: 'round',
  233. join: 'round'
  234. }
  235. ]
  236. }
  237. },
  238. {
  239. value: 'start',
  240. symbol: {
  241. type: 'simple-marker',
  242. size: 20,
  243. color: 'red',
  244. outline: {
  245. width: 0.5,
  246. color: 'white'
  247. }
  248. }
  249. },
  250. {
  251. value: 'end',
  252. symbol: {
  253. type: 'simple-marker',
  254. size: 20,
  255. color: 'orange',
  256. outline: {
  257. width: 0.5,
  258. color: 'white'
  259. }
  260. }
  261. }
  262. ]
  263. }
  264. });
  265. }
  266. //轨迹播放
  267. export function playTrajectory(id) {
  268. invokeParams('ShowData', {
  269. name: 'car_layer' + id,
  270. mode: 'player',
  271. action: 'play',
  272. speed: 60,
  273. showline: true,
  274. renderer: {
  275. type: 'unique-value',
  276. uniqueValueInfos: [
  277. {
  278. value: 'line',
  279. symbol: {
  280. type: 'line-3d',
  281. symbolLayers: [
  282. {
  283. type: 'line',
  284. size: 2,
  285. material: {
  286. color: 'green'
  287. },
  288. cap: 'round',
  289. join: 'round'
  290. }
  291. ]
  292. }
  293. },
  294. {
  295. value: 'flowlabel',
  296. symbol: {
  297. type: 'text',
  298. color: 'black',
  299. text: '{{date}}\r\n\r\n',
  300. font: {
  301. size: 10,
  302. weight: 'bold'
  303. }
  304. }
  305. },
  306. {
  307. value: 'marker',
  308. symbol: {
  309. type: 'simple-marker',
  310. size: 10,
  311. color: 'red',
  312. outline: {
  313. width: 0.5,
  314. color: 'white'
  315. }
  316. }
  317. }
  318. ]
  319. }
  320. });
  321. }
  322. export function stopTrajectory(id) {
  323. invokeParams('ShowData', {
  324. name: id,
  325. mode: 'player',
  326. action: 'stop'
  327. });
  328. }
  329. //标绘制线
  330. export function startBidding(visible = true) {
  331. invokeParams('userSketch', {
  332. type: 'point', //'point',
  333. visible: visible,
  334. isTools: true,
  335. isLocate: true,
  336. position: 'top-right',
  337. activeSymbol: {
  338. type: 'simple-marker',
  339. size: 5,
  340. color: 'red',
  341. outline: {
  342. width: 0.5,
  343. color: 'white'
  344. }
  345. }
  346. });
  347. }
  348. //画线
  349. export function addPolyLine(data, name) {
  350. invokeParams('ShowData', {
  351. name: name || 'layer1',
  352. type: 'polyline',
  353. data: {
  354. content: data,
  355. parsegeometry: "function(item){return [Number(item['x']), Number(item['y'])]}"
  356. },
  357. legendVisible: false,
  358. popupEnabled: false,
  359. renderer: {
  360. type: 'simple',
  361. label: '测试',
  362. visualVariables: [],
  363. symbol: {
  364. type: 'line-3d',
  365. symbolLayers: [
  366. {
  367. type: 'line',
  368. size: 2,
  369. material: {
  370. color: 'red'
  371. },
  372. cap: 'round',
  373. join: 'round'
  374. }
  375. ]
  376. }
  377. }
  378. });
  379. }
  380. export function juHe() {
  381. invokeParams('ShowData', {
  382. name: 'car_layer',
  383. // type: 'cluster',
  384. isLocate: true,
  385. data: {
  386. url: new URL(`@/utils/map/test2.json`, import.meta.url).href,
  387. parsegeometry: 'function(item){return {x:Number(item.X),y:Number(item.Y)}}'
  388. },
  389. popupEnabled: false,
  390. legendVisible: false,
  391. featureReduction: {
  392. type: 'cluster',
  393. clusterRadius: '200px',
  394. // maxClusterRadius: 200,
  395. labelingInfo: [
  396. {
  397. symbol: {
  398. type: 'text',
  399. color: '#004a5d',
  400. font: {
  401. size: '12px'
  402. }
  403. },
  404. labelPlacement: 'center-center'
  405. }
  406. ],
  407. labelsVisible: true,
  408. popupEnabled: false,
  409. minScale: 0,
  410. maxScale: 0
  411. },
  412. renderer: {
  413. type: 'unique-value',
  414. field: 'STATUSNAME',
  415. uniqueValueInfos: [
  416. {
  417. value: '已结案',
  418. label: '已结案',
  419. symbol: {
  420. type: 'simple-marker',
  421. size: 20,
  422. color: 'green',
  423. outline: {
  424. width: 0.5,
  425. color: 'white'
  426. }
  427. }
  428. }
  429. ]
  430. }
  431. // labels: [
  432. // {
  433. // fields: ['#.STATUSNAME'],
  434. // color: [255, 255, 255, 1],
  435. // size: 10,
  436. // labelPlacement: 'center-center'
  437. // }
  438. // ]
  439. });
  440. }
  441. //添加arcGisMap图层
  442. export function addArcgisMap() {
  443. invokeParams('AddArcgisMap', {
  444. name: '疾控图层',
  445. url: 'https://zgscim.china-gis.com/server/rest/services/basemap/basemap_white/MapServer',
  446. type: 'wmts'
  447. });
  448. }
  449. //开始输出点坐标点
  450. export function startOutputPoint() {
  451. invokeParams('outputClickPosition', {
  452. type: 'position',
  453. mode: 'start',
  454. popupEnabled: false,
  455. symbol: {
  456. type: 'simple-marker',
  457. size: 6,
  458. color: 'black',
  459. outline: {
  460. width: 0.5,
  461. color: 'white'
  462. }
  463. }
  464. });
  465. }
  466. //关闭输出点坐标
  467. export function closeOutputPoint() {
  468. invokeParams('outputClickPosition', {
  469. type: 'position',
  470. mode: 'stop'
  471. });
  472. }
  473. //定位
  474. export function gotoPosition(point, color) {
  475. invokeParams('goToPosition', {
  476. positon: point,
  477. heading: 0,
  478. tilt: 45,
  479. hasImg: true,
  480. marker: {
  481. size: 16,
  482. color: color || '#000fff'
  483. },
  484. zoom: 18,
  485. isRotation360: false
  486. });
  487. }
  488. //区边界
  489. export function regionZone() {
  490. invokeParams('goToPosition', {
  491. name: 'car_layer',
  492. type: 'layer',
  493. isLocate: true,
  494. isHighlight: true,
  495. highLight: {
  496. color: 'blue'
  497. },
  498. camera: {
  499. tilt: 0,
  500. heading: 0
  501. },
  502. data: {
  503. layers: {
  504. name: '区县边界'
  505. }
  506. },
  507. labels: [
  508. {
  509. fields: ['#.名称', '#.序号'],
  510. color: [255, 255, 0, 0.5],
  511. size: 12
  512. }
  513. ],
  514. renderer: {
  515. type: 'simple',
  516. symbol: {
  517. type: 'line-3d',
  518. symbolLayers: [
  519. {
  520. type: 'line',
  521. size: 5,
  522. material: {
  523. color: 'red'
  524. }
  525. }
  526. ]
  527. }
  528. }
  529. });
  530. }