移动端
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.
 
 

265 line
10 KiB

  1. <template>
  2. <div>
  3. <p class="fuTitle">地块位置</p>
  4. <div id="full-screen-acceptance" style="width: 100%;height:45vh;position:relative;">
  5. <div :id=this.uuidMap style="width: 100%;height: 100%"></div>
  6. </div>
  7. <!-- <div id="info" > <button type="button" @click="showHistoryDown">保 存</button></div>-->
  8. </div>
  9. </template>
  10. <script>
  11. import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
  12. import {selectTHouseBaseObligeeMapList} from "@/api/onlineHome/homestead/circulation";
  13. import {getByLyZjddm } from "@/api/onlineHome/homestead/circulation";
  14. import $ from "jquery";
  15. export default {
  16. components: {
  17. getQueryLand,getByLyZjddm
  18. },
  19. data() {
  20. return {
  21. uuidMap: this.guidProduct(),
  22. map:this.guidProduct(),
  23. showHistoryTable: false,
  24. closeMoule: null,
  25. };
  26. },
  27. props: ['theGeom','shqrxm'],
  28. methods: {
  29. //地图加载
  30. guidProduct(){
  31. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  32. var r = Math.random() * 16 | 0,
  33. v = c == 'x' ? r : (r & 0x3 | 0x8);
  34. return v.toString(16);
  35. });
  36. },
  37. //地图查看
  38. drawingLyPaceCountryDarw() {
  39. //加载地图编辑
  40. var that = this;
  41. console.info(this.shqrxm);
  42. selectTHouseBaseObligeeMapList({shyqrdbxm:this.shqrxm}).then((response) => {
  43. if (response.code == 200) {
  44. document.getElementById(that.uuidMap).innerHTML = '';
  45. var hc_land;
  46. var projection = new ol.proj.Projection({
  47. //地图投影类型
  48. code: "EPSG:3857",
  49. units: "degrees",
  50. //extent:extent
  51. });
  52. var aerial = new ol.layer.Tile({
  53. source: new ol.source.XYZ({
  54. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  55. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  56. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  57. }),
  58. isGroup: true,
  59. name: "卫星影像图",
  60. resolution:Math.random() * 0.00000001
  61. });
  62. var yingxzi = new ol.layer.Tile({
  63. source: new ol.source.XYZ({
  64. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  65. }),
  66. isGroup: true,
  67. name: "天地图文字标注--卫星影像图",
  68. resolution:Math.random() * 0.00000001
  69. });
  70. //加载地图
  71. that.map = new ol.Map({
  72. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
  73. layers: [aerial, yingxzi],
  74. projection: projection,
  75. target: that.uuidMap,
  76. view: new ol.View({
  77. //center: ol.proj.fromLonLat([115.452752, 31.789033]),
  78. zoom: 15,
  79. minZoom: 5, //地图缩小限制
  80. maxZoom: 18.3, //地图放大限制
  81. }),
  82. interactions: ol.interaction.defaults({
  83. pinchRotate: false // 移动端禁止地图旋转
  84. }),
  85. //view: new ol.View({ol.view.getResolution() + Math.random() * 0.00000001)});//随机数缩放实现刷新
  86. });
  87. if (response.data.length > 0) {
  88. //setTimeout(() => {
  89. for (var i = 0; response.data.length > i; i++) {
  90. //图层查询定位开始 ---------start
  91. console.log( response.data[i].zjdzd.theGeom);
  92. hc_land = new ol.layer.Vector({
  93. title: "add Layer",
  94. source: new ol.source.Vector({
  95. projection: projection,
  96. features: new ol.format.GeoJSON().readFeatures("{\n" +
  97. " \"type\": \"Feature\",\n" +
  98. " \"geometry\":" + response.data[i].zjdzd.theGeom + ", " +
  99. " \"properties\":" + JSON.stringify(response.data[i]) + "}"),
  100. }),
  101. resolution:Math.random() * 0.00000001,
  102. style: new ol.style.Style({
  103. fill: new ol.style.Fill({
  104. //矢量图层填充颜色,以及透明度
  105. color: "rgba(204, 255, 204,0.3)",
  106. }),
  107. stroke: new ol.style.Stroke({
  108. //边界样式
  109. color: "#CCFF66",
  110. width: 3,
  111. }),
  112. }),
  113. });
  114. that.map.addLayer(hc_land);
  115. var maxXMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxX;
  116. var maxYMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxY;
  117. var minXMap = hc_land.values_.source.featuresRtree_.rbush_.data.minX;
  118. var minYMap = hc_land.values_.source.featuresRtree_.rbush_.data.minY;
  119. //定位查询位置
  120. var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置
  121. that.map.getView().animate({
  122. // 只设置需要的属性即可
  123. center: center, // 中心点
  124. zoom: 16.9, // 缩放级别
  125. rotation: undefined, // 缩放完成view视图旋转弧度
  126. duration: 1000, // 缩放持续时间,默认不需要设置
  127. resolution:Math.random() * 0.00000001,
  128. });
  129. }
  130. } else { // 加载全部地图,不带宅基地图斑
  131. let deptName = this.$store.state.user.loginDeptId + "";
  132. getQueryLand(deptName).then((response) => {
  133. if (response.code == 200) {
  134. let InsertCode = response.data;
  135. if (InsertCode != null) {
  136. let lat = InsertCode.lat;
  137. let lng = InsertCode.lng;
  138. let center;
  139. if(lat !=null && lng !=null && lat !="" && lng !=""){
  140. center = [lng,lat];
  141. }else {
  142. center = [115.452752, 31.789033];
  143. }
  144. that.map.getView().animate({
  145. // 只设置需要的属性即可
  146. center: ol.proj.fromLonLat(center), // 中心点
  147. zoom: 17.9, // 缩放级别
  148. rotation: undefined, // 缩放完成view视图旋转弧度
  149. duration: 1000, // 缩放持续时间,默认不需要设置
  150. });
  151. }
  152. }
  153. });
  154. }
  155. var geo_zjdzd;
  156. that.map.on("singleclick", function (evt) {
  157. let feature = that.map.forEachFeatureAtPixel(
  158. evt.pixel,
  159. (feature) => feature
  160. );
  161. //document.getElementById(that.uuidMap).innerHTML = '';
  162. if (feature && (feature !==undefined)) {
  163. that.map.removeLayer(geo_zjdzd);
  164. var aleft = [];
  165. for(var i=0;i<feature.values_.geometry.flatCoordinates.length;i++){
  166. aleft.push("["+feature.values_.geometry.flatCoordinates[i]+","+feature.values_.geometry.flatCoordinates[i+1] +"]")
  167. i = i+1;
  168. }
  169. var aright = "[[["+aleft +"]]]";
  170. var geoThegeom = "{\"type\": \"MultiPolygon\", \"coordinates\": "+aright + "}";
  171. this.closeMoule= null;
  172. //图层查询定位开始 ---------start
  173. geo_zjdzd = new ol.layer.Vector({
  174. title: "add Layer",
  175. source: new ol.source.Vector({
  176. projection: projection,
  177. features: new ol.format.GeoJSON().readFeatures("{\n" +
  178. " \"type\": \"Feature\",\n" +
  179. " \"geometry\":" + geoThegeom + "}"),
  180. }),
  181. resolution:Math.random() * 0.00000001,
  182. style: new ol.style.Style({
  183. fill: new ol.style.Fill({
  184. //矢量图层填充颜色,以及透明度
  185. color: "rgb(204, 255, 255,0.5)",
  186. }),
  187. stroke: new ol.style.Stroke({
  188. //边界样式
  189. color: "#00FFFF",
  190. width: 3,
  191. }),
  192. }),
  193. });
  194. that.map.addLayer(geo_zjdzd);
  195. //that.closeMoule = feature.values_.zjddm;
  196. that.$emit('closeMoule', feature.values_.zjddm);
  197. var maxXMap = geo_zjdzd.values_.source.featuresRtree_.rbush_.data.maxX;
  198. var maxYMap = geo_zjdzd.values_.source.featuresRtree_.rbush_.data.maxY;
  199. var minXMap = geo_zjdzd.values_.source.featuresRtree_.rbush_.data.minX;
  200. var minYMap = geo_zjdzd.values_.source.featuresRtree_.rbush_.data.minY;
  201. //定位查询位置
  202. var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置
  203. that.map.getView().animate({
  204. // 只设置需要的属性即可
  205. center: center, // 中心点
  206. zoom: 16.9, // 缩放级别
  207. rotation: undefined, // 缩放完成view视图旋转弧度
  208. duration: 1000, // 缩放持续时间,默认不需要设置
  209. resolution:Math.random() * 0.00000001,
  210. });
  211. }
  212. });
  213. }
  214. });
  215. },
  216. showHistoryDown() {
  217. this.showHistoryTable = false;
  218. this.$emit('closeMoule', this.closeMoule);
  219. this.closeMoule = null;
  220. },
  221. },
  222. watch: {},
  223. };
  224. </script>
  225. <style scoped>
  226. #that.message {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. .fuTitle {
  231. border-top: 1px solid #e9e9e9;
  232. text-align: center;
  233. padding: 10px 0px 0px 0px;
  234. font-size: 36px;
  235. color: #999;
  236. }
  237. .ant-btn-red {
  238. position: relative;
  239. display: inline-block;
  240. background: #D0EEFF;
  241. border: 1px solid #99D3F5;
  242. border-radius: 4px;
  243. padding: 4px 12px;
  244. overflow: hidden;
  245. color: #1E88C7;
  246. text-decoration: none;
  247. text-indent: 0;
  248. line-height: 20px;
  249. }
  250. #land-btn-wrap{
  251. position: absolute;
  252. right: 3%;
  253. top: 5%;
  254. z-index: 2000;
  255. }
  256. </style>