hcxx.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div>
  3. <div class="imgCon">
  4. <div class="echartTitle">
  5. <div class="block-title">监测类型情况</div>
  6. </div>
  7. <div class="imgList">
  8. <div
  9. class="imgDiv"
  10. v-for="(item, i) in monitorList"
  11. :key="i"
  12. @click="clickImg(i)"
  13. @mouseenter="handleMouseEnter(item, i)"
  14. @mouseleave="handleMouseLeave(item, i)"
  15. >
  16. <span>{{ i + 1 }}</span>
  17. <img :src="item.imagerPath" />
  18. <p>{{ item.imagerSj }}</p>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. // import { getJctbhcInfo, getTiffPath } from "@/api/ghss/jctb.js";
  26. import VectorSource from "ol/source/Vector";
  27. import VectorLayer from "ol/layer/Vector";
  28. import Feature from "ol/Feature";
  29. import Point from "ol/geom/Point";
  30. import Style from "ol/style/Style";
  31. import Icon from "ol/style/Icon";
  32. export default {
  33. props: {
  34. detailObj: {
  35. type: Object,
  36. },
  37. jcbh: {
  38. type: String,
  39. },
  40. },
  41. components: {},
  42. data() {
  43. return {
  44. imgUrl: "",
  45. monitorList: [
  46. {
  47. name: "11swm",
  48. imagerLzb: "",
  49. imagerBzb: "",
  50. imagerPath:
  51. "/analyse/全域土地整治/jctb/0/HN4602022023022004080074/1b9a9da4a23d426cab363ed369150b4f.jpg",
  52. },
  53. ],
  54. primitive: null,
  55. selectId: null,
  56. primitivesArray: [],
  57. hcObj: null,
  58. // jtArr:[],//箭头id数组
  59. // dwArr:[],//
  60. idArr: [], //id数组
  61. handler: {},
  62. };
  63. },
  64. mounted() {
  65. this.init();
  66. },
  67. methods: {
  68. inputAction() {
  69. this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  70. // 鼠标移动事件
  71. this.handler.setInputAction(function (movement) {},
  72. Cesium.ScreenSpaceEventType.LEFT_CLICK);
  73. },
  74. handleMouseEnter(a, b) {
  75. this.ceshi(a.id, "yr");
  76. },
  77. handleMouseLeave(a, b) {
  78. this.ceshi(a.id, "yc");
  79. },
  80. changeData(name, updata) {
  81. this[name] = updata;
  82. },
  83. clickImg(val) {
  84. this.$emit("updateParent", "emitImgList", this.monitorList);
  85. this.$emit("updateParent", "emitImgIndex", val);
  86. },
  87. // 加载图片
  88. ddd(obj) {
  89. // 将经纬度转换为 Cartesian3 坐标,起始点
  90. //起始点
  91. // var startPosition = Cesium.Cartesian3.fromDegrees(
  92. // Number(obj.imagerLzb),
  93. // Number(obj.imagerBzb)
  94. // );
  95. // let poi = this.getLonAndLat(
  96. // Number(obj.imagerLzb),
  97. // Number(obj.imagerBzb),
  98. // Number(obj.imagerAngle),
  99. // 20
  100. // );
  101. // //结束点
  102. // var targetPosition = Cesium.Cartesian3.fromDegrees(poi.lng, poi.lat);
  103. // // 创建一个实体来表示点
  104. // var pointEntity = viewer.entities.add({
  105. // id: "dw" + obj.id,
  106. // position: startPosition, // 点的位置
  107. // point: {
  108. // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, // 设置为贴地
  109. // pixelSize: 10, // 点的大小
  110. // color: Cesium.Color.RED, // 点的颜色
  111. // outlineColor: Cesium.Color.BLACK, // 点的轮廓颜色
  112. // outlineWidth: 2, // 点的轮廓宽度
  113. // },
  114. // });
  115. // 创建一个实体来放置箭头
  116. // var arrowEntity = viewer.entities.add({
  117. // id: "jt" + obj.id,
  118. // position: startPosition, // 设置箭头位置
  119. // billboard: {
  120. // // image: "http://192.168.176.1:8001/长箭头.png", // 设置箭头图标
  121. // image: "/static/images/路径@3x-2.png", // 设置箭头图标
  122. // width: 37, // 设置图标宽度
  123. // height: 69, // 设置图标高度
  124. // scale: 0.7, // 设置图标缩放
  125. // rotation: Cesium.Math.toRadians(360 - Number(obj.imagerAngle)), // 可选,默认为0
  126. // // rotation: Number(obj.imagerAngle), // 可选,默认为0
  127. // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, // 设置贴地
  128. // },
  129. // });
  130. // // 聚焦视角到箭头位置
  131. // viewer.zoomTo(arrowEntity);
  132. var vectorSource = new VectorSource();
  133. window.map.mapDiv.addLayer(
  134. new VectorLayer({
  135. source: vectorSource,
  136. style: new Style({
  137. image: new Icon({
  138. anchor: [0.5, 46], // 调整锚点以正确显示箭头尖端位置
  139. anchorXUnits: "fraction",
  140. anchorYUnits: "pixels",
  141. src: "/static/images/路径@3x-2.png", // 替换为你的箭头图片路径
  142. rotation: Math.PI / 4, //360 - Number(obj.imagerAngle),
  143. }),
  144. }), // 使用自定义样式
  145. })
  146. );
  147. // 添加一个特征,并设置其旋转角度
  148. var feature = new Feature({
  149. geometry: new Point([0, 0]), // 设置位置
  150. });
  151. // feature.setStyle(
  152. // new ol.style.Style({
  153. // // 可以单独为特征设置样式以覆盖图层样式
  154. // image: new ol.style.Icon({
  155. // anchor: [0.5, 46], // 保持锚点设置不变
  156. // anchorXUnits: "fraction",
  157. // anchorYUnits: "pixels",
  158. // src: "path/to/your/arrow.png", // 替换为你的箭头图片路径
  159. // rotation: Math.PI / 4, // 设置旋转角度,例如45度角,Math.PI / 4 表示 π/4 弧度,即45度角。可以根据需要调整角度值。
  160. // }),
  161. // })
  162. // );
  163. vectorSource.addFeature(feature);
  164. },
  165. ceshi(id, evtName) {
  166. let aaa = viewer.entities.getById("jt" + id);
  167. if (evtName == "yr") {
  168. aaa.billboard.image = "/static/images/路径@3x.png";
  169. } else {
  170. aaa.billboard.image = "/static/images/路径@3x-2.png";
  171. }
  172. },
  173. /**
  174. * 根据一个经纬度及距离角度,算出另外一个经纬度
  175. * @param {*} lng 经度 113.3960698
  176. * @param {*} lat 纬度 22.941386
  177. * @param {*} brng 方位角 45 ---- 正北方:000°或360° 正东方:090° 正南方:180° 正西方:270°
  178. * @param {*} dist 90000距离(米)
  179. * 1、角度转换为弧度公式:弧度=角度×(π ÷度180 )
  180. * 2、弧度转换为角度公式: 角度=弧度×(180÷π)
  181. */
  182. getLonAndLat(lng, lat, brng, dist) {
  183. //大地坐标系资料WGS-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
  184. var a = 6378137;
  185. var b = 6356752.3142;
  186. var f = 1 / 298.257223563;
  187. var lon1 = lng * 1;
  188. var lat1 = lat * 1;
  189. var s = dist;
  190. var alpha1 = brng * (Math.PI / 180); //mapNumberUtil.rad(brng);
  191. var sinAlpha1 = Math.sin(alpha1);
  192. var cosAlpha1 = Math.cos(alpha1);
  193. //var tanU1 = (1 - f) * Math.tan(mapNumberUtil.rad(lat1));
  194. var tanU1 = (1 - f) * Math.tan(lat1 * (Math.PI / 180));
  195. var cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),
  196. sinU1 = tanU1 * cosU1;
  197. var sigma1 = Math.atan2(tanU1, cosAlpha1);
  198. var sinAlpha = cosU1 * sinAlpha1;
  199. var cosSqAlpha = 1 - sinAlpha * sinAlpha;
  200. var uSq = (cosSqAlpha * (a * a - b * b)) / (b * b);
  201. var A =
  202. 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
  203. var B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
  204. var sigma = s / (b * A),
  205. sigmaP = 2 * Math.PI;
  206. while (Math.abs(sigma - sigmaP) > 1e-12) {
  207. var cos2SigmaM = Math.cos(2 * sigma1 + sigma);
  208. var sinSigma = Math.sin(sigma);
  209. var cosSigma = Math.cos(sigma);
  210. var deltaSigma =
  211. B *
  212. sinSigma *
  213. (cos2SigmaM +
  214. (B / 4) *
  215. (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
  216. (B / 6) *
  217. cos2SigmaM *
  218. (-3 + 4 * sinSigma * sinSigma) *
  219. (-3 + 4 * cos2SigmaM * cos2SigmaM)));
  220. sigmaP = sigma;
  221. sigma = s / (b * A) + deltaSigma;
  222. }
  223. var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
  224. var lat2 = Math.atan2(
  225. sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
  226. (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)
  227. );
  228. var lambda = Math.atan2(
  229. sinSigma * sinAlpha1,
  230. cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1
  231. );
  232. var C = (f / 16) * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
  233. var L =
  234. lambda -
  235. (1 - C) *
  236. f *
  237. sinAlpha *
  238. (sigma +
  239. C *
  240. sinSigma *
  241. (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
  242. var revAz = Math.atan2(sinAlpha, -tmp); // final bearing
  243. var lngLatObj = {
  244. lng: lon1 + L * (180 / Math.PI),
  245. lat: lat2 * (180 / Math.PI),
  246. };
  247. return lngLatObj;
  248. },
  249. delatePoi(type) {
  250. if (this.idArr.length != 0) {
  251. this.idArr.forEach((item) => {
  252. viewer.entities.removeById(type + item);
  253. });
  254. // this.idArr = [];
  255. }
  256. },
  257. init() {
  258. // getJctbhcInfo(newVal).then((res) => {
  259. this.idArr = [];
  260. // if (res.code == 200) {
  261. // this.monitorList = res.data.images;
  262. // this.hcObj = res.data;
  263. this.monitorList.forEach((item, i) => {
  264. // item.name = res.data.dcry;
  265. // window.axiosURI +/file/upload/attachment
  266. item.imagerPath =
  267. "http://192.168.60.2:8080/file/upload/attachment" + item.imagerPath;
  268. this.ddd(item);
  269. this.idArr.push(item.id);
  270. });
  271. // }
  272. // });
  273. },
  274. },
  275. watch: {
  276. jcbh: {
  277. handler(newVal, oldVal) {},
  278. // deep: true,
  279. // immediate: true,
  280. },
  281. },
  282. beforeDestroy() {
  283. this.delatePoi("jt");
  284. this.delatePoi("dw");
  285. },
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. .imgCon {
  290. .imgList {
  291. width: 100%;
  292. // height: 300px;
  293. max-height: 400px;
  294. display: flex;
  295. flex-wrap: wrap;
  296. // background-color: rgba(255, 192, 203, 0.372);
  297. .imgDiv {
  298. width: 126px;
  299. height: 83px;
  300. margin-right: 10px;
  301. // background-color: rgba(0, 255, 255, 0.413);
  302. position: relative;
  303. margin: 4px 4px;
  304. img {
  305. width: 126px;
  306. height: 83px;
  307. }
  308. span {
  309. width: 26px;
  310. height: 26px;
  311. display: inline-block;
  312. position: absolute;
  313. top: 0;
  314. left: 0;
  315. background: #dbad70;
  316. text-align: center;
  317. line-height: 26px;
  318. }
  319. p {
  320. position: absolute;
  321. bottom: 0;
  322. font-size: 10px;
  323. color: #33ccff;
  324. text-align: center;
  325. width: 100%;
  326. height: 30px;
  327. line-height: 30px;
  328. }
  329. }
  330. }
  331. }
  332. </style>