addDataSet.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <link rel="stylesheet" href="./ol.css" type="text/css">
  5. <link rel="stylesheet" href="./style.css" type="text/css">
  6. <script src="./ol.js"></script>
  7. <style>
  8. [v-cloak] {
  9. display: none;
  10. }
  11. #editor {
  12. height: 200px;
  13. }
  14. </style>
  15. <!-- <script src="./ol.js"></script> -->
  16. <title>控制点定位</title>
  17. </head>
  18. <body>
  19. <div id="app" v-cloak>
  20. <div class="content">
  21. <div id="plane">
  22. <div class="scrollBox">
  23. <!-- <button id="location1">定位1</button>
  24. <button id="location2">定位2</button> -->
  25. <p class="title">数据集位置</p>
  26. <p class="desc">输入拍摄时记录的坐标,将数据集放置在真实世界地图中</p>
  27. <form>
  28. <div class="tag">
  29. <P class="formTitle">锚点1</P>
  30. <div class="localIcon" @click="location(1)"></div>
  31. </div>
  32. <div class="formItem">
  33. <p class="itemTitle">本地坐标:</p>
  34. <div class="inputItem">
  35. <div class="name"> X</div>
  36. <div class="ipt">
  37. <input type="text" v-model="ax" name="ax" id="ax" />
  38. </div>
  39. <span class="unit">m</span>
  40. </div>
  41. <div class="inputItem">
  42. <div class="name"> Y</div>
  43. <div class="ipt">
  44. <input type="text" v-model="ay" name="ay" id="ay" />
  45. </div>
  46. <span class="unit">m</span>
  47. </div>
  48. <div class="inputItem">
  49. <div class="name"> Z</div>
  50. <div class="ipt">
  51. <input type="text" v-model="az" name="az" id="az" />
  52. </div>
  53. <span class="unit">m</span>
  54. </div>
  55. </div>
  56. <div class="formItem">
  57. <p class="itemTitle">Wgs84坐标:</p>
  58. <div class="inputItem">
  59. <div class="name">经度</div>
  60. <div class="ipt">
  61. <input type="text" v-model="alon" name="alon" id="alon" value="120" />
  62. </div>
  63. </div>
  64. <div class="inputItem">
  65. <div class="name">纬度</div>
  66. <div class="ipt">
  67. <input type="text" v-model="alat" name="alat" id="alat" value="22" />
  68. </div>
  69. </div>
  70. <div class="inputItem">
  71. <div class="name">高程</div>
  72. <div class="ipt">
  73. <input type="text" v-model="aalt" name="aalt" id="aalt" value="0" />
  74. </div>
  75. </div>
  76. </div>
  77. <div class="tag">
  78. <P class="formTitle">锚点2</P>
  79. <div class="localIcon" @click="location(2)"></div>
  80. </div>
  81. <div class="formItem">
  82. <p class="itemTitle">本地坐标:</p>
  83. <div class="inputItem">
  84. <div class="name"> X</div>
  85. <div class="ipt">
  86. <input type="text" v-model="bx" name="bx" id="bx" />
  87. </div>
  88. <span class="unit">m</span>
  89. </div>
  90. <div class="inputItem">
  91. <div class="name"> Y</div>
  92. <div class="ipt">
  93. <input type="text" v-model="by" name="by" id="by" />
  94. </div>
  95. <span class="unit">m</span>
  96. </div>
  97. <div class="inputItem">
  98. <div class="name"> Z</div>
  99. <div class="ipt">
  100. <input type="text" v-model="bz" name="bz" id="bz" />
  101. </div>
  102. <span class="unit">m</span>
  103. </div>
  104. </div>
  105. <div class="formItem">
  106. <p class="itemTitle">Wgs84坐标:</p>
  107. <div class="inputItem">
  108. <div class="name">经度</div>
  109. <div class="ipt">
  110. <input type="text" v-model="blon" name="blon" id="blon" value="123" />
  111. </div>
  112. </div>
  113. <div class="inputItem">
  114. <div class="name">纬度</div>
  115. <div class="ipt">
  116. <input type="text" v-model="blat" name="blat" id="blat" value="22" />
  117. </div>
  118. </div>
  119. <div class="inputItem">
  120. <div class="name">高程</div>
  121. <div class="ipt">
  122. <input type="text" v-model="balt" name="balt" id="balt" value="0" />
  123. </div>
  124. </div>
  125. </div>
  126. <p class="itemTitle">EPSG 坐标系 4326</p>
  127. <div class="formItem">
  128. <div class="allIpt">
  129. <input type="text" v-model="EPSG" name="EPSG" id="EPSG" value="EPSG:4326" />
  130. </div>
  131. </div>
  132. </form>
  133. </div>
  134. <div class="bottom">
  135. <div class="style"></div>
  136. <!-- <input type="submit" class="submitBtn" value="提交" />
  137. <button id="clear">取消</button> -->
  138. <div id="clear" @click="clearMap">取消</div>
  139. <div class="submitBtn" @click="commit()">
  140. 提交
  141. </div>
  142. </div>
  143. </div>
  144. <div class="rightBox">
  145. <div id="map" class="map"></div>
  146. </div>
  147. </div>
  148. </div>
  149. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  150. <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  151. <script type="text/javascript">
  152. //输入经纬度就可以定位
  153. </script>
  154. <script>
  155. new Vue({
  156. el: '#app',
  157. data() {
  158. return {
  159. pointLayerArray: [],
  160. map: {},
  161. gaodeMapLayer: {},
  162. ax: '',
  163. ay: '',
  164. az: '',
  165. alon: '120',
  166. alat: '22',
  167. aalt: '0',
  168. bx: '',
  169. by: '',
  170. bz: '',
  171. blon: '123',
  172. blat: '22',
  173. balt: '0',
  174. EPSG: 'EPSG:4326',
  175. ageControlLocation1: [],
  176. ageControlLocation2: [],
  177. gpsControlCoordinate1: [],
  178. gpsControlCoordinate2: [],
  179. }
  180. },
  181. created() {
  182. },
  183. mounted() {
  184. // document.getElementById("location1").addEventListener("click", location1);
  185. // document.getElementById("location2").addEventListener("click", location2);
  186. // // document.getElementById("clear").addEventListener("click", clearMap);
  187. // function location1() {
  188. // let alon = document.getElementById("alon").value;
  189. // let alat = document.getElementById("alat").value;
  190. // addPoint(+alon, +alat, "锚点1")
  191. // }
  192. // function location2() {
  193. // let blon = document.getElementById("blon").value;
  194. // let blat = document.getElementById("blat").value;
  195. // addPoint(+blon, +blat, "锚点2")
  196. // }
  197. // let pointLayerArray = [];
  198. // let map = initMap('map');
  199. // function initMap(divid) {
  200. // let gaodeMapLayer = new ol.layer.Tile({
  201. // source: new ol.source.XYZ({
  202. // url: 'http://wprd03.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  203. // })
  204. // });
  205. // return new ol.Map({
  206. // layers: [gaodeMapLayer],
  207. // target: divid,
  208. // view: new ol.View({
  209. // center: ol.proj.fromLonLat([113.59569403794666,
  210. // 22.36656052911783
  211. // ]), //最初定位的位置
  212. // zoom: 4 //地图层级
  213. // })
  214. // });
  215. // }
  216. // function addPoint(lon, lat, text) {
  217. // let vector = new ol.source.Vector();
  218. // let vLayer = new ol.layer.Vector({
  219. // source: vector
  220. // })
  221. // vLayer.type = "con_point";
  222. // map.addLayer(vLayer)
  223. // pointLayerArray.push(vLayer);
  224. // let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  225. // let feature = new ol.Feature({
  226. // geometry: new ol.geom.Point(labelCoords)
  227. // });
  228. // vector.addFeature(feature);
  229. // vLayer.setStyle(new ol.style.Style({
  230. // image: new ol.style.Circle({ //点样式
  231. // radius: 7,
  232. // fill: new ol.style.Fill({
  233. // color: '#00c033'
  234. // })
  235. // }),
  236. // text: new ol.style.Text({
  237. // text: text,
  238. // font: '15px sans-serif',
  239. // offsetX: 5,
  240. // offsetY: -10,
  241. // fill: new ol.style.Fill({
  242. // color: "#b9391f"
  243. // }),
  244. // stroke: new ol.style.Stroke({
  245. // color: "#b9391f"
  246. // })
  247. // })
  248. // }))
  249. // map.getView().setCenter(labelCoords)
  250. // }
  251. // function clearMap() {
  252. // pointLayerArray.map(each => {
  253. // if (each.type == "con_point") {
  254. // map.removeLayer(each)
  255. // }
  256. // });
  257. // pointLayerArray = [];
  258. // }
  259. this.map = this.initMap('map');
  260. },
  261. methods: {
  262. initMap(divid) {
  263. this.pointLayerArray = [];
  264. this.gaodeMapLayer = new ol.layer.Tile({
  265. source: new ol.source.XYZ({
  266. url: 'http://wprd03.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  267. })
  268. });
  269. return new ol.Map({
  270. layers: [this.gaodeMapLayer],
  271. target: divid,
  272. view: new ol.View({
  273. center: ol.proj.fromLonLat([113.59569403794666,
  274. 22.36656052911783
  275. ]), //最初定位的位置
  276. zoom: 4 //地图层级
  277. })
  278. });
  279. },
  280. clearMap() {
  281. this.pointLayerArray.map(each => {
  282. alert(1)
  283. if (each.type == "con_point") {
  284. this.map.removeLayer(each)
  285. }
  286. });
  287. this.pointLayerArray = [];
  288. },
  289. addPoint(lon, lat, text) {
  290. let vector = new ol.source.Vector();
  291. let vLayer = new ol.layer.Vector({
  292. source: vector
  293. })
  294. vLayer.type = "con_point";
  295. this.map.addLayer(vLayer)
  296. this.pointLayerArray.push(vLayer);
  297. let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  298. let feature = new ol.Feature({
  299. geometry: new ol.geom.Point(labelCoords)
  300. });
  301. vector.addFeature(feature);
  302. vLayer.setStyle(new ol.style.Style({
  303. image: new ol.style.Circle({ //点样式
  304. radius: 7,
  305. fill: new ol.style.Fill({
  306. color: '#00c033'
  307. })
  308. }),
  309. text: new ol.style.Text({
  310. text: text,
  311. font: '15px sans-serif',
  312. offsetX: 5,
  313. offsetY: -10,
  314. fill: new ol.style.Fill({
  315. color: "#b9391f"
  316. }),
  317. stroke: new ol.style.Stroke({
  318. color: "#b9391f"
  319. })
  320. })
  321. }))
  322. this.map.getView().setCenter(labelCoords)
  323. },
  324. location(type) {
  325. let alon
  326. let alat
  327. let str = ''
  328. if (type == 1) {
  329. alon = this.alon;
  330. alat = this.alat;
  331. str = '锚点1'
  332. } else {
  333. alon = this.blon;
  334. alat = this.blat;
  335. str = '锚点2'
  336. }
  337. this.addPoint(+alon, +alat, str)
  338. },
  339. handleData() {
  340. this.ageControlLocation1.push(this.ax - 0)
  341. this.ageControlLocation1.push(this.ay - 0)
  342. this.ageControlLocation1.push(this.az - 0)
  343. this.gpsControlCoordinate1.push(this.alon - 0)
  344. this.gpsControlCoordinate1.push(this.alat - 0)
  345. this.gpsControlCoordinate1.push(this.aalt - 0)
  346. this.ageControlLocation2.push(this.bx - 0)
  347. this.ageControlLocation2.push(this.by - 0)
  348. this.ageControlLocation2.push(this.bz - 0)
  349. this.gpsControlCoordinate2.push(this.blon - 0)
  350. this.gpsControlCoordinate2.push(this.blat - 0)
  351. this.gpsControlCoordinate2.push(this.balt - 0)
  352. },
  353. commit() {
  354. this.handleData()
  355. axios.post('/indoor/api/controlPoint/save', {
  356. ageControlLocation1: this.ageControlLocation1,
  357. ageControlLocation2: this.ageControlLocation2,
  358. gpsControlCoordinate1: this.gpsControlCoordinate1,
  359. gpsControlCoordinate2: this.gpsControlCoordinate2,
  360. id: 1
  361. })
  362. .then(function (response) {
  363. alert('成功')
  364. })
  365. .catch(function (error) {
  366. alert('失败')
  367. });
  368. }
  369. }
  370. })
  371. </script>
  372. </body>
  373. </html>