移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
пре 2 година
пре 4 месеци
пре 3 година
пре 6 месеци
пре 3 година
пре 3 година
пре 4 месеци
пре 3 година
пре 6 месеци
пре 3 година
пре 2 година
пре 4 месеци
пре 3 година
пре 6 месеци
пре 2 година
пре 3 година
пре 2 година
пре 4 месеци
пре 3 година
пре 2 година
пре 3 година
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 4 месеци
пре 6 месеци
пре 5 месеци
пре 3 година
пре 5 месеци
пре 5 месеци
пре 5 месеци
пре 3 година
пре 2 година
пре 3 година
пре 6 месеци
пре 5 месеци
пре 6 месеци
пре 3 година
пре 5 месеци
пре 3 година
пре 2 година
пре 3 година
пре 6 месеци
пре 5 месеци
пре 6 месеци
пре 3 година
пре 2 година
пре 3 година
пре 4 месеци
пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <div>
  3. <!-- <p class="fuTitle">地块位置绘制</p>-->
  4. <div id="full-screen-acceptance" style="width: 100%;height:71vh; position: relative;">
  5. <div :id=this.uuidMap style="width: 100%;height: 100%"></div>
  6. <div id='land-btn-wrap'>
  7. <!--<el-button :id=this.drawingPolygonMap style="background-color:#D0EEFF;color:#1E88C7" @click="" type="primary">画图</el-button>-->
  8. <!--<input id="drawRemove" type="button" class="ant-btn ant-btn-red" value="取消"/>&nbsp;&nbsp;-->
  9. <!--<el-button :id=this.drawingPolygonMap style="background-color:#D0EEFF;color:#1E88C7" type="primary">重置图层</el-button>-->
  10. <input :id="locationMap" type="button" class="ant-btn ant-btn-red" value="定位"/>&nbsp;&nbsp;
  11. <input :id="this.drawingPolygonMap" class="ant-btn ant-btn-red" type="button" value="画图"/>&nbsp;&nbsp;
  12. <input :id="this.drawingResetMap" type="button" class="ant-btn ant-btn-red" value="重置"/>&nbsp;&nbsp;
  13. </div>
  14. <div v-if="hasSelectLocationMode" class="location-mode-chooser-btn"><input type="button" class="ant-btn ant-btn-red" value="选择定位方式" @click="selectLocationMode"/></div>
  15. </div>
  16. <div style="font-size: 13px; padding-top: 5px;">备注:绿色地块表示该地块,蓝色表示本账套已标记的其他地块</div>
  17. <div id="info" style="display: none"></div>
  18. </div>
  19. </template>
  20. <script>
  21. import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
  22. import $ from "jquery";
  23. import { getConfigKey } from "@/api/system/config";
  24. import {Toast} from "vant";
  25. export default {
  26. components: {
  27. getQueryLand,
  28. },
  29. data() {
  30. return {
  31. closeMoule: null,
  32. uuidMap: this.guidProduct(),
  33. drawingPolygonMap: this.guidProduct(),
  34. drawingResetMap: this.guidProduct(),
  35. locationMap: this.guidProduct(),
  36. mapGeoServerUrl: "", // geoserver地址
  37. villageBorderLayerName: "", // 乡镇边界图层名称
  38. };
  39. },
  40. props: ['theGeom','message', 'resourceId', 'resourceList'],
  41. created() {
  42. // 获取geoserver的地址
  43. this.getGeoServerUrl();
  44. // 获取村边界的图层名称
  45. this.getVillageBorderLayerName();
  46. },
  47. computed: {
  48. isAndroid() {
  49. return !!window._Native_object;
  50. },
  51. hasSelectLocationMode() {
  52. return this.isAndroid && typeof(window._Native_object.SelectLocationMode) === 'function';
  53. },
  54. hasGetLocationTimeout() {
  55. return this.isAndroid && typeof(window._Native_object.GetLocationTimeout) === 'function';
  56. },
  57. hasGetLocationMode() {
  58. return this.isAndroid && typeof(window._Native_object.GetLocationMode) === 'function';
  59. },
  60. },
  61. methods: {
  62. // 获取geoserver的地址
  63. getGeoServerUrl() {
  64. getConfigKey("system.geoServer.url").then(response => {
  65. this.mapGeoServerUrl = response.msg;
  66. });
  67. },
  68. // 获取村边界的图层名称
  69. getVillageBorderLayerName() {
  70. getConfigKey("geoserver.layer.villageBorder").then(response => {
  71. this.villageBorderLayerName = response.msg;
  72. });
  73. },
  74. //地图加载
  75. formSubmit(){
  76. //父组件监听的名字必须是formSubmit
  77. // 子组件调用父组件的方法并传参
  78. if(this.closeMoule =="" || this.closeMoule == null){
  79. this.$emit('formSubmit', null);
  80. }else{
  81. this.$emit('formSubmit', JSON.stringify(this.closeMoule));
  82. }
  83. },
  84. guidProduct(){
  85. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  86. var r = Math.random() * 16 | 0,
  87. v = c == 'x' ? r : (r & 0x3 | 0x8);
  88. return v.toString(16);
  89. });
  90. },
  91. selectLocationMode() {
  92. if(this.hasSelectLocationMode)
  93. {
  94. let res = window._Native_object.SelectLocationMode();
  95. console.log('当前选择定位模式: ' + res);
  96. }
  97. },
  98. getLocationMode() {
  99. let mode = '';
  100. if(this.hasGetLocationMode)
  101. {
  102. mode = window._Native_object.GetLocationMode();
  103. }
  104. console.log('当前选择定位模式: ' + mode);
  105. return mode;
  106. },
  107. getLocationTimeout() {
  108. let timeout = 30000;
  109. if(this.isAndroid)
  110. {
  111. let to = window._Native_object.GetLocationTimeout();
  112. if(to <= 0)
  113. to = 30000;
  114. timeout = to;
  115. }
  116. console.log('当前选择定位超时: ' + timeout);
  117. return timeout;
  118. },
  119. getCurrentLocation(callback) {
  120. // 1. 首先尝试Android宿主端
  121. if(this.isAndroid) // Android层注入全局对象
  122. {
  123. let mode = this.getLocationMode();
  124. if(mode !== 'h5')
  125. {
  126. console.log('使用Native获取定位');
  127. let coord = window._Native_object.GetLocation(null);
  128. console.log('Native坐标: ' + coord);
  129. if(coord)
  130. {
  131. let arr = coord.split(',');
  132. let res = {
  133. code: 200,
  134. data: {
  135. lng: arr[0],
  136. lat: arr[1],
  137. },
  138. };
  139. callback(res);
  140. return;
  141. }
  142. }
  143. }
  144. // 2. 再尝试浏览器
  145. if (navigator.geolocation) {
  146. console.log('使用浏览器获取定位');
  147. const loading = Toast.loading({
  148. message: '定位中...',
  149. duration: 0,
  150. });
  151. let timeout = this.getLocationTimeout();
  152. navigator.geolocation.getCurrentPosition(
  153. (position) => {
  154. const { latitude, longitude } = position.coords;
  155. console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
  156. let res = {
  157. code: 200,
  158. data: {
  159. lng: longitude,
  160. lat: latitude,
  161. },
  162. };
  163. loading.clear();
  164. callback(res);
  165. },
  166. (error) => {
  167. loading.clear();
  168. console.log('定位失败: ' + error.message);
  169. getQueryLand().then(callback);
  170. },
  171. { enableHighAccuracy: true, timeout: timeout }
  172. );
  173. return;
  174. }
  175. // 最后使用地区坐标
  176. console.log('使用地区坐标定位');
  177. getQueryLand().then(callback);
  178. },
  179. getDeptLocation(callback) {
  180. getQueryLand().then((response) => {
  181. if (response.code == 200) {
  182. let InsertCode = response.data;
  183. if (InsertCode != null) {
  184. var lat = InsertCode.lat;
  185. var lng = InsertCode.lng;
  186. if(lat !=null && lng !=null && lat !="" && lng !=""){
  187. callback(response);
  188. return;
  189. }
  190. }
  191. }
  192. this.getCurrentLocation(callback);
  193. });
  194. },
  195. //地图查看
  196. drawingPaceCountryLine() {
  197. //加载地图编辑
  198. var that = this;
  199. var map;
  200. //var hc_land;
  201. var draw; // global so we can remove it later
  202. var vector_drawing;
  203. var mark_layer = null;
  204. function addMark(lng, lat) {
  205. if(!mark_layer)
  206. {
  207. mark_layer = new ol.layer.Vector({
  208. source: new ol.source.Vector(),
  209. });
  210. map.addLayer(mark_layer);
  211. }
  212. else
  213. mark_layer.getSource().clear();
  214. let newFeature = new ol.Feature({
  215. geometry: new ol.geom.Point(ol.proj.fromLonLat([lng, lat])), //几何信息
  216. //name: "标注点",
  217. });
  218. newFeature.setStyle(new ol.style.Style({
  219. image: new ol.style.Icon({
  220. //设置图标偏移
  221. anchor: [0.5, 0.5],
  222. //标注样式的起点位置
  223. anchorOrigin: "top-right",
  224. //X方向单位:分数
  225. anchorXUnits: "fraction",
  226. //Y方向单位:像素
  227. anchorYUnits: "fraction",
  228. //偏移起点位置的方向
  229. offsetOrigin: "top-right",
  230. //透明度
  231. opacity: 0.9,
  232. //图片路径
  233. src: require('../../assets/images/location/mark.png'),
  234. }),
  235. zIndex: 9999,
  236. }));
  237. mark_layer.getSource().addFeature(newFeature);
  238. }
  239. if (that.message != null && that.message != ""
  240. && that.message != undefined) {
  241. document.getElementById(that.uuidMap).innerHTML = '';
  242. var hc_land;
  243. var hc_landFuther;
  244. var draw; // global so we can remove it later
  245. var vector_drawing;
  246. var projection = new ol.proj.Projection({
  247. //地图投影类型
  248. code: "EPSG:3857",
  249. units: "degrees",
  250. //extent:extent
  251. });
  252. var aerial = new ol.layer.Tile({
  253. source: new ol.source.XYZ({
  254. url: "http://t0.tianditu.gov.cn/img_w/wmts?" +
  255. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  256. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  257. }),
  258. isGroup: true,
  259. name: "卫星影像图",
  260. });
  261. var yingxzi = new ol.layer.Tile({
  262. source: new ol.source.XYZ({
  263. url: "https://t0.tianditu.gov.cn/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  264. }),
  265. isGroup: true,
  266. name: "天地图文字标注--卫星影像图",
  267. });
  268. //加载地图
  269. map = new ol.Map({
  270. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
  271. layers: [aerial, yingxzi],
  272. projection: projection,
  273. target: that.uuidMap,
  274. view: new ol.View({
  275. //center: ol.proj.fromLonLat([115.452752, 31.789033]),
  276. zoom: 15,
  277. minZoom: 5, //地图缩小限制
  278. maxZoom: 18.3, //地图放大限制
  279. }),
  280. });
  281. // 添加村边界
  282. let mapBorder = new ol.layer.Image({
  283. source: new ol.source.ImageWMS({
  284. url: this.mapGeoServerUrl + '/wms',
  285. params: {
  286. LAYERS: this.villageBorderLayerName,
  287. cql_filter: "dept_id = '" + this.$store.state.user.loginDeptId + "'",
  288. SRID: 3857,
  289. },
  290. }),
  291. name: 'villageBorderLayer'
  292. });
  293. map.addLayer(mapBorder);
  294. // 添加已经存在的资源图层
  295. let vectorSource = new ol.source.Vector();
  296. for (let resource of this.resourceList) {
  297. if (resource.theGeom && resource.id !== this.resourceId) {
  298. let feature = new ol.Feature({
  299. geometry: new ol.geom.MultiPolygon(JSON.parse(resource.theGeom).coordinates),
  300. // permanentName: permanent.name
  301. });
  302. vectorSource.addFeature(feature);
  303. }
  304. }
  305. let resourceLayer = new ol.layer.Vector({
  306. source: vectorSource,
  307. style: (feature, resolution) => {
  308. return new ol.style.Style({
  309. fill: new ol.style.Fill({
  310. //矢量图层填充颜色,以及透明度
  311. color: "rgba(0, 218, 255, 0.3)",
  312. }),
  313. stroke: new ol.style.Stroke({
  314. //边界样式
  315. color: "#00DAFF",
  316. width: 3,
  317. }),
  318. })
  319. }
  320. });
  321. map.addLayer(resourceLayer);
  322. //图层查询定位开始 ---------start
  323. if(this.message.substring(0,1) =="{"){
  324. // var theGeomMap =this.message.replace("Point", "MultiPolygon");
  325. // var pointLeft = theGeomMap.replace("[", "[[[[");
  326. // var pointRight = pointLeft.replace("]", "]]]]");
  327. hc_land = new ol.layer.Vector({
  328. title: "add Layer",
  329. source: new ol.source.Vector({
  330. projection: projection,
  331. features: new ol.format.GeoJSON().readFeatures("{\n" +
  332. " \"type\": \"Feature\",\n" +
  333. " \"geometry\":" + this.message + "}"),
  334. }),
  335. style: new ol.style.Style({
  336. fill: new ol.style.Fill({
  337. //矢量图层填充颜色,以及透明度
  338. color: "rgba(204, 255, 204,0.3)",
  339. }),
  340. stroke: new ol.style.Stroke({
  341. //边界样式
  342. color: "#47c68f",
  343. width: 3,
  344. }),
  345. }),
  346. });
  347. map.addLayer(hc_land);
  348. var maxXMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxX;
  349. var maxYMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxY;
  350. var minXMap = hc_land.values_.source.featuresRtree_.rbush_.data.minX;
  351. var minYMap = hc_land.values_.source.featuresRtree_.rbush_.data.minY;
  352. //定位查询位置
  353. var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置
  354. map.getView().animate({
  355. // 只设置需要的属性即可
  356. center: center, // 中心点
  357. zoom: 17.9, // 缩放级别
  358. rotation: undefined, // 缩放完成view视图旋转弧度
  359. duration: 1000, // 缩放持续时间,默认不需要设置
  360. });
  361. }
  362. // if(this.message.substring(0,1) =="["){
  363. // var zbNew = JSON.stringify({"type": "MultiPolygon", "coordinates": [[[this.message.replaceAll("\"","")]]]});
  364. // var leftJoin = zbNew.replace("\"[","[");
  365. // var rightJoin = leftJoin.replace("\"]","]");
  366. // hc_landFuther = new ol.layer.Vector({
  367. // title: "add Layer",
  368. // source: new ol.source.Vector({
  369. // projection: projection,
  370. // features: new ol.format.GeoJSON().readFeatures("{\n" +
  371. // " \"type\": \"Feature\",\n" +
  372. // " \"geometry\":" + rightJoin + "}"),
  373. // }),
  374. // style: new ol.style.Style({
  375. // fill: new ol.style.Fill({
  376. // //矢量图层填充颜色,以及透明度
  377. // color: "rgba(204, 255, 204,0.3)",
  378. // }),
  379. // stroke: new ol.style.Stroke({
  380. // //边界样式
  381. // color: "#47c68f",
  382. // width: 3,
  383. // }),
  384. // }),
  385. // });
  386. // map.addLayer(hc_landFuther);
  387. // var maxXMap = hc_landFuther.values_.source.featuresRtree_.rbush_.data.maxX;
  388. // var maxYMap = hc_landFuther.values_.source.featuresRtree_.rbush_.data.maxY;
  389. // var minXMap = hc_landFuther.values_.source.featuresRtree_.rbush_.data.minX;
  390. // var minYMap = hc_landFuther.values_.source.featuresRtree_.rbush_.data.minY;
  391. // //定位查询位置
  392. // var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置
  393. // map.getView().animate({
  394. // // 只设置需要的属性即可
  395. // center: center, // 中心点
  396. // zoom: 17.9, // 缩放级别
  397. // rotation: undefined, // 缩放完成view视图旋转弧度
  398. // duration: 1000, // 缩放持续时间,默认不需要设置
  399. // });
  400. // }
  401. //图层查询定位结束 ---------end
  402. //开始绘制地图
  403. $("#"+this.drawingPolygonMap).click(function () {
  404. map.removeLayer(hc_land);
  405. //map.removeLayer(hc_landFuther);
  406. map.removeLayer(vector_drawing);
  407. //that.closeMoule = null;
  408. map.removeInteraction(draw);
  409. //var source = new ol.source.Vector({wrapX: false});
  410. vector_drawing = new ol.layer.Vector({
  411. source: new ol.source.Vector(),
  412. });
  413. map.addLayer(vector_drawing);
  414. function addInteraction() {
  415. draw = new ol.interaction.Draw({
  416. source: vector_drawing.getSource(),
  417. type: "Polygon"
  418. });
  419. draw.on('drawend', function (evt) {
  420. var feature = evt.feature;
  421. var geometry = feature.getGeometry();
  422. var coordinate = geometry.getCoordinates();
  423. that.closeMoule = coordinate;
  424. that.formSubmit();
  425. });
  426. map.addInteraction(draw);
  427. }
  428. addInteraction();
  429. });
  430. //清除画图鼠标点击事件
  431. // $("#drawRemove").click(function () {
  432. // //map.addLayer(hc_land);
  433. // map.removeInteraction(draw);
  434. // //map.removeLayer(vector_drawing);
  435. // });
  436. //还原之前图层
  437. $("#"+this.drawingResetMap).click(function () {
  438. if(that.closeMoule !=null) {
  439. map.removeLayer(vector_drawing);
  440. //map.removeLayer(hc_landFuther);
  441. map.removeInteraction(draw);
  442. map.addLayer(hc_land);
  443. //map.addLayer(hc_landFuther);
  444. // that.closeMoule = null;
  445. that.formSubmit();
  446. }
  447. });
  448. $("#" + this.locationMap).click(function () {
  449. that.getCurrentLocation(res => {
  450. if (res.code == 200) {
  451. let lat = res.data.lat;
  452. let lng = res.data.lng;
  453. if(lat && lng){
  454. Zb = [lng,lat];
  455. }else {
  456. Zb =[115.452752, 31.789033];
  457. }
  458. addMark(lng,lat);
  459. map.getView().animate({
  460. // 只设置需要的属性即可
  461. center: ol.proj.fromLonLat(Zb), // 中心点
  462. zoom: 18, // 缩放级别
  463. rotation: undefined, // 缩放完成view视图旋转弧度
  464. duration: 1000, // 缩放持续时间,默认不需要设置
  465. });
  466. }
  467. });
  468. });
  469. } else{
  470. //this.closeMoule = null;
  471. document.getElementById(that.uuidMap).innerHTML = '';
  472. var projection = new ol.proj.Projection({
  473. //地图投影类型
  474. code: "EPSG:3857",
  475. units: "degrees",
  476. //extent:extent
  477. });
  478. var aerial = new ol.layer.Tile({
  479. source: new ol.source.XYZ({
  480. url: "http://t0.tianditu.gov.cn/img_w/wmts?" +
  481. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  482. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  483. }),
  484. isGroup: true,
  485. name: "卫星影像图",
  486. });
  487. var yingxzi = new ol.layer.Tile({
  488. source: new ol.source.XYZ({
  489. url: "https://t0.tianditu.gov.cn/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  490. }),
  491. isGroup: true,
  492. name: "天地图文字标注--卫星影像图",
  493. });
  494. //获取坐标是否存在
  495. var Zb;
  496. this.getDeptLocation((response) => {
  497. if (response.code == 200) {
  498. let InsertCode = response.data;
  499. if (InsertCode != null) {
  500. var lat = InsertCode.lat;
  501. var lng = InsertCode.lng;
  502. if(lat !=null && lng !=null && lat !="" && lng !=""){
  503. Zb = [lng,lat];
  504. }else {
  505. Zb =[115.452752, 31.789033];
  506. }
  507. //加载地图
  508. map = new ol.Map({
  509. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
  510. layers: [aerial, yingxzi],
  511. projection: projection,
  512. logo: 'false',
  513. target: that.uuidMap,
  514. view: new ol.View({
  515. center: ol.proj.fromLonLat(Zb),
  516. //center: ol.proj.fromLonLat([115.452752, 31.789033]),
  517. zoom: 16.9,
  518. minZoom: 5, //地图缩小限制
  519. maxZoom: 18, //地图放大限制
  520. }),
  521. });
  522. // 添加村边界
  523. let mapBorder = new ol.layer.Image({
  524. source: new ol.source.ImageWMS({
  525. url: this.mapGeoServerUrl + '/wms',
  526. params: {
  527. LAYERS: this.villageBorderLayerName,
  528. cql_filter: "dept_id = '" + this.$store.state.user.loginDeptId + "'",
  529. SRID: 3857,
  530. },
  531. }),
  532. name: 'villageBorderLayer'
  533. });
  534. map.addLayer(mapBorder);
  535. // 添加已经存在的资源图层
  536. let vectorSource = new ol.source.Vector();
  537. for (let resource of this.resourceList) {
  538. if (resource.theGeom && resource.id !== this.resourceId) {
  539. let feature = new ol.Feature({
  540. geometry: new ol.geom.MultiPolygon(JSON.parse(resource.theGeom).coordinates),
  541. // permanentName: permanent.name
  542. });
  543. vectorSource.addFeature(feature);
  544. }
  545. }
  546. let resourceLayer = new ol.layer.Vector({
  547. source: vectorSource,
  548. style: (feature, resolution) => {
  549. return new ol.style.Style({
  550. fill: new ol.style.Fill({
  551. //矢量图层填充颜色,以及透明度
  552. color: "rgba(0, 218, 255, 0.3)",
  553. }),
  554. stroke: new ol.style.Stroke({
  555. //边界样式
  556. color: "#00DAFF",
  557. width: 3,
  558. }),
  559. })
  560. }
  561. });
  562. map.addLayer(resourceLayer);
  563. }
  564. }
  565. });
  566. //图层查询定位结束 ---------end
  567. //开始绘制地图
  568. $("#"+this.drawingPolygonMap).click(function () {
  569. //that.closeMoule = null;
  570. map.removeInteraction(draw);
  571. //var source = new ol.source.Vector({wrapX: false});
  572. vector_drawing = new ol.layer.Vector({
  573. source: new ol.source.Vector(),
  574. });
  575. map.addLayer(vector_drawing);
  576. function addInteraction() {
  577. draw = new ol.interaction.Draw({
  578. source: vector_drawing.getSource(),
  579. type: "Polygon"
  580. });
  581. draw.on('drawend', function (evt) {
  582. var feature = evt.feature;
  583. var geometry = feature.getGeometry();
  584. var coordinate = geometry.getCoordinates();
  585. that.closeMoule = coordinate;
  586. that.formSubmit();
  587. });
  588. map.addInteraction(draw);
  589. }
  590. addInteraction();
  591. });
  592. //清除画图鼠标点击事件
  593. // $("#drawRemove").click(function () {
  594. // //map.addLayer(hc_land);
  595. // map.removeInteraction(draw);
  596. // //map.removeLayer(vector_drawing);
  597. // });
  598. //还原之前图层
  599. $("#"+this.drawingResetMap).click(function () {
  600. map.removeInteraction(draw);
  601. map.removeLayer(vector_drawing);
  602. //that.closeMoule = null;
  603. that.formSubmit();
  604. });
  605. $("#" + this.locationMap).click(function () {
  606. that.getCurrentLocation(res => {
  607. if (res.code == 200) {
  608. let lat = res.data.lat;
  609. let lng = res.data.lng;
  610. if(lat && lng){
  611. Zb = [lng,lat];
  612. }else {
  613. Zb =[115.452752, 31.789033];
  614. }
  615. addMark(lng,lat);
  616. map.getView().animate({
  617. // 只设置需要的属性即可
  618. center: ol.proj.fromLonLat(Zb), // 中心点
  619. zoom: 18, // 缩放级别
  620. rotation: undefined, // 缩放完成view视图旋转弧度
  621. duration: 1000, // 缩放持续时间,默认不需要设置
  622. });
  623. }
  624. });
  625. });
  626. }
  627. },
  628. },
  629. watch: {},
  630. };
  631. </script>
  632. <style scoped>
  633. #that.message {
  634. width: 100%;
  635. height: 100%;
  636. }
  637. .fuTitle {
  638. border-top: 1px solid #e9e9e9;
  639. text-align: center;
  640. padding: 10px 0px 0px 0px;
  641. font-size: 18px;
  642. color: #999;
  643. }
  644. .ant-btn-red {
  645. position: relative;
  646. display: inline-block;
  647. background: #D0EEFF;
  648. border: 1px solid #99D3F5;
  649. border-radius: 4px;
  650. padding: 4px 12px;
  651. overflow: hidden;
  652. color: #1E88C7;
  653. text-decoration: none;
  654. text-indent: 0;
  655. line-height: 30px;
  656. font-size: 28px;
  657. margin: 5px 0 5px;
  658. }
  659. #land-btn-wrap{
  660. position: relative;
  661. width: 25%;
  662. left: 75%;
  663. bottom: 100%;
  664. z-index: 2000;
  665. padding-top: 5%;
  666. }
  667. .location-mode-chooser-btn {
  668. position: absolute;
  669. right: 0;
  670. bottom: 0;
  671. z-index: 2000;
  672. }
  673. </style>