网站
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.
 
 
 

156 lines
6.0 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "paging", 'dateTime', 'swiper'], function ($, template, Tools) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. propertyList:'',
  9. map: '', // 地图图层
  10. },
  11. };
  12. var tools = new Tools();
  13. module.init = function (page) {
  14. tools.doGet(resourceGet+getQueryVariable('id'), {translate_dict: 1}, module.assetDetail , true);
  15. tools.doGet(webList, {}, module.webList , true);
  16. // var map = new BMapGL.Map('container'); // 创建Map实例
  17. // map.centerAndZoom(new BMapGL.Point(116.320938,39.950026), 18); // 初始化地图,设置中心点坐标和地图级别
  18. // map.enableScrollWheelZoom(false); // 开启鼠标滚轮缩放
  19. };
  20. module.useContent = function (data) {
  21. if (data.code == 200) {
  22. module.data.phone = data.data.phone;
  23. module.data.leader = data.data.leader;
  24. var propertyDetailData = template('propertyDetailData', module.data);
  25. $("#propertyDetailContent").html(propertyDetailData);
  26. setTimeout(() => {
  27. initMap(data.data);
  28. }, 500);
  29. }
  30. }
  31. initMap = function (dept) {
  32. document.getElementById("container").innerHTML = "";
  33. // 定义地图投影
  34. let projection = new ol.proj.Projection({
  35. code: "EPSG:3857",
  36. units: "degrees",
  37. });
  38. // 定义地图图层
  39. let aerial = new ol.layer.Tile({
  40. source: new ol.source.XYZ({
  41. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  42. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  43. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  44. }),
  45. isGroup: true,
  46. name: "卫星影像图",
  47. });
  48. let yingxzi = new ol.layer.Tile({
  49. source: new ol.source.XYZ({
  50. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  51. }),
  52. isGroup: true,
  53. name: "天地图文字标注--卫星影像图",
  54. });
  55. //加载地图
  56. module.data.map = new ol.Map({
  57. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  58. layers: [aerial, yingxzi],
  59. projection: projection,
  60. target: "container",
  61. view: new ol.View({
  62. center: ol.proj.fromLonLat([dept.lng, dept.lat]), // 地图中心坐标
  63. zoom: 16,
  64. minZoom: 1, //地图缩小限制
  65. maxZoom: 18, //地图放大限制
  66. }),
  67. /*interactions: ol.interaction.defaults({
  68. doubleClickZoom: false, // 双击放大地图
  69. // mouseWheelZoom: false, // 鼠标滚轮放大地图
  70. // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
  71. })*/
  72. });
  73. if (module.data.propertyDetail && module.data.propertyDetail.theGeomJson) {
  74. const resourceDetail = new ol.layer.Vector({
  75. source: new ol.source.Vector({
  76. features: new ol.format.GeoJSON().readFeatures(module.data.propertyDetail.theGeomJson),
  77. }),
  78. name: 'resourceDetail',
  79. style: new ol.style.Style({
  80. fill: new ol.style.Fill({
  81. //矢量图层填充颜色,以及透明度
  82. color: "rgba(255, 255, 0, 0.3)",
  83. }),
  84. stroke: new ol.style.Stroke({
  85. //边界样式
  86. color: "#ffff00",
  87. width: 2,
  88. }),
  89. })
  90. });
  91. module.data.map.addLayer(resourceDetail);
  92. module.data.map.getView().setCenter(ol.extent.getCenter(resourceDetail.getSource().getExtent()));
  93. }
  94. }
  95. module.webList = function (data) {
  96. if (data.code == 200) {
  97. var content = data.data;
  98. module.data.webList = content;
  99. var webData = template('webData', module.data);
  100. $("#webContent").html(webData);
  101. var titData = template('titData', module.data);
  102. $("#titContent").html(titData);
  103. }
  104. }
  105. module.assetDetail = function(data){
  106. if (data.code == 200) {
  107. var content = data.data;
  108. module.data.propertyDetail = content;
  109. tools.doGet(attachmentList, {
  110. tableId:content.id,
  111. tableName: 't_asset_resource',
  112. bizPath: 'asset'
  113. }, module.attachmentDetail , true);
  114. tools.doGet(treeselectSecond+content.deptId, {}, module.useContent , true);
  115. // var propertyDetailData = template('propertyDetailData', module.data);
  116. // $("#propertyDetailContent").html(propertyDetailData);
  117. // $('#dialog').css('display','block');
  118. }
  119. }
  120. module.attachmentDetail = function(data){
  121. if (data.code == 200) {
  122. var content = data.rows;
  123. var attachmentList = [];
  124. content.map(res=>{
  125. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  126. attachmentList.push(res);
  127. }
  128. })
  129. module.data.attachment = attachmentList;
  130. var propertyDetailData = template('propertyDetailData', module.data);
  131. $("#propertyDetailContent").html(propertyDetailData);
  132. $('#dialog').css('display','block');
  133. }
  134. }
  135. //获取地址栏参数
  136. function getQueryVariable(variable){
  137. var query = window.location.search.substring(1);
  138. var vars = query.split("&");
  139. for (var i=0;i<vars.length;i++) {
  140. var pair = vars[i].split("=");
  141. if(pair[0] == variable){return pair[1];}
  142. }
  143. return(false);
  144. }
  145. return module;
  146. });