|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "paging", 'dateTime', 'swiper'], function ($, template, Tools) {
- //数据存储
- var module = {
- data: {
- propertyList:'',
- map: '', // 地图图层
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- tools.doGet(assetresourceGet+getQueryVariable('id'), {translate_dict: 1}, module.assetDetail , true);
- tools.doGet(webList, {}, module.webList , true);
- // var map = new BMapGL.Map('container'); // 创建Map实例
- // map.centerAndZoom(new BMapGL.Point(116.320938,39.950026), 18); // 初始化地图,设置中心点坐标和地图级别
- // map.enableScrollWheelZoom(false); // 开启鼠标滚轮缩放
- };
-
- module.useContent = function (data) {
- if (data.code == 200) {
- module.data.phone = data.data.phone;
- module.data.leader = data.data.leader;
- var propertyDetailData = template('propertyDetailData', module.data);
- $("#propertyDetailContent").html(propertyDetailData);
- setTimeout(() => {
- initMap(data.data);
- }, 500);
- }
- }
-
- initMap = function (dept) {
- document.getElementById("container").innerHTML = "";
- // 定义地图投影
- let projection = new ol.proj.Projection({
- code: "EPSG:3857",
- units: "degrees",
- });
- // 定义地图图层
- let aerial = new ol.layer.Tile({
- source: new ol.source.XYZ({
- url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
- "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
- "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
- }),
- isGroup: true,
- name: "卫星影像图",
- });
- let yingxzi = new ol.layer.Tile({
- source: new ol.source.XYZ({
- url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
- }),
- isGroup: true,
- name: "天地图文字标注--卫星影像图",
- });
- //加载地图
- module.data.map = new ol.Map({
- controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
- layers: [aerial, yingxzi],
- projection: projection,
- target: "container",
- view: new ol.View({
- center: ol.proj.fromLonLat([dept.lng, dept.lat]), // 地图中心坐标
- zoom: 16,
- minZoom: 1, //地图缩小限制
- maxZoom: 18, //地图放大限制
- }),
- /*interactions: ol.interaction.defaults({
- doubleClickZoom: false, // 双击放大地图
- // mouseWheelZoom: false, // 鼠标滚轮放大地图
- // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
- })*/
- });
-
- if (module.data.propertyDetail && module.data.propertyDetail.theGeomJson) {
- const resourceDetail = new ol.layer.Vector({
- source: new ol.source.Vector({
- features: new ol.format.GeoJSON().readFeatures(module.data.propertyDetail.theGeomJson),
- }),
- name: 'resourceDetail',
- style: new ol.style.Style({
- fill: new ol.style.Fill({
- //矢量图层填充颜色,以及透明度
- color: "rgba(255, 255, 0, 0.3)",
- }),
- stroke: new ol.style.Stroke({
- //边界样式
- color: "#ffff00",
- width: 2,
- }),
- })
- });
- module.data.map.addLayer(resourceDetail);
- module.data.map.getView().setCenter(ol.extent.getCenter(resourceDetail.getSource().getExtent()));
- }
- }
-
- module.webList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- module.data.webList = content;
- var webData = template('webData', module.data);
- $("#webContent").html(webData);
- var titData = template('titData', module.data);
- $("#titContent").html(titData);
- }
- }
-
- module.assetDetail = function(data){
- if (data.code == 200) {
- var content = data.data;
- module.data.propertyDetail = content;
- tools.doGet(attachmentList, {
- tableId:content.id,
- tableName: 't_asset_resource',
- bizPath: 'asset'
- }, module.attachmentDetail , true);
- tools.doGet(treeselectSecond+content.deptId, {}, module.useContent , true);
- // var propertyDetailData = template('propertyDetailData', module.data);
- // $("#propertyDetailContent").html(propertyDetailData);
- // $('#dialog').css('display','block');
- }
- }
-
- module.attachmentDetail = function(data){
- if (data.code == 200) {
- var content = data.rows;
- var attachmentList = [];
- content.map(res=>{
- if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
- attachmentList.push(res);
- }
- })
- module.data.attachment = attachmentList;
- var propertyDetailData = template('propertyDetailData', module.data);
- $("#propertyDetailContent").html(propertyDetailData);
- $('#dialog').css('display','block');
- }
- }
-
- //获取地址栏参数
- function getQueryVariable(variable){
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if(pair[0] == variable){return pair[1];}
- }
- return(false);
- }
-
- return module;
- });
|