移动端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

1070 lignes
36 KiB

  1. <template>
  2. <div class="home_wrapper">
  3. <div class="map_main" id="mapWrap"></div>
  4. <div class="top_address" @click="showAddress=true">
  5. <i class="address_icon"></i>
  6. <p>{{deptName}}</p>
  7. </div>
  8. <!--选择当前区域弹窗-->
  9. <van-popup v-model="showAddress" position="bottom">
  10. <van-cascader
  11. v-model="villageValue"
  12. title="请选择"
  13. :options="addrOptions"
  14. @close="showAddress = false"
  15. @finish="onConfirmDept"
  16. active-color="#1989fa"
  17. :field-names="hcAreaInfoFieldName"
  18. />
  19. </van-popup>
  20. <!--当前区域详情弹窗-->
  21. <van-popup v-model="show" position="bottom" :overlay="false" round>
  22. <div class="pop_main">
  23. <div class="pop_title">
  24. <i class="address_icon"></i>
  25. <p>{{deptName}}</p>
  26. </div>
  27. <div class="pop_content">
  28. <div class="pop_content_left">
  29. <img src="../../../static/images/plotPremises/plotPremises_icon_01.png" alt="">
  30. <div class="pop_content_left_box">
  31. <div>
  32. <p>农房 <span>(栋)</span></p>
  33. <p class="num">{{detail.zzs}}</p>
  34. </div>
  35. <span class="border"></span>
  36. <div>
  37. <p>可租 <span>(栋)</span></p>
  38. <p class="num" @click="deptId == 100?'':(showList = true,activeName='nf')">{{detail.kzs}}</p>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="pop_content_left">
  43. <img src="../../../static/images/plotPremises/plotPremises_icon_02.png" alt="">
  44. <div class="pop_content_left_box">
  45. <div>
  46. <p>农地 <span>(亩)</span></p>
  47. <p class="num">{{detail.landArea}}</p>
  48. </div>
  49. <span class="border"></span>
  50. <div>
  51. <p>可租 <span>(亩)</span></p>
  52. <p class="num" @click="deptId == 100?'':(showList = true,activeName='nd')">{{detail.rentableArea}}</p>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </van-popup>
  59. <!--租地详情弹窗-->
  60. <van-popup v-model="showZD" closeable position="bottom" :closed="show=true" :overlay="false" round>
  61. <div class="pop_main">
  62. <div class="pop_title">
  63. <i class="address_icon"></i>
  64. <p>{{deptName}}-{{ndItem.id}}</p>
  65. </div>
  66. <div class="pop_content_zd">
  67. <img src="../../../static/images/plotPremises/plotPremises_img.png" alt="">
  68. <div class="pop_content_zd_right">
  69. <!-- <van-row type="flex" justify="space-between">
  70. <van-col>租地位置:</van-col>
  71. <van-col>{{deptName}}</van-col>
  72. </van-row> -->
  73. <van-row type="flex" justify="space-between">
  74. <van-col>租地编号:</van-col>
  75. <van-col class="num">{{ndItem.id}}</van-col>
  76. </van-row>
  77. <van-row type="flex" justify="space-between">
  78. <van-col>租地面积:</van-col>
  79. <van-col class="num">{{ndItem.scmjm}}亩</van-col>
  80. </van-row>
  81. <van-row type="flex" justify="space-between">
  82. <van-col>咨询代表:</van-col>
  83. <van-col>{{ deptInfo.leader }}</van-col>
  84. </van-row>
  85. <van-row type="flex" justify="space-between">
  86. <van-col>咨询电话:</van-col>
  87. <van-col class="num">{{ deptInfo.phone }}</van-col>
  88. </van-row>
  89. </div>
  90. </div>
  91. </div>
  92. </van-popup>
  93. <!--租房详情弹窗-->
  94. <van-popup v-model="showZF" closeable position="bottom" :closed="show=true" :overlay="false" round>
  95. <div class="pop_main">
  96. <div class="pop_title">
  97. <i class="address_icon"></i>
  98. <p>{{deptName}}-{{nfItem.id}}</p>
  99. </div>
  100. <div class="pop_content_zd">
  101. <img src="../../../static/images/plotPremises/plotPremises_img.png" alt="">
  102. <div class="pop_content_zd_right">
  103. <!-- <van-row type="flex" justify="space-between">
  104. <van-col>租房位置:</van-col>
  105. <van-col>{{deptName}}</van-col>
  106. </van-row> -->
  107. <van-row type="flex" justify="space-between">
  108. <van-col>租房编号:</van-col>
  109. <van-col class="num">{{nfItem.id}}</van-col>
  110. </van-row>
  111. <van-row type="flex" justify="space-between">
  112. <van-col>租房面积:</van-col>
  113. <van-col class="num">{{nfItem.zdmj}}㎡</van-col>
  114. </van-row>
  115. <van-row type="flex" justify="space-between">
  116. <van-col>咨询代表:</van-col>
  117. <van-col>{{ deptInfo.leader }}</van-col>
  118. </van-row>
  119. <van-row type="flex" justify="space-between">
  120. <van-col>咨询电话:</van-col>
  121. <van-col class="num">{{ deptInfo.phone }}</van-col>
  122. </van-row>
  123. </div>
  124. </div>
  125. </div>
  126. </van-popup>
  127. <!--农房农地右侧列表弹窗-->
  128. <van-popup v-model="showList" close-icon="../../../static/images/plotPremises/plotPremises_icon_03.png" closeable position="right" :closed="show=true" :overlay="false" round :style="{ width: '45%' , height: '60%' , background:'#ffffff' }">
  129. <div class="pop_main_right">
  130. <p class="pop_title" :style="{color:activeName=='nf'?'#1B65F8':'#FF7321'}">{{activeName=='nf'?'待租农房':'待租农地'}}</p>
  131. <div class="pop_content_right" v-if="activeName=='nf'">
  132. <van-row>
  133. <van-col span="12" class="num">编号</van-col>
  134. <van-col span="12" style="text-align: left;">面积(㎡)</van-col>
  135. </van-row>
  136. <!-- 待租农房列表 -->
  137. <van-row v-for="(item,index) in detail.rentableHomestead"
  138. :key="index"
  139. @click="listChange(index,'nf',item)"
  140. :class="{ active: selectChooseOrder == index }"
  141. align="center"
  142. >
  143. <van-col span="12" class="num">{{item.id}}</van-col>
  144. <van-col span="12" style="text-align: left;" class="num">{{item.zdmj}}</van-col>
  145. </van-row>
  146. </div>
  147. <div class="pop_content_right" v-else>
  148. <van-row>
  149. <van-col span="12" class="num">编号</van-col>
  150. <van-col span="12" style="text-align: left;">面积(亩)</van-col>
  151. </van-row>
  152. <!-- 待租农房列表 -->
  153. <van-row v-for="(item,index) in detail.rentableLand"
  154. :key="index"
  155. @click="listChange(index,'nd',item)"
  156. :class="{ active: selectChooseOrder == index }"
  157. align="center"
  158. >
  159. <van-col span="12" class="num">{{item.id}}</van-col>
  160. <van-col span="12" style="text-align: left;" class="num">{{item.scmjm}}</van-col>
  161. </van-row>
  162. </div>
  163. <div class="pop_btn_right">
  164. <p :style="{background:activeName=='nf'?'#1B65F8':'',color:activeName=='nf'?'#ffffff':''}" @click="tabChange('nf')">农房</p>
  165. <p :style="{background:activeName=='nd'?'#FF7321':'',color:activeName=='nd'?'#ffffff':''}" @click="tabChange('nd')">农地</p>
  166. </div>
  167. </div>
  168. </van-popup>
  169. <!-- <van-popup v-model="showAddress" position="bottom" round>-->
  170. <!-- <van-picker show-toolbar title="村镇选择" :columns="columns" />-->
  171. <!-- </van-popup>-->
  172. </div>
  173. </template>
  174. <script>
  175. import $ from "jquery";
  176. import { getConfigKey } from "@/utils/data";
  177. import { getDept , treeselect , plotPremisesStatistics } from "@/api/plotPremisesMobile";
  178. export default {
  179. data() {
  180. return {
  181. show:true,
  182. showZD:false,
  183. showZF:false,
  184. showList:false,
  185. showAddress:false,
  186. activeName:'nf',
  187. selectChooseOrder:-1,
  188. addrOptions: [],
  189. map: "", // 地图
  190. // countyBorder: "", // 区县边界
  191. // townBorder: "", // 乡镇边界
  192. // villageBorder: "", // 村边界
  193. borderLayer: "", // 区域边界图层
  194. deptLayer: "", // 坐标点图层
  195. userRole: "", // 记录用户身份
  196. cityId: null, // 记录市的deptId
  197. countyId: null, // 记录区县的deptId
  198. townId: null, // 记录乡镇的deptId
  199. currentDeptLevel: null, // 当前所处的部门级别
  200. mapGeoServerUrl: "", // 加载geoserver地址
  201. countyBorderLayerName: "", // 区县边界图层名称
  202. townBorderLayerName: "", // 乡镇边界图层名称
  203. villageBorderLayerName: "", // 村边界图层名称
  204. landLayer: "", // 地块图层
  205. homesteadLayer: "", // 宅基地图层
  206. selectedLayer: "", // 选中的图层
  207. deptInfo: {
  208. leader: null, // 联系人
  209. phone: null // 电话
  210. },
  211. deptName:'',
  212. deptId:'',
  213. detail:{},
  214. villageValue: "",
  215. hcAreaInfoFieldName: {
  216. text: "label",
  217. value: "value",
  218. children: "children",
  219. },
  220. deptOptions:[],
  221. nfItem:{},
  222. ndItem:{},
  223. };
  224. },
  225. created() {
  226. },
  227. mounted() {
  228. // 获取geoserver的地址
  229. this.getGeoServerUrl();
  230. // 获取区县边界图层名称
  231. this.getCountyBorderLayerName();
  232. // 获取乡镇边界的图层名称
  233. this.getTownBorderLayerName();
  234. // 获取村边界的图层名称
  235. this.getVillageBorderLayerName();
  236. // 获取部门下拉树列表
  237. treeselect().then(response => {
  238. this.addrOptions = response.data;
  239. this.deptId = response.data[0].id;
  240. this.deptName = response.data[0].label;
  241. // 初始化地图
  242. this.initMap();
  243. this.getData();
  244. });
  245. },
  246. methods: {
  247. getData(){
  248. plotPremisesStatistics({deptId:this.deptId}).then(response => {
  249. this.detail = response.data;
  250. });
  251. },
  252. onConfirmDept({ selectedOptions }){
  253. this.deptId = selectedOptions[selectedOptions.length-1].id;
  254. this.deptName = selectedOptions.map((option) => option.label).join('/');
  255. this.getData();
  256. this.showAddress = false;
  257. this.drawMap(selectedOptions);
  258. this.deptInfo.leader = null;
  259. this.deptInfo.phone = null;
  260. getDept(this.deptId).then(res => {
  261. this.deptInfo.leader = res.data.leader;
  262. this.deptInfo.phone = res.data.phone;
  263. });
  264. },
  265. tabChange(name){
  266. this.activeName = name;
  267. this.selectChooseOrder = -1;
  268. },
  269. listChange(id,type,data){
  270. this.selectChooseOrder = id;
  271. this.show = false;
  272. this.showZF = false;
  273. this.showZD = false;
  274. if (type=='nf') {
  275. this.showZF = true;
  276. this.nfItem = data;
  277. }
  278. if (type=='nd') {
  279. this.showZD = true;
  280. this.ndItem = data;
  281. }
  282. if (this.selectedLayer) {
  283. this.map.removeLayer(this.selectedLayer);
  284. this.selectedLayer = '';
  285. }
  286. if (data.theGeom) {
  287. this.selectedLayer = new ol.layer.Vector({
  288. source: new ol.source.Vector({
  289. features: new ol.format.GeoJSON().readFeatures("{\n" +
  290. " \"type\": \"Feature\",\n" +
  291. " \"geometry\":" + data.theGeom + ", \"properties\":" + JSON.stringify(data.id) + "}"),
  292. }),
  293. name: 'selectedLayer',
  294. style: new ol.style.Style({
  295. fill: new ol.style.Fill({
  296. //矢量图层填充颜色,以及透明度
  297. color: "rgba(255, 84, 87, 0.5)",
  298. }),
  299. stroke: new ol.style.Stroke({
  300. //边界样式
  301. color: "#ff5457",
  302. width: 2,
  303. }),
  304. }),
  305. });
  306. this.map.addLayer(this.selectedLayer);
  307. let center = ol.extent.getCenter(this.selectedLayer.getSource().getExtent());
  308. this.map.getView().animate({
  309. center: center, // 中心点
  310. zoom: 17, // 缩放级别
  311. rotation: undefined, // 缩放完成view视图旋转弧度
  312. duration: 500, // 缩放持续时间,默认不需要设置
  313. });
  314. }
  315. },
  316. //获取geoserver的地址
  317. getGeoServerUrl() {
  318. getConfigKey("system.geoServer.url").then(response => {
  319. this.mapGeoServerUrl = response.msg;
  320. });
  321. },
  322. //获取区县边界的图层名称
  323. getCountyBorderLayerName() {
  324. getConfigKey("geoserver.layer.countyBorder").then(response => {
  325. this.countyBorderLayerName = response.msg;
  326. });
  327. },
  328. //获取乡镇边界的图层名称
  329. getTownBorderLayerName() {
  330. getConfigKey("geoserver.layer.townBorder").then(response => {
  331. this.townBorderLayerName = response.msg;
  332. });
  333. },
  334. //获取村边界的图层名称
  335. getVillageBorderLayerName() {
  336. getConfigKey("geoserver.layer.villageBorder").then(response => {
  337. this.villageBorderLayerName = response.msg;
  338. });
  339. },
  340. // 初始化地图
  341. initMap() {
  342. const dept = this.addrOptions[0];
  343. // 定义地图中心坐标
  344. let mapCenterLocation;
  345. if (dept.lng && dept.lat) {
  346. mapCenterLocation = [dept.lng, dept.lat];
  347. } else {
  348. mapCenterLocation = [116.391458, 39.902377];
  349. }
  350. document.getElementById("mapWrap").innerHTML = "";
  351. // 定义地图投影
  352. let projection = new ol.proj.Projection({
  353. code: "EPSG:3857",
  354. units: "degrees",
  355. });
  356. // 定义地图图层
  357. let aerial = new ol.layer.Tile({
  358. source: new ol.source.XYZ({
  359. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  360. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  361. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  362. }),
  363. isGroup: true,
  364. name: "卫星影像图",
  365. });
  366. let yingxzi = new ol.layer.Tile({
  367. source: new ol.source.XYZ({
  368. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  369. }),
  370. isGroup: true,
  371. name: "天地图文字标注--卫星影像图",
  372. });
  373. //加载地图
  374. this.map = new ol.Map({
  375. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  376. layers: [aerial, yingxzi],
  377. projection: projection,
  378. target: "mapWrap",
  379. view: new ol.View({
  380. center: ol.proj.fromLonLat(mapCenterLocation), // 地图中心坐标
  381. zoom: 9.5,
  382. minZoom: 1, //地图缩小限制
  383. maxZoom: 18, //地图放大限制
  384. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  385. }),
  386. interactions: ol.interaction.defaults({
  387. doubleClickZoom: false, // 双击放大地图
  388. // mouseWheelZoom: false, // 鼠标滚轮放大地图
  389. // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
  390. })
  391. });
  392. if (dept.deptLevel === '5') {
  393. // 登录身份为市级领导
  394. this.userRole = 'cityLeader';
  395. this.cityId = dept.id;
  396. this.currentDeptLevel = '5';
  397. // 添加区县边界
  398. this.addCountyBorder();
  399. } else if (dept.deptLevel === '4') {
  400. // 登录身份为县级领导
  401. this.userRole = 'countyLeader';
  402. this.countyId = dept.id;
  403. this.currentDeptLevel = '4';
  404. // 添加乡镇边界
  405. this.addTownBorder(dept.id);
  406. this.map.getView().setZoom(10.5);
  407. }
  408. // else if (dept.deptLevel === '3') {
  409. // // 登录身份为镇级领导
  410. // this.userRole = 'townLeader';
  411. // this.townId = dept.id;
  412. // this.currentDeptLevel = '3';
  413. // // 添加村边界
  414. // this.addVillageBorder(dept.id);
  415. // this.map.getView().setZoom(12.5);
  416. // }
  417. if (dept.children) {
  418. this.addDeptLayer(dept.children);
  419. }
  420. this.map.on("click", (evt) => {
  421. let feature = this.map.forEachFeatureAtPixel(
  422. evt.pixel,
  423. (feature) => feature
  424. );
  425. if (feature) {
  426. // 镇级:加载村级坐标点
  427. if (feature.get('level') === 'deptPoint') {
  428. const deptId = feature.get('deptId');
  429. const deptLevel = feature.get('deptLevel');
  430. const lng = feature.get('lng');
  431. const lat = feature.get('lat');
  432. if (deptLevel === '4' || deptLevel === '3') {
  433. if (deptLevel === '4') {
  434. this.countyId = deptId;
  435. this.currentDeptLevel = '4';
  436. this.map.removeLayer(this.borderLayer);
  437. this.borderLayer = '';
  438. // 添加乡镇边界
  439. this.addTownBorder(deptId);
  440. this.map.getView().animate({
  441. center: ol.proj.fromLonLat([lng, lat]), // 中心点
  442. zoom: 10.5, // 缩放级别
  443. rotation: undefined, // 缩放完成view视图旋转弧度
  444. duration: 1000, // 缩放持续时间,默认不需要设置
  445. });
  446. } else if (deptLevel === '3') {
  447. this.townId = deptId;
  448. this.currentDeptLevel = '3';
  449. this.map.removeLayer(this.borderLayer);
  450. this.borderLayer = '';
  451. // 添加村边界
  452. const cqlFilter = "parent_id = '" + deptId + "'";
  453. this.addVillageBorder(cqlFilter);
  454. this.map.getView().animate({
  455. center: ol.proj.fromLonLat([lng, lat]), // 中心点
  456. zoom: 12.5, // 缩放级别
  457. rotation: undefined, // 缩放完成view视图旋转弧度
  458. duration: 1000, // 缩放持续时间,默认不需要设置
  459. });
  460. }
  461. const deptNode = this.findNode(this.addrOptions, deptId);
  462. if (deptNode && deptNode.children) {
  463. this.map.removeLayer(this.deptLayer);
  464. this.deptLayer = '';
  465. this.addDeptLayer(deptNode.children);
  466. }
  467. } else if (deptLevel === '2') {
  468. this.deptId = deptId;
  469. this.getData();
  470. let parentNodes = [];
  471. this.findParentNode(this.addrOptions, deptId, parentNodes);
  472. this.villageValue = deptId;
  473. this.deptName = parentNodes.map(node => node.label).join('/');
  474. this.currentDeptLevel = '2';
  475. this.map.removeLayer(this.borderLayer);
  476. this.borderLayer = '';
  477. // 添加村边界
  478. const cqlFilter = "dept_id = '" + deptId + "'";
  479. this.addVillageBorder(cqlFilter);
  480. let villagePoint = {
  481. id: deptId,
  482. label: feature.get('deptName'),
  483. lng: lng,
  484. lat: lat,
  485. deptLevel: deptLevel,
  486. };
  487. let depts = [];
  488. depts.push(villagePoint);
  489. this.map.removeLayer(this.deptLayer);
  490. this.deptLayer = '';
  491. this.addDeptLayer(depts);
  492. this.addLandLayer(deptId);
  493. this.addHomesteadLayer(deptId);
  494. this.map.getView().animate({
  495. center: ol.proj.fromLonLat([lng, lat]), // 中心点
  496. zoom: 17, // 缩放级别
  497. rotation: undefined, // 缩放完成view视图旋转弧度
  498. duration: 1000, // 缩放持续时间,默认不需要设置
  499. });
  500. getDept(deptId).then(res => {
  501. this.deptInfo.leader = res.data.leader;
  502. this.deptInfo.phone = res.data.phone;
  503. });
  504. }
  505. }
  506. } else {
  507. const viewResolution = this.map.getView().getResolution();
  508. const url1 = this.landLayer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json'});
  509. if (url1) {
  510. this.fetchUrl(url1);
  511. }
  512. const url2 = this.homesteadLayer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json'});
  513. if (url2) {
  514. this.fetchUrl(url2);
  515. }
  516. }
  517. });
  518. // 缩小地图,重新加载页面
  519. this.map.on("moveend", (evt) => {
  520. const zoom = this.map.getView().getZoom();
  521. if (this.userRole === 'cityLeader') {
  522. if (this.currentDeptLevel === '2' && zoom < 13) {
  523. this.currentDeptLevel = '3';
  524. this.map.removeLayer(this.borderLayer);
  525. this.borderLayer = "";
  526. const cqlFilter = "parent_id = '" + this.townId + "'";
  527. this.addVillageBorder(cqlFilter);
  528. this.map.removeLayer(this.deptLayer);
  529. this.deptLayer = "";
  530. const deptNode = this.findNode(this.addrOptions, this.townId);
  531. if (deptNode && deptNode.children) {
  532. this.addDeptLayer(deptNode.children);
  533. }
  534. this.map.removeLayer(this.landLayer);
  535. this.landLayer = "";
  536. this.map.removeLayer(this.homesteadLayer);
  537. this.homesteadLayer = "";
  538. if (this.selectedLayer) {
  539. this.map.removeLayer(this.selectedLayer);
  540. this.selectedLayer = "";
  541. }
  542. this.deptInfo.leader = null;
  543. this.deptInfo.phone = null;
  544. } else if (this.currentDeptLevel === '3' && zoom < 11) {
  545. this.currentDeptLevel = '4';
  546. this.map.removeLayer(this.borderLayer);
  547. this.borderLayer = "";
  548. this.addTownBorder(this.countyId);
  549. this.map.removeLayer(this.deptLayer);
  550. this.deptLayer = "";
  551. const deptNode = this.findNode(this.addrOptions, this.countyId);
  552. if (deptNode && deptNode.children) {
  553. this.addDeptLayer(deptNode.children);
  554. }
  555. } else if (this.currentDeptLevel === '4' && zoom < 9.5) {
  556. this.currentDeptLevel = '5';
  557. this.map.removeLayer(this.borderLayer);
  558. this.borderLayer = "";
  559. this.addCountyBorder();
  560. this.map.removeLayer(this.deptLayer);
  561. this.deptLayer = "";
  562. const deptNode = this.findNode(this.addrOptions, this.cityId);
  563. if (deptNode && deptNode.children) {
  564. this.addDeptLayer(deptNode.children);
  565. }
  566. }
  567. } else if (this.userRole === 'countyLeader') {
  568. if (this.currentDeptLevel === '2' && zoom < 13) {
  569. this.currentDeptLevel = '3';
  570. this.map.removeLayer(this.borderLayer);
  571. this.borderLayer = "";
  572. const cqlFilter = "parent_id = '" + this.townId + "'";
  573. this.addVillageBorder(cqlFilter);
  574. this.map.removeLayer(this.deptLayer);
  575. this.deptLayer = "";
  576. const deptNode = this.findNode(this.addrOptions, this.townId);
  577. if (deptNode && deptNode.children) {
  578. this.addDeptLayer(deptNode.children);
  579. }
  580. this.map.removeLayer(this.landLayer);
  581. this.landLayer = "";
  582. this.map.removeLayer(this.homesteadLayer);
  583. this.homesteadLayer = "";
  584. if (this.selectedLayer) {
  585. this.map.removeLayer(this.selectedLayer);
  586. this.selectedLayer = "";
  587. }
  588. this.deptInfo.leader = null;
  589. this.deptInfo.phone = null;
  590. } else if (this.currentDeptLevel === '3' && zoom < 11) {
  591. this.currentDeptLevel = '4';
  592. this.map.removeLayer(this.borderLayer);
  593. this.borderLayer = "";
  594. this.addTownBorder(this.countyId);
  595. this.map.removeLayer(this.deptLayer);
  596. this.deptLayer = "";
  597. const deptNode = this.findNode(this.addrOptions, this.countyId);
  598. if (deptNode && deptNode.children) {
  599. this.addDeptLayer(deptNode.children);
  600. }
  601. }
  602. }
  603. });
  604. },
  605. findNode(tree, deptId) {
  606. for (const node of tree) {
  607. if (node.id === deptId) return node;
  608. if (node.children) {
  609. const res = this.findNode(node.children, deptId);
  610. if (res) return res;
  611. }
  612. }
  613. return null;
  614. },
  615. findParentNode(tree, deptId, result) {
  616. for (let node of tree) {
  617. if (node.id === deptId) {
  618. result.unshift(node);
  619. return true;
  620. }
  621. if (node.children && node.children.length > 0) {
  622. let isFind = this.findParentNode(node.children, deptId, result);
  623. if (isFind) {
  624. result.unshift(node);
  625. return true;
  626. }
  627. }
  628. }
  629. return false;
  630. },
  631. fetchUrl(url) {
  632. fetch(url)
  633. .then(response => response.json())
  634. .then(data => {
  635. if (data.features.length > 0) {
  636. let arr = data.features[0].id.split(".");
  637. let tableName = arr[0];
  638. let id = arr[1];
  639. this.show = false;
  640. this.showList = false;
  641. this.showZF = false;
  642. this.showZD = false;
  643. if (tableName.startsWith("t_homestead_zjdzdxx")) {
  644. this.showZF = true;
  645. this.nfItem = {
  646. id: id,
  647. zdmj: data.features[0].properties.ZDMJ,
  648. };
  649. }
  650. if (tableName.startsWith("t_sys_dk")) {
  651. this.showZD = true;
  652. this.ndItem = {
  653. id: id,
  654. scmjm: data.features[0].properties.SCMJM,
  655. };
  656. }
  657. if (this.selectedLayer) {
  658. this.map.removeLayer(this.selectedLayer);
  659. this.selectedLayer = "";
  660. }
  661. this.selectedLayer = new ol.layer.Vector({
  662. source: new ol.source.Vector({
  663. features: new ol.format.GeoJSON().readFeatures(data)
  664. }),
  665. name: 'selectedLayer',
  666. style: new ol.style.Style({
  667. fill: new ol.style.Fill({
  668. //矢量图层填充颜色,以及透明度
  669. color: "rgba(255, 84, 87, 0.3)",
  670. }),
  671. stroke: new ol.style.Stroke({
  672. //边界样式
  673. color: "#ff5457",
  674. width: 3,
  675. }),
  676. })
  677. });
  678. this.map.addLayer(this.selectedLayer);
  679. // this.map.getLayers().insertAt(4, this.selectedHomesteadLayer);
  680. }
  681. });
  682. },
  683. // 添加区县边界
  684. addCountyBorder() {
  685. this.borderLayer = new ol.layer.Image({
  686. source: new ol.source.ImageWMS({
  687. url: this.mapGeoServerUrl + '/wms',
  688. params: {
  689. LAYERS: this.countyBorderLayerName,
  690. SRID: 3857,
  691. }
  692. }),
  693. name: 'countyBorderLayer'
  694. });
  695. this.map.getLayers().insertAt(2, this.borderLayer);
  696. },
  697. // 添加乡镇边界
  698. addTownBorder(deptId) {
  699. this.borderLayer = new ol.layer.Image({
  700. source: new ol.source.ImageWMS({
  701. url: this.mapGeoServerUrl + "/wms",
  702. params: {
  703. LAYERS: this.townBorderLayerName,
  704. // TILED: true,
  705. cql_filter: "parent_id = '" + deptId + "'",
  706. SRID: 3857,
  707. },
  708. }),
  709. name: 'townBorderLayer'
  710. });
  711. this.map.getLayers().insertAt(2, this.borderLayer);
  712. },
  713. // 添加村边界
  714. addVillageBorder(cqlFilter) {
  715. this.borderLayer = new ol.layer.Image({
  716. source: new ol.source.ImageWMS({
  717. url: this.mapGeoServerUrl + '/wms',
  718. params: {
  719. LAYERS: this.villageBorderLayerName,
  720. cql_filter: cqlFilter,
  721. SRID: 3857,
  722. },
  723. }),
  724. name: 'villageBorderLayer'
  725. });
  726. this.map.getLayers().insertAt(2, this.borderLayer);
  727. },
  728. // 创建矢量数据源
  729. addDeptLayer(depts) {
  730. const createFeatureStyle = function(feature) {
  731. return new ol.style.Style({
  732. image: new ol.style.Icon({
  733. //设置图标偏移
  734. anchor: [0.5, 1],
  735. //标注样式的起点位置
  736. anchorOrigin: "top-right",
  737. //X方向单位:分数
  738. anchorXUnits: "fraction",
  739. //Y方向单位:像素
  740. anchorYUnits: "pixels",
  741. //偏移起点位置的方向
  742. offsetOrigin: "top-right",
  743. //透明度
  744. opacity: 0.9,
  745. // rotation: (Math.PI / 180) * 20,
  746. //图片路径
  747. src: require("../../assets/images/plotPremises/mark.png"),
  748. }),
  749. text: new ol.style.Text({
  750. textAlign: "center", //位置
  751. textBaseline: "bottom", //基准线
  752. font: "normal 14px 微软雅黑", //文字样式
  753. text: feature.get("deptName"), //文本内容
  754. fill: new ol.style.Fill({
  755. //文本填充样式(即文字颜色)
  756. color: "#ffffff",
  757. }),
  758. }),
  759. });
  760. };
  761. let features = [];
  762. for (let i = 0; i < depts.length; i++) {
  763. let feature = new ol.Feature({
  764. geometry: new ol.geom.Point(
  765. ol.proj.fromLonLat([depts[i].lng, depts[i].lat])
  766. ),
  767. deptId: depts[i].id,
  768. deptName: depts[i].label,
  769. // orgCode: depts[i].orgCode,
  770. lat: depts[i].lat,
  771. lng: depts[i].lng,
  772. deptLevel: depts[i].deptLevel,
  773. level: 'deptPoint',
  774. });
  775. // 创建下级部门坐标点
  776. feature.setStyle(createFeatureStyle(feature));
  777. features.push(feature);
  778. }
  779. const vectorSource = new ol.source.Vector({
  780. features: features,
  781. });
  782. // 创建矢量图层
  783. this.deptLayer = new ol.layer.Vector({
  784. source: vectorSource,
  785. name: 'deptLayer'
  786. });
  787. // this.map.addLayer(this.deptLayer);
  788. this.map.getLayers().insertAt(3, this.deptLayer);
  789. },
  790. // 添加地块图层
  791. addLandLayer(deptId) {
  792. this.landLayer = new ol.layer.Image({
  793. source: new ol.source.ImageWMS({
  794. url: "http://218.59.175.43:8090/geoserver/zjd_dc/wms", // 测试用的geoserver服务器链接,正式使用时需要换掉
  795. params: {
  796. LAYERS: "zjd_dc:t_sys_dk_mobile", // 测试用的图层,正式使用时要换成自己发布的图层
  797. cql_filter: "dept_id = '" + deptId + "'",
  798. SRID: 3857,
  799. }
  800. }),
  801. name: 'landLayer'
  802. });
  803. this.map.addLayer(this.landLayer);
  804. // this.map.getLayers().insertAt(3, this.landLayer);
  805. },
  806. // 添加宅基地图层
  807. addHomesteadLayer(deptId) {
  808. this.homesteadLayer = new ol.layer.Image({
  809. source: new ol.source.ImageWMS({
  810. url: "http://218.59.175.43:8090/geoserver/zjd_dc/wms", // 测试用的geoserver服务器链接,正式使用时需要换掉
  811. params: {
  812. LAYERS: "zjd_dc:t_homestead_zjdzdxx_mobile", // 测试用的图层,正式使用时要换成自己发布的图层
  813. cql_filter: "dept_id = '" + deptId + "'",
  814. SRID: 3857,
  815. }
  816. }),
  817. name: 'homesteadLayer'
  818. });
  819. this.map.addLayer(this.homesteadLayer);
  820. // this.map.getLayers().insertAt(3, this.homesteadLayer);
  821. },
  822. drawMap(selectedOptions) {
  823. const villageNode = selectedOptions[selectedOptions.length - 1];
  824. const ids = selectedOptions.map(option => option.id);
  825. this.currentDeptLevel = '2';
  826. this.townId = ids[ids.length - 2];
  827. this.countyId = ids[ids.length - 3];
  828. this.map.removeLayer(this.borderLayer);
  829. this.borderLayer = '';
  830. // 添加村边界
  831. const cqlFilter = "dept_id = '" + villageNode.id + "'";
  832. this.addVillageBorder(cqlFilter);
  833. let villagePoint = {
  834. id: villageNode.id,
  835. label: villageNode.label,
  836. lng: villageNode.lng,
  837. lat: villageNode.lat,
  838. deptLevel: villageNode.deptLevel,
  839. };
  840. let depts = [];
  841. depts.push(villagePoint);
  842. this.map.removeLayer(this.deptLayer);
  843. this.deptLayer = '';
  844. this.addDeptLayer(depts);
  845. if (this.landLayer) {
  846. this.map.removeLayer(this.landLayer);
  847. this.landLayer = '';
  848. }
  849. if (this.homesteadLayer) {
  850. this.map.removeLayer(this.homesteadLayer);
  851. this.homesteadLayer = '';
  852. }
  853. if (this.selectedLayer) {
  854. this.map.removeLayer(this.selectedLayer);
  855. this.selectedLayer = "";
  856. }
  857. this.addLandLayer(villageNode.id);
  858. this.addHomesteadLayer(villageNode.id);
  859. this.map.getView().animate({
  860. center: ol.proj.fromLonLat([villageNode.lng, villageNode.lat]), // 中心点
  861. zoom: 17, // 缩放级别
  862. rotation: undefined, // 缩放完成view视图旋转弧度
  863. duration: 1000, // 缩放持续时间,默认不需要设置
  864. });
  865. },
  866. },
  867. };
  868. </script>
  869. <style scoped lang="scss">
  870. .home_wrapper {
  871. background: #e9e9e9;
  872. min-height: 100vh;
  873. width: 100vw;
  874. }
  875. .num{
  876. font-family: Arial;
  877. }
  878. .map_main{
  879. width: 100%;
  880. height: 100vh;
  881. /*background: url("../../../static/images/plotPremises/map_bg.png") no-repeat center;*/
  882. /*background-size: 100%;*/
  883. }
  884. /deep/ .van-popup{
  885. background: #F1F0F5;
  886. }
  887. /deep/ .van-popup--right{
  888. top: 35%;
  889. .van-icon__image{
  890. width: .7em;
  891. height: .7em;
  892. display: block;
  893. }
  894. }
  895. .top_address{
  896. display: flex;
  897. align-items: center;
  898. position: absolute;
  899. top: 5vh;
  900. left: 3vw;
  901. padding: 1vh 2vh;
  902. background: #ffffff;
  903. border-radius: 5vh;
  904. p{font-size: 1.5vh}
  905. }
  906. .address_icon {
  907. width: 13PX;
  908. height: 17PX;
  909. background: url("../../../static/images/plotPremises/positioning.png") no-repeat;
  910. background-size: 100% 100%;
  911. margin-right: 1vw;
  912. }
  913. .pop_main{
  914. padding: 2vh 3vw;
  915. .pop_title{
  916. display: flex;
  917. align-items: center;
  918. font-size: 2.2vh;
  919. line-height: 1;
  920. }
  921. .pop_content{
  922. display: flex;
  923. justify-content: space-between;
  924. margin-top: 2vh;
  925. .pop_content_left{
  926. background: #ffffff;
  927. width: 48%;
  928. padding: 1.5vh 3vw;
  929. border-radius: 15PX;
  930. .pop_content_left_box{
  931. display: flex;
  932. justify-content: space-between;
  933. margin-top: .5vh;
  934. .border{
  935. border-left: 2PX dashed #DFDFDF;
  936. }
  937. div{
  938. p{
  939. &:first-child{
  940. font-size: 2vh;
  941. color: #797979;
  942. span{
  943. font-size: 1.5vh;
  944. }
  945. }
  946. &:last-child{
  947. font-size: 4vw;
  948. color: #333333;
  949. }
  950. }
  951. &:last-child{
  952. p:last-child{
  953. color: #1B65F8;
  954. }
  955. }
  956. }
  957. }
  958. }
  959. }
  960. .pop_content_zd{
  961. background: #ffffff;
  962. border-radius: 15PX;
  963. display: flex;
  964. justify-content: space-between;
  965. margin-top: 2vh;
  966. overflow: hidden;
  967. img{width: 40%;}
  968. .pop_content_zd_right{
  969. width: 60%;
  970. padding:1.5vh 2.5vh;
  971. font-size: 1.8vh;
  972. display: flex;
  973. flex-direction: column;
  974. justify-content: space-between;
  975. }
  976. }
  977. }
  978. .pop_main_right{
  979. .pop_title{
  980. font-size: 2.2vh;
  981. color: #1B65F8;
  982. padding: 1.5vh;
  983. }
  984. .pop_content_right{
  985. font-size: 1.8vh;
  986. height: 48vh;
  987. overflow-y: scroll;
  988. .active{
  989. box-shadow:0px 0px 5px #999999;
  990. }
  991. .van-row{
  992. padding: 1vh 0;
  993. }
  994. .num{text-align: center;}
  995. }
  996. .pop_btn_right{
  997. display: flex;
  998. width: 100%;
  999. position: absolute;
  1000. bottom: 0;
  1001. p{
  1002. padding: 1.5vh 0;
  1003. text-align: center;
  1004. font-size: 2vh;
  1005. flex: 1;
  1006. background: #E1E0E4;
  1007. color: #9F9F9F;
  1008. }
  1009. }
  1010. }
  1011. </style>