移动端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

163 rader
5.0 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" style="display: none"></div>
  8. </div>
  9. </template>
  10. <script>
  11. import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
  12. import {getByLyZjddm } from "@/api/onlineHome/homestead/circulation";
  13. import $ from "jquery";
  14. export default {
  15. components: {
  16. getQueryLand,getByLyZjddm
  17. },
  18. data() {
  19. return {
  20. uuidMap: this.guidProduct(),
  21. map:this.guidProduct(),
  22. };
  23. },
  24. props: ['theGeom','message'],
  25. methods: {
  26. //地图加载
  27. guidProduct(){
  28. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  29. var r = Math.random() * 16 | 0,
  30. v = c == 'x' ? r : (r & 0x3 | 0x8);
  31. return v.toString(16);
  32. });
  33. },
  34. //地图查看
  35. drawingLyPaceCountryDarw() {
  36. //加载地图编辑
  37. var that = this;
  38. getByLyZjddm(that.message).then(qlrRes => {
  39. document.getElementById(that.uuidMap).innerHTML = '';
  40. var hc_land;
  41. var projection = new ol.proj.Projection({
  42. //地图投影类型
  43. code: "EPSG:3857",
  44. units: "degrees",
  45. //extent:extent
  46. });
  47. var aerial = new ol.layer.Tile({
  48. source: new ol.source.XYZ({
  49. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  50. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  51. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  52. }),
  53. isGroup: true,
  54. name: "卫星影像图",
  55. resolution:Math.random() * 0.00000001
  56. });
  57. var yingxzi = new ol.layer.Tile({
  58. source: new ol.source.XYZ({
  59. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  60. }),
  61. isGroup: true,
  62. name: "天地图文字标注--卫星影像图",
  63. resolution:Math.random() * 0.00000001
  64. });
  65. //加载地图
  66. that.map = new ol.Map({
  67. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
  68. layers: [aerial, yingxzi],
  69. projection: projection,
  70. target: that.uuidMap,
  71. view: new ol.View({
  72. //center: ol.proj.fromLonLat([115.452752, 31.789033]),
  73. zoom: 15,
  74. minZoom: 5, //地图缩小限制
  75. maxZoom: 18.3, //地图放大限制
  76. }),
  77. interactions: ol.interaction.defaults({
  78. pinchRotate: false // 移动端禁止地图旋转
  79. }),
  80. //view: new ol.View({ol.view.getResolution() + Math.random() * 0.00000001)});//随机数缩放实现刷新
  81. });
  82. //图层查询定位开始 ---------start
  83. hc_land = new ol.layer.Vector({
  84. title: "add Layer",
  85. source: new ol.source.Vector({
  86. projection: projection,
  87. features: new ol.format.GeoJSON().readFeatures("{\n" +
  88. " \"type\": \"Feature\",\n" +
  89. " \"geometry\":" + qlrRes.data.theGeom + "}"),
  90. }),
  91. resolution:Math.random() * 0.00000001,
  92. style: new ol.style.Style({
  93. fill: new ol.style.Fill({
  94. //矢量图层填充颜色,以及透明度
  95. color: "rgba(204, 255, 204,0.3)",
  96. }),
  97. stroke: new ol.style.Stroke({
  98. //边界样式
  99. color: "#CCFF66",
  100. width: 3,
  101. }),
  102. }),
  103. });
  104. that.map.addLayer(hc_land);
  105. var maxXMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxX;
  106. var maxYMap = hc_land.values_.source.featuresRtree_.rbush_.data.maxY;
  107. var minXMap = hc_land.values_.source.featuresRtree_.rbush_.data.minX;
  108. var minYMap = hc_land.values_.source.featuresRtree_.rbush_.data.minY;
  109. //定位查询位置
  110. var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置
  111. that.map.getView().animate({
  112. // 只设置需要的属性即可
  113. center: center, // 中心点
  114. zoom: 16.9, // 缩放级别
  115. rotation: undefined, // 缩放完成view视图旋转弧度
  116. duration: 1000, // 缩放持续时间,默认不需要设置
  117. resolution:Math.random() * 0.00000001,
  118. });
  119. });
  120. },
  121. },
  122. watch: {},
  123. };
  124. </script>
  125. <style scoped>
  126. #that.message {
  127. width: 100%;
  128. height: 100%;
  129. }
  130. .fuTitle {
  131. border-top: 1px solid #e9e9e9;
  132. text-align: center;
  133. padding: 10px 0px 0px 0px;
  134. font-size: 36px;
  135. color: #999;
  136. }
  137. .ant-btn-red {
  138. position: relative;
  139. display: inline-block;
  140. background: #D0EEFF;
  141. border: 1px solid #99D3F5;
  142. border-radius: 4px;
  143. padding: 4px 12px;
  144. overflow: hidden;
  145. color: #1E88C7;
  146. text-decoration: none;
  147. text-indent: 0;
  148. line-height: 20px;
  149. }
  150. #land-btn-wrap{
  151. position: absolute;
  152. right: 3%;
  153. top: 5%;
  154. z-index: 2000;
  155. }
  156. </style>