管理系统PC端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

map.vue 32 KiB

3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
3ヶ月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. <template>
  2. <div class="app-container">
  3. <van-nav-bar
  4. title="土地列表管理"
  5. left-arrow
  6. placeholder
  7. safe-area-inset-top
  8. @click-left="onClickLeft"
  9. />
  10. <div class="search_box">
  11. <div class="left">
  12. <van-field v-model="keyword" left-icon="search" placeholder="请输入用户名" />
  13. </div>
  14. <van-button type="primary" round @click="searchMap" >搜索</van-button>
  15. </div>
  16. <div class="location" :id="locationMap">
  17. <img src="../../assets/images/app/location.png" alt="">
  18. </div>
  19. <div id="full-screen-acceptance" style="width: 100%;height:100vh;">
  20. <!--<div id="landMapDiv"></div>-->
  21. <div id="landMapBox"></div>
  22. <!-- <div id='land-btn-wrap'>-->
  23. <!-- <el-row>-->
  24. <!-- <input id="drawPolygon" class="ant-btn ant-btn-red" type="button" value="画图"/>&nbsp;&nbsp;-->
  25. <!-- &lt;!&ndash; <input id="drawRemove" type="button" class="ant-btn ant-btn-red" value="取消画图"/>&nbsp;&nbsp; &ndash;&gt;-->
  26. <!-- <input id="drawReset" type="button" class="ant-btn ant-btn-red" value="还原"/>-->
  27. <!-- </el-row>-->
  28. <!-- </div>-->
  29. </div>
  30. <van-popup v-model="open" position="bottom" round >
  31. <div class="landPopup">
  32. <p class="landPopup_title">属性数据 <img @click="$router.push({name:'appAttributeEdit',query:{fid:form.fid}})" src="../../assets/images/app/edit.png" width="25" alt=""></p>
  33. <van-field readonly v-model="form.deptName" label="区域位置名称" placeholder="请输入" input-align="right" label-width="auto" />
  34. <van-field readonly v-model="form.bsm" label="标识码" placeholder="请输入" input-align="right" label-width="auto" />
  35. <van-field readonly v-model="form.ysdm" label="要素代码" placeholder="请输入" input-align="right" label-width="auto" />
  36. <van-field readonly v-model="form.dkbm" label="地块代码" placeholder="请输入" input-align="right" label-width="auto" />
  37. <van-field readonly v-model="form.dkmc" label="地块名称" placeholder="请输入" input-align="right" label-width="auto" />
  38. <van-field readonly v-model="form.syqxz" label="所有权性质" placeholder="请输入" input-align="right" label-width="auto" />
  39. <van-field readonly v-model="form.dklb" label="地块类别" placeholder="请输入" input-align="right" label-width="auto" />
  40. <van-field readonly v-model="form.tdlylx" label="土地利用类型" placeholder="请输入" input-align="right" label-width="auto" />
  41. <van-field readonly v-model="form.dldj" label="地力等级" placeholder="请输入" input-align="right" label-width="auto" />
  42. <van-field readonly v-model="form.tdyt" label="土地用途" placeholder="请输入" input-align="right" label-width="auto" />
  43. <van-field readonly v-model="form.sfjbnt" label="是否基本农田" placeholder="请输入" input-align="right" label-width="auto" />
  44. <van-field readonly v-model="form.dkdz" label="地块东至" placeholder="请输入" input-align="right" label-width="auto" />
  45. <van-field readonly v-model="form.dkxz" label="地块西至" placeholder="请输入" input-align="right" label-width="auto" />
  46. <van-field readonly v-model="form.dknz" label="地块南至" placeholder="请输入" input-align="right" label-width="auto" />
  47. <van-field readonly v-model="form.dkbz" label="地块北至" placeholder="请输入" input-align="right" label-width="auto" />
  48. <van-field readonly v-model="form.dkbzxx" label="备注信息" placeholder="请输入" input-align="right" label-width="auto" />
  49. <van-field readonly v-model="form.zjrxm" label="指界人姓名" placeholder="请输入" input-align="right" label-width="auto" />
  50. <van-field readonly v-model="form.txmj" label="图显面积" placeholder="请输入" input-align="right" label-width="auto" />
  51. <van-field readonly v-model="form.scmjm" label="实测面积" placeholder="请输入" input-align="right" label-width="auto" />
  52. <van-field readonly v-model="form.sfzwd" label="是否账外地" placeholder="请输入" input-align="right" label-width="auto" />
  53. <p class="landPopup_title">经营数据 <img @click="$router.push({name:'appOperateEdit',query:{dkbm:form.dkbm}})" src="../../assets/images/app/edit.png" width="25" alt=""></p>
  54. <van-field readonly v-model="form.jymj" label="经营面积(亩)" placeholder="请输入" input-align="right" label-width="auto" />
  55. <van-field readonly v-model="form.jyfs" label="经营方式" placeholder="请输入" input-align="right" label-width="auto" />
  56. <van-field readonly v-model="form.jydxmc" label="经营对象名称" placeholder="请输入" input-align="right" label-width="auto" />
  57. <van-field readonly v-model="form.jykssj" label="经营开始时间" placeholder="请输入" input-align="right" label-width="auto" />
  58. <van-field readonly v-model="form.jyjssj" label="经营结束时间" placeholder="请输入" input-align="right" label-width="auto" />
  59. <van-field readonly v-model="form.cbje" label="承包金额(元)" placeholder="请输入" input-align="right" label-width="auto" />
  60. <van-field readonly v-model="form.surveyStatus" label="调查状态" placeholder="请输入" input-align="right" label-width="auto" />
  61. <van-field readonly v-model="form.bzxx" label="备注信息" placeholder="请输入" input-align="right" label-width="auto" />
  62. <van-field readonly label="实物图" placeholder="" input-align="right" label-width="auto" />
  63. <div v-if="!!form.dkImg">
  64. <el-tooltip effect="light" :content="item" placement="bottom" v-for="(item, index) in form.dkImg.split(',')" :key="index">
  65. <el-image style="height: 64px; width: 64px; margin: 2px; display: inline-block;" fit="scale-down" :src="baseRoutingUrll + item" :preview-src-list="form.dkImg.split(',').map((x) => baseRoutingUrll + x)"/>
  66. </el-tooltip>
  67. </div>
  68. <div class="footer_main">
  69. <van-button type="danger" @click="open = false" hairline size="large">关闭弹窗</van-button>
  70. </div>
  71. </div>
  72. </van-popup>
  73. </div>
  74. </template>
  75. <script>
  76. import { listLandQuery, getLandDetailByDkbm } from "@/api/resource/land"
  77. import {getConfigKey} from "@/api/system/config";
  78. import {getDept} from "@/api/system/dept";
  79. import {Toast} from "vant";
  80. import $ from "jquery";
  81. import Cookies from "js-cookie";
  82. export default {
  83. name: "appMap",
  84. components: { },
  85. data() {
  86. return {
  87. baseRoutingUrll:'/api',
  88. form: {}, // 地块信息表单参数
  89. map: "", // 地图
  90. mapGeoServerUrl: "", // geoserver地址
  91. mapCenterLocation: [], // 地图中心坐标
  92. landLayerName: "", // 地块图层名称
  93. landLayer: "", // 地块图层
  94. mapBorder: "", // 地图边界
  95. villageBorderLayerName: "", // 乡镇边界图层名称
  96. vectorLayer: "", // 绘制的矢量图层
  97. title: "", // 弹出层标题
  98. open: false, // 是否显示地块弹出层
  99. syqxzOptions: [], // 所有权性质字典
  100. syqxzText: null, // 所有权性质标签名
  101. showOwnership: false, // 控制所有权性质字典弹出层的显示和隐藏
  102. dklbOptions: [], // 地块类别字典
  103. dklbText: null, // 地块类别标签名
  104. showLandCategory: false, // 控制的地块类别字典弹出层的显示和隐藏
  105. dldjOptions: [], // 地力等级字典
  106. dldjText: null, // 地力等级标签名
  107. showLandGrade: false, // 控制地力等级字典弹出层的显示和隐藏
  108. tdytOptions: [], // 土地用途字典
  109. tdytText: null, // 土地用途标签名
  110. showLandPurpose: false, // 控制土地用途字典弹出层的显示和隐藏
  111. tdlylxOptions: [], // 土地利用类型
  112. tdlylxText: null, // 土地利用类型标签名
  113. showLandType: false, // 控制土地利用类型字典弹出层的显示和隐藏
  114. sfjbntOptions: [], // 是否基本农田字典
  115. showSaveBtn: false, // 控制保存按钮的显示隐藏
  116. showDeleteBtn: false, // 控制删除按钮的显示隐藏
  117. // isDisabled: false, // 是否禁用
  118. taskStatus: null, // 调查任务的完成状态:1表示已完成,2表示未完成
  119. landCategory: ['10'], // 地块类别
  120. showLegend:true,
  121. value:'',
  122. deptId:100,
  123. importCode:'',
  124. keyword:'',
  125. locationMap: this.guidProduct(),
  126. selectedHomesteadLayer: "",
  127. };
  128. },
  129. computed: {
  130. isAndroid() {
  131. return !!window._Native_object;
  132. },
  133. hasSelectLocationMode() {
  134. return this.isAndroid && typeof(window._Native_object.SelectLocationMode) === 'function';
  135. },
  136. hasGetLocationTimeout() {
  137. return this.isAndroid && typeof(window._Native_object.GetLocationTimeout) === 'function';
  138. },
  139. hasGetLocationMode() {
  140. return this.isAndroid && typeof(window._Native_object.GetLocationMode) === 'function';
  141. },
  142. },
  143. created() {
  144. this.deptId = Cookies.get('userDept');
  145. this.importCode = Cookies.get('importCode');
  146. // 获取geoserver的地址
  147. this.getGeoServerUrl();
  148. // 获取地块图层名称
  149. this.getLandLayerName();
  150. // 获取村边界的图层名称
  151. this.getVillageBorderLayerName();
  152. },
  153. mounted() {
  154. // 初始化地图
  155. listLandQuery().then(response => {
  156. setTimeout(() => {
  157. this.initMap(response.rows);
  158. }, 500);
  159. });
  160. },
  161. methods: {
  162. onClickLeft(){
  163. history.back(-1);
  164. },
  165. // 获取geoserver的地址
  166. getGeoServerUrl() {
  167. getConfigKey("system.geoServer.url").then(response => {
  168. this.mapGeoServerUrl = response.msg;
  169. });
  170. },
  171. // 获取地块图层名称
  172. getLandLayerName() {
  173. getConfigKey("geoserver.layer.resourceLand").then(response => {
  174. this.landLayerName = response.msg;
  175. });
  176. },
  177. // 获取村边界的图层名称
  178. getVillageBorderLayerName() {
  179. getConfigKey("geoserver.layer.villageBorder").then(response => {
  180. this.villageBorderLayerName = response.msg;
  181. });
  182. },
  183. guidProduct(){
  184. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  185. var r = Math.random() * 16 | 0,
  186. v = c == 'x' ? r : (r & 0x3 | 0x8);
  187. return v.toString(16);
  188. });
  189. },
  190. // 初始化地图
  191. initMap(resourceList) {
  192. getDept(this.deptId).then(response => {
  193. let dept = response.data;
  194. if (dept.longitude && dept.latitude) {
  195. this.mapCenterLocation = [dept.longitude, dept.latitude];
  196. } else {
  197. this.mapCenterLocation = [116.391458, 39.902377];
  198. }
  199. document.getElementById("landMapBox").innerHTML = "";
  200. // 定义地图投影
  201. let projection = new ol.proj.Projection({
  202. code: "EPSG:3857",
  203. units: "degrees",
  204. });
  205. // 定义地图图层
  206. let aerial = new ol.layer.Tile({
  207. source: new ol.source.XYZ({
  208. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  209. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  210. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  211. }),
  212. isGroup: true,
  213. name: "卫星影像图",
  214. });
  215. let yingxzi = new ol.layer.Tile({
  216. source: new ol.source.XYZ({
  217. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  218. }),
  219. isGroup: true,
  220. name: "天地图文字标注--卫星影像图",
  221. });
  222. //加载地图
  223. this.map = new ol.Map({
  224. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  225. layers: [aerial, yingxzi],
  226. projection: projection,
  227. target: "landMapBox",
  228. view: new ol.View({
  229. center: ol.proj.fromLonLat(this.mapCenterLocation), // 地图中心坐标
  230. zoom: 14,
  231. minZoom: 1, //地图缩小限制
  232. maxZoom: 18, //地图放大限制
  233. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  234. }),
  235. });
  236. // // 添加村边界
  237. this.addVillageBorder();
  238. // 添加地块图层
  239. this.addLandLayer();
  240. // 绘制地块
  241. $("#drawLandPolygon").click(() => {
  242. // 创建矢量数据源
  243. let vectorSource = new ol.source.Vector({
  244. wrapX: false,
  245. });
  246. // 创建矢量图层
  247. this.vectorLayer = new ol.layer.Vector({
  248. source: vectorSource,
  249. });
  250. // 添加图层
  251. this.map.addLayer(this.vectorLayer);
  252. // 地图交互-绘制图形
  253. let drawInteraction = new ol.interaction.Draw({
  254. source: vectorSource,
  255. type: "Polygon",
  256. });
  257. // 添加交互
  258. this.map.addInteraction(drawInteraction);
  259. drawInteraction.on('drawend', (evt) => {
  260. // 移除交互
  261. this.map.removeInteraction(drawInteraction);
  262. let coordinates = evt.feature.getGeometry().getCoordinates();
  263. this.reset();
  264. this.form.theGeom = JSON.stringify(coordinates);
  265. this.title = "添加地块信息";
  266. this.showSaveBtn = true;
  267. this.showDeleteBtn = false;
  268. // this.isDisabled = false;
  269. setTimeout(() => {
  270. this.open = true;
  271. }, 10);
  272. });
  273. });
  274. var mark_layer = null;
  275. function addMark(lng, lat) {
  276. if(!mark_layer)
  277. {
  278. mark_layer = new ol.layer.Vector({
  279. source: new ol.source.Vector(),
  280. });
  281. that.map.addLayer(mark_layer);
  282. }
  283. else
  284. mark_layer.getSource().clear();
  285. let newFeature = new ol.Feature({
  286. geometry: new ol.geom.Point(ol.proj.fromLonLat([lng, lat])), //几何信息
  287. //name: "标注点",
  288. });
  289. newFeature.setStyle(new ol.style.Style({
  290. image: new ol.style.Icon({
  291. //设置图标偏移
  292. anchor: [0.5, 0.5],
  293. //标注样式的起点位置
  294. anchorOrigin: "top-right",
  295. //X方向单位:分数
  296. anchorXUnits: "fraction",
  297. //Y方向单位:像素
  298. anchorYUnits: "fraction",
  299. //偏移起点位置的方向
  300. offsetOrigin: "top-right",
  301. //透明度
  302. opacity: 0.9,
  303. //图片路径
  304. src: require('../../assets/images/app/mark.png'),
  305. }),
  306. zIndex: 9999,
  307. }));
  308. mark_layer.getSource().addFeature(newFeature);
  309. }
  310. var that = this;
  311. var Zb;
  312. $("#" + this.locationMap).click(function () {
  313. that.getCurrentLocation(res => {
  314. if (res.code == 200) {
  315. let lat = res.data.lat;
  316. let lng = res.data.lng;
  317. if(lat && lng){
  318. Zb = [lng,lat];
  319. }else {
  320. Zb =[115.452752, 31.789033];
  321. }
  322. addMark(lng,lat);
  323. that.map.getView().animate({
  324. // 只设置需要的属性即可
  325. center: ol.proj.fromLonLat(Zb), // 中心点
  326. zoom: 18, // 缩放级别
  327. rotation: undefined, // 缩放完成view视图旋转弧度
  328. duration: 1000, // 缩放持续时间,默认不需要设置
  329. });
  330. }
  331. });
  332. });
  333. // 地图点击事件
  334. this.map.on("click", (evt) => {
  335. // 点击宅基地查看详情
  336. console.log(this.landLayer)
  337. if (this.landLayer) {
  338. const viewResolution = this.map.getView().getResolution();
  339. const url = this.landLayer.getSource()
  340. .getFeatureInfoUrl(evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json'});
  341. console.log(url)
  342. if (url) {
  343. fetch(url)
  344. .then(response => response.json())
  345. .then(data => {
  346. if (data.features.length > 0) {
  347. let id = data.features[0].properties.DKBM;
  348. getLandDetailByDkbm(id).then(response => {
  349. this.form = response.data;
  350. setTimeout(() => {
  351. this.open = true;
  352. }, 500);
  353. });
  354. if (this.selectedHomesteadLayer) {
  355. this.map.removeLayer(this.selectedHomesteadLayer);
  356. this.selectedHomesteadLayer = "";
  357. }
  358. this.selectedHomesteadLayer = new ol.layer.Vector({
  359. source: new ol.source.Vector({
  360. features: new ol.format.GeoJSON().readFeatures(data)
  361. }),
  362. name: 'selectedHomesteadLayer',
  363. style: new ol.style.Style({
  364. fill: new ol.style.Fill({
  365. //矢量图层填充颜色,以及透明度
  366. color: "rgba(255,0,17,0.3)",
  367. }),
  368. stroke: new ol.style.Stroke({
  369. //边界样式
  370. color: "#ff0000",
  371. width: 3,
  372. }),
  373. })
  374. });
  375. this.map.addLayer(this.selectedHomesteadLayer);
  376. this.map.getLayers().insertAt(4, this.selectedHomesteadLayer);
  377. // getLandDetail(id).then(response => {
  378. // // this.form = response.data;
  379. // getLandDetailByDkbm(response.data.dkbm).then(res => {
  380. // res.data.txmj = response.data.txmj;
  381. // this.form = res.data;
  382. // });
  383. // // getOperationDetailByDkbm(response.data.dkbm).then(response => {
  384. // // this.form = response.data
  385. // // })
  386. // setTimeout(() => {
  387. // this.open = true;
  388. // }, 500);
  389. // });
  390. }
  391. });
  392. }
  393. }
  394. });
  395. });
  396. },
  397. filterLandLayer() {
  398. if (this.landLayer) {
  399. this.map.removeLayer(this.landLayer);
  400. this.landLayer = "";
  401. }
  402. this.addLandLayer();
  403. },
  404. getLocationMode() {
  405. let mode = '';
  406. if(this.hasGetLocationMode)
  407. {
  408. mode = window._Native_object.GetLocationMode();
  409. }
  410. console.log('当前选择定位模式: ' + mode);
  411. return mode;
  412. },
  413. getLocationTimeout() {
  414. let timeout = 10000;
  415. if(this.hasGetLocationMode)
  416. {
  417. let to = window._Native_object.GetLocationTimeout();
  418. if(to <= 0)
  419. to = 30000;
  420. timeout = to;
  421. }
  422. console.log('当前选择定位超时: ' + timeout);
  423. return timeout;
  424. },
  425. getCurrentLocation(callback) {
  426. // 1. 首先尝试Android宿主端
  427. if(this.isAndroid) // Android层注入全局对象
  428. {
  429. let mode = this.getLocationMode();
  430. if(mode !== 'h5')
  431. {
  432. console.log('使用Native获取定位');
  433. let coord = window._Native_object.GetLocation(null);
  434. console.log('Native坐标: ' + coord);
  435. if(coord)
  436. {
  437. let arr = coord.split(',');
  438. let res = {
  439. code: 200,
  440. data: {
  441. lng: arr[0],
  442. lat: arr[1],
  443. },
  444. };
  445. callback(res);
  446. return;
  447. }
  448. }
  449. }
  450. // 2. 再尝试浏览器
  451. if (navigator.geolocation) {
  452. console.log('使用浏览器获取定位');
  453. const loading = Toast.loading({
  454. message: '定位中...',
  455. duration: 0,
  456. });
  457. let timeout = this.getLocationTimeout();
  458. navigator.geolocation.getCurrentPosition(
  459. (position) => {
  460. const { latitude, longitude } = position.coords;
  461. console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
  462. let res = {
  463. code: 200,
  464. data: {
  465. lng: longitude,
  466. lat: latitude,
  467. },
  468. };
  469. loading.clear();
  470. callback(res);
  471. },
  472. (error) => {
  473. loading.clear();
  474. console.log('定位失败: ' + error.message);
  475. getQueryLand().then(callback);
  476. },
  477. { enableHighAccuracy: true, timeout: timeout }
  478. );
  479. return;
  480. }
  481. // 最后使用地区坐标
  482. console.log('使用地区坐标定位');
  483. getQueryLand().then(callback);
  484. },
  485. // 添加地块图层
  486. addLandLayer() {
  487. this.landLayer = new ol.layer.Image({
  488. source: new ol.source.ImageWMS({
  489. url: this.mapGeoServerUrl + '/wms',
  490. params: {
  491. LAYERS: this.landLayerName,
  492. cql_filter: "import_code = '" + this.importCode + "'",
  493. SRID: 3857,
  494. abc: Math.random() // 无效参数,保证每次发送的请求都不一样
  495. }
  496. }),
  497. name: 'landLayer'
  498. });
  499. this.map.getLayers().insertAt(3, this.landLayer);
  500. // this.map.addLayer(this.landLayer);
  501. },
  502. // 添加村边界
  503. addVillageBorder() {
  504. this.mapBorder = new ol.layer.Image({
  505. source: new ol.source.ImageWMS({
  506. url: this.mapGeoServerUrl + '/wms',
  507. params: {
  508. LAYERS: this.villageBorderLayerName,
  509. cql_filter: "import_code = '" + this.importCode + "'",
  510. SRID: 3857,
  511. },
  512. }),
  513. name: 'villageBorderLayer'
  514. });
  515. this.map.getLayers().insertAt(2, this.mapBorder);
  516. },
  517. reset() {
  518. this.form = {
  519. deptId: null,
  520. dkbm: null,
  521. dkmc: null,
  522. syqxz: '30',
  523. dklb: '99',
  524. tdlylx: '01',
  525. dldj: '01',
  526. tdyt: '1',
  527. sfjbnt: '1',
  528. scmjm: null,
  529. zjrxm: null,
  530. dkdz: null,
  531. dkxz: null,
  532. dknz: null,
  533. dkbz: null,
  534. dkbzxx: null,
  535. theGeom: null
  536. };
  537. this.syqxzText = '集体土地所有权';
  538. this.dklbText = '其他集体土地';
  539. this.tdlylxText = '【1】耕地';
  540. this.dldjText = '一等地';
  541. this.tdytText = '种植业';
  542. },
  543. // 根据搜索条件查询宅基地
  544. searchMap() {
  545. if (this.keyword) {
  546. if (this.selectedHomesteadLayer) {
  547. this.map.removeLayer(this.selectedHomesteadLayer);
  548. this.selectedHomesteadLayer = "";
  549. }
  550. let map_cql_filter = "DKBM = '" + this.keyword + "'";
  551. // 定位查询位置
  552. let param_dw = {
  553. // srsName: "EPSG:3857",
  554. service: "WFS",
  555. version: "1.0.0",
  556. request: "GetFeature",
  557. typename: this.landLayerName,
  558. // maxFeatures:1000,
  559. cql_filter: map_cql_filter,
  560. outputFormat: "application/json",
  561. };
  562. let url_dw = this.mapGeoServerUrl + "/ows"; //wfsurl;
  563. url_dw = url_dw + "?";
  564. for (let key in param_dw) {
  565. url_dw = url_dw + key + "=" + param_dw[key] + "&";
  566. }
  567. url_dw = url_dw.substr(0, url_dw.length - 1);
  568. fetch(url_dw, {
  569. method: "GET", // *GET, POST, PUT, DELETE, etc.
  570. }).then((res) => {
  571. return res.json();
  572. }).then((data) => {
  573. if (data.features.length > 0) {
  574. this.selectedHomesteadLayer = new ol.layer.Vector({
  575. source: new ol.source.Vector({
  576. features: new ol.format.GeoJSON().readFeatures(data)
  577. }),
  578. name: 'selectedHomesteadLayer',
  579. style: new ol.style.Style({
  580. fill: new ol.style.Fill({
  581. //矢量图层填充颜色,以及透明度
  582. color: "rgba(255,0,17,0.3)",
  583. }),
  584. stroke: new ol.style.Stroke({
  585. //边界样式
  586. color: "#ff0000",
  587. width: 3,
  588. }),
  589. })
  590. });
  591. this.map.addLayer(this.selectedHomesteadLayer);
  592. this.map.getLayers().insertAt(4, this.selectedHomesteadLayer);
  593. let resolution = this.map.getView().getResolutionForExtent(data.bbox, this.map.getSize());
  594. this.map.getView().fit(data.bbox);
  595. this.map.getView().setResolution(resolution);
  596. // this.map.getView().setZoom(16);
  597. } else {
  598. this.msgError("没有搜索到该用户的宅基地")
  599. }
  600. });
  601. }
  602. }
  603. },
  604. };
  605. </script>
  606. <style scoped lang="scss">
  607. ::v-deep .van-nav-bar{
  608. background: linear-gradient( 173deg, #91E2D3 0%, #CDFCF0 100%);
  609. ::v-deep.van-icon{
  610. color: #000000;
  611. }
  612. }
  613. .location{
  614. display: flex;
  615. align-items: center;
  616. justify-content: center;
  617. width: 50px;
  618. height: 50px;
  619. margin: 2vh;
  620. position: absolute;
  621. top: 12vh;
  622. right: 0vw;
  623. z-index: 9;
  624. background-color: rgba(0,0,0,0.5);
  625. border-radius: 10px;
  626. img{
  627. width: 30px;
  628. height: 30px;
  629. border: 1px dashed #ffffff;
  630. }
  631. }
  632. .van-popup{
  633. background: linear-gradient( 180deg, #E5FFF4 0%, #ffffff 100%);
  634. .landPopup{
  635. width: 94%;
  636. margin: 0 auto;
  637. .landPopup_title{
  638. color: #29D2AF;
  639. font-size: 20px;
  640. display: flex;
  641. align-items: center;
  642. justify-content: space-between;
  643. }
  644. }
  645. }
  646. .app-container{
  647. /*background: #fff url("../../../../../static/images/contracted/contracted_index_bg.png") no-repeat center;*/
  648. background-size: 100% 100%;
  649. height: 100vh;
  650. padding: 0;
  651. overflow: hidden;
  652. }
  653. ::v-deep .van-hairline--bottom::after{
  654. border: none;
  655. }
  656. ::v-deep .van-field--disabled .van-field__label {
  657. color: #646566;
  658. }
  659. ::v-deep .landPopup .van-dialog {
  660. width: 90%;
  661. height: 85%;
  662. overflow-y: auto;
  663. }
  664. ::v-deep .landPopup .van-field__label {
  665. width: 7em;
  666. }
  667. .head{
  668. padding: 0 4vw;
  669. }
  670. .tap_block{
  671. width: 100%;
  672. display: flex;
  673. justify-content: space-between;
  674. background: #ebfaf2;
  675. padding: 2PX 4PX;
  676. border-radius: 10PX;
  677. margin-top: 1vh;
  678. .active{
  679. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  680. box-shadow: 0 0 10PX #cccccc;
  681. color: #333333;
  682. }
  683. p{
  684. width: 25%;
  685. text-align: center;
  686. padding: 5PX 0;
  687. border-radius: 10PX;
  688. color: #666666;
  689. }
  690. }
  691. .legend_main{
  692. position: absolute;
  693. top: 2vh;
  694. right: 2vw;
  695. }
  696. .openLegend{
  697. position: absolute;
  698. top: 2vh;
  699. right: 0vw;
  700. background-color: rgba(255,255,255,.5);
  701. width: 20PX;
  702. height: 70PX;
  703. display: flex;
  704. align-items: center;
  705. justify-content: center;
  706. border-top-left-radius: 10PX;
  707. border-bottom-left-radius: 10PX;
  708. .sanjiao-left {
  709. display: inline-block;
  710. border-right: 8PX solid #999999;
  711. border-right-color: initial;
  712. border-top: 5PX solid transparent;
  713. border-bottom: 5PX solid transparent;
  714. }
  715. }
  716. .legend_second{
  717. background: rgba(255,255,255,.5);
  718. padding: 2vh;
  719. border-radius: 10PX;
  720. margin-top: 2vh;
  721. }
  722. .legend_tt{
  723. font-size: 16PX;
  724. display: flex;
  725. align-items: center;
  726. justify-content: space-between;
  727. img{
  728. width: 20PX;
  729. }
  730. }
  731. .legend{
  732. background: rgba(255,255,255,.5);
  733. padding: 2vh;
  734. border-radius: 10PX;
  735. .van-checkbox{
  736. margin-top: 2vh;
  737. &:nth-child(1){
  738. ::v-deep .van-checkbox__icon .van-icon{
  739. /*border-color: rgba(22,233,15,1);*/
  740. border: 4px solid #16E90F;
  741. }
  742. }
  743. &:nth-child(2){
  744. ::v-deep .van-checkbox__icon .van-icon{
  745. /*border-color: rgba(1,198,222,1);*/
  746. border: 4px solid #01C6DE;
  747. }
  748. }
  749. &:nth-child(3){
  750. ::v-deep .van-checkbox__icon .van-icon{
  751. /*border-color: rgba(238,238,0,1);*/
  752. border: 4px solid #EEEE00;
  753. }
  754. }
  755. &:nth-child(4){
  756. ::v-deep .van-checkbox__icon .van-icon{
  757. /*border-color: rgba(238,60,60,1);*/
  758. border: 4px solid #EE3C3C;
  759. }
  760. }
  761. &:nth-child(5){
  762. ::v-deep .van-checkbox__icon .van-icon{
  763. /*border-color: rgba(235,134,0,1);*/
  764. border: 4px solid #EB8600;
  765. }
  766. }
  767. }
  768. .van-checkbox-group {
  769. .van-checkbox__label{
  770. i{
  771. display: block;
  772. width: 15PX;
  773. height: 15PX;
  774. border: 1px solid;
  775. border-radius: 3PX;
  776. margin-left: 10PX;
  777. }
  778. .i1{
  779. background: rgba(22,233,15,.7);
  780. border-color: rgba(22,233,15,1);
  781. }
  782. .i2{
  783. background: rgba(1,198,222,.7);
  784. border-color: rgba(1,198,222,1);
  785. }
  786. .i3{
  787. background: rgba(238,238,0,.7);
  788. border-color: rgba(238,238,0,1);
  789. }
  790. .i4{
  791. background: rgba(238,60,60,.7);
  792. border-color: rgba(238,60,60,1);
  793. }
  794. .i5{
  795. background: rgba(235,134,0,.7);
  796. border-color: rgba(235,134,0,1);
  797. }
  798. div{
  799. display: flex;
  800. align-items: center;
  801. }
  802. }
  803. }
  804. }
  805. .mapBox{
  806. height: 100vh;
  807. width: 100%;
  808. }
  809. .footer_main {
  810. flex: 0 0 120px;
  811. background: #ccc;
  812. display: flex;
  813. justify-content: center; /* 相对父元素水平居中 */
  814. align-items: center; /* 子元素相对父元素垂直居中 */
  815. }
  816. .search_box{
  817. display: flex;
  818. align-items: center;
  819. justify-content: space-between;
  820. width: 94%;
  821. margin: 2vh auto;
  822. position: absolute;
  823. left: 3vw;
  824. z-index: 9;
  825. .left{
  826. display: flex;
  827. align-items: center;
  828. flex: 1;
  829. background-color: #ffffff;
  830. border-radius: 50vh;
  831. overflow: hidden;
  832. margin-right: 3vw;
  833. }
  834. p{
  835. flex-shrink: 0;
  836. }
  837. button{
  838. flex-shrink: 0;
  839. background: linear-gradient( 271deg, #53E4A5 0%, #24DBDB 100%);
  840. border: none;
  841. width: 20vw;
  842. }
  843. }
  844. #land-btn-wrap {
  845. position: relative;
  846. width: 40%;
  847. left: 60%;
  848. bottom: 95%;
  849. z-index: 2000;
  850. }
  851. #landMapBox {
  852. width: 100%;
  853. height: 100%;
  854. }
  855. .ant-btn-red {
  856. position: relative;
  857. display: inline-block;
  858. background: #D0EEFF;
  859. border: 1px solid #99D3F5;
  860. border-radius: 4px;
  861. padding: 4px 12px;
  862. overflow: hidden;
  863. color: #1E88C7;
  864. text-decoration: none;
  865. text-indent: 0;
  866. line-height: 20px;
  867. right: -36%;
  868. }
  869. </style>