define([
|
"dojo",
|
"dojo/_base/declare",
|
"dojo/_base/lang",
|
"base/BaseWidget",
|
"dojo/text!widgets/mapBrowse/template.html",
|
"widgets/mapBrowse/config",
|
"widgets/myModules/monitorSpots",
|
"base/AppEvent",
|
"base/ConfigData",
|
"iframe/jcyj/js/dataShow.js",
|
"dojo/dom",
|
"dojo/dom-construct",
|
"dojo/dom-attr",
|
"dojo/dom-style",
|
"dojo/on",
|
"esri/layers/ArcGISDynamicMapServiceLayer",
|
"esri/layers/ArcGISTiledMapServiceLayer",
|
"esri/layers/FeatureLayer",
|
"controls/tab/TabControl",
|
"esri/dijit/SymbolStyler",
|
"esri/styles/basic",
|
"dojo/_base/array",
|
"esri/InfoTemplate",
|
"esri/renderers/SimpleRenderer",
|
"esri/renderers/ClassBreaksRenderer",
|
"esri/renderers/UniqueValueRenderer",
|
"esri/symbols/PictureMarkerSymbol",
|
"esri/layers/GraphicsLayer",
|
"esri/graphic",
|
"dojo/domReady!"
|
], function (dojo,
|
declare,
|
lang,
|
BaseWidget,
|
template,
|
config,
|
monitorSpots,
|
AppEvent,
|
ConfigData,
|
dataShow,
|
dom,
|
domConstruct,
|
domAttr,
|
domStyle,
|
on,
|
ArcGISDynamicMapServiceLayer,
|
ArcGISTiledMapServiceLayer,
|
FeatureLayer,
|
TabControl,
|
SymbolStyler,
|
basic,
|
arrayUtils,
|
InfoTemplate,
|
SimpleRenderer,
|
ClassBreaksRenderer,
|
UniqueValueRenderer,
|
PictureMarkerSymbol,
|
GraphicsLayer,
|
Graphic) {
|
var imgDiv = [];
|
var vedioDiv = '';
|
var docuDiv = '';
|
var panoUrl = '';
|
var Widget = declare([BaseWidget], {
|
widgetName: "MapBrowseWidget",
|
label: "地图浏览",
|
templateString: template,
|
_map: null,
|
_layers: [],
|
_styler: null,
|
_selectLayer: null,
|
MapBrowseObj: null,
|
treecheck: null,
|
treechecked: null,
|
_clicklayer: null,
|
_historyBack: null,
|
content: null,
|
monitorLayer: null,
|
constructor: function (options, srcRefNode) {
|
this._map = options.map;
|
//初始化监测站点图层
|
this.monitorLayer = new GraphicsLayer({id: 'monitorLayer'});
|
this.monitorLayer.on('click', this.monitorSpotsOnClick);
|
this._map.addLayer(this.monitorLayer);
|
},
|
postCreate: function () {
|
|
},
|
startup: function () {
|
MapBrowseObj = this;
|
MapBrowseObj.treecheck = [];
|
this._init();
|
this.inherited(arguments);
|
$('#rMenu').mouseleave(function () {
|
$('#rMenu').css({
|
"visibility": "hidden"
|
});
|
$('#Transparency').css({
|
"visibility": "hidden",
|
});
|
});
|
$('#Transparency').mouseleave(function (evt) {
|
$('#Transparency').css({
|
"visibility": "hidden",
|
});
|
});
|
$('#m_del').mouseover(function (evt) {
|
$('#Transparency').css({
|
"visibility": "visible",
|
});
|
$('#rangechange').val(MapBrowseObj._clicklayer.opacity);
|
});
|
$('#rangechange').change(function (evt) {
|
var zhi = $('#rangechange').val();
|
MapBrowseObj._setlayeropacity(zhi * 1);
|
});
|
|
// 绑定tab切换事件--点击切换状态并控制相应的tab标签显示
|
$('.tab-container li').click(function () {
|
var tabName = $(this).attr('data');
|
var containerName = tabName + '-container';
|
if (tabName && !$(this).hasClass('tab-selected')) {
|
$('.container-show').removeClass('container-show');
|
switch (tabName) {
|
case 'introduce':
|
$('.tab-selected img').attr('src', 'widgets/mapBrowse/images/layer.png');
|
$('.tab-selected').removeClass('tab-selected');
|
$(this).children('img').attr('src', 'widgets/mapBrowse/images/introduce-selected.png');
|
break;
|
case 'layer':
|
$('.tab-selected img').attr('src', 'widgets/mapBrowse/images/introduce.png');
|
$('.tab-selected').removeClass('tab-selected');
|
$(this).children('img').attr('src', 'widgets/mapBrowse/images/layer-selected.png');
|
break;
|
default:
|
break;
|
}
|
$(this).addClass('tab-selected');
|
$('.' + containerName).addClass('container-show');
|
}
|
});
|
AppEvent.addAppEventListener("clearall", lang.hitch(this, function (evt) {
|
if (evt.idname != "MapBrowseWidget") {
|
var treeObj = $.fn.zTree.getZTreeObj("mapBrowseTree");
|
var nodes = treeObj.getCheckedNodes();
|
for (var index in nodes) {
|
if (!nodes[index].isParent) {
|
if (nodes[index].checked) {
|
var nodeobj = nodes[index];
|
nodes[index].checkedOld = false;
|
MapBrowseObj._map.removeLayer(ConfigData.layers[nodes[index].tId]);
|
ConfigData.layers[nodes[index].tId] = null;
|
|
if (dojo.byId("all")) {
|
dojo.destroy("all");
|
dojo.destroy("bar_div");
|
}
|
}
|
}
|
}
|
MapBrowseObj._init();
|
}
|
}));
|
//初始化自定义弹窗部件
|
var mymonitorSpots = new monitorSpots();
|
AppEvent.addAppEventListener('popup', lang.hitch(mymonitorSpots, function (e) {
|
this.popup(e)
|
}));
|
|
},
|
open: function () {
|
this.inherited(arguments);
|
},
|
close: function () {
|
this.inherited(arguments);
|
if (MapBrowseObj._styler) {//摧毁样式弹窗
|
MapBrowseObj._styler.destroy();
|
MapBrowseObj._styler = null;
|
}
|
},
|
_init: function () {
|
// $.ajax({
|
// type: "get",
|
// // url: ConfigData.ajaxURL,
|
// url: getNativePath() + "resources/queryResourcesTree.do?soId=bbb7001c67c442540167c4a2a604000b",
|
// data: {
|
// "limit": 10000
|
// },
|
// dataType: "json",
|
// async: true,
|
// success: function (result) {
|
// var _ztreeObj = [];
|
// var resultObj = result.data;
|
// for (var i = 0; i < resultObj.length; i++) {
|
// var searchCatalog = {};
|
// searchCatalog.id = resultObj[i].resourcesId;
|
// searchCatalog.pId = resultObj[i].resourcesPid;
|
// searchCatalog.name = resultObj[i].resourcesName;
|
// searchCatalog.Url = resultObj[i].resourcesUrl;
|
// searchCatalog.isPath = true;
|
// _ztreeObj.push(searchCatalog);
|
// }
|
|
// var setting = {
|
// view: {
|
// addHoverDom: MapBrowseObj.addHoverDom,
|
// removeHoverDom: MapBrowseObj.removeHoverDom
|
// },
|
// check: {
|
// enable: true
|
// },
|
// data: {
|
// simpleData: {
|
// enable: true
|
// }
|
// },
|
// callback: {
|
// beforeClick: MapBrowseObj._beforeClick,
|
// onCheck: MapBrowseObj._zTreeOnCheck
|
// }
|
// };
|
// ConfigData.treeNodes = _ztreeObj;//将目录树节点存入全局
|
// var treeObj = $.fn.zTree.init($("#mapBrowseTree"), setting, _ztreeObj);
|
|
|
// //获取监测站点目录树
|
// $.ajax({
|
// url: ConfigData.monitorSpotURL,
|
// type: 'get',
|
// dataType: 'json',
|
// async: true,
|
// success: function (e) {
|
// var data = e.data;
|
// // console.log(data);
|
// var newNodes = [{//构造湿地监控点父节点
|
// id: 'monitorNode',
|
// pId: 0,
|
// name: '湿地监控点',
|
// children: data
|
// }];
|
// for (var eKey in data) {//父节点
|
// data[eKey].pId = "monitorNode";
|
// var data1 = data[eKey].children;
|
// for (var data1Key in data1) {//第二层节点
|
// var data2 = data1[data1Key].children;
|
// if (!data1[data1Key].hasOwnProperty('name')) {//没有name属性就添加
|
// data1[data1Key]['name'] = data1[data1Key].text;
|
// }
|
// if (data1[data1Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
|
// data1[data1Key]['x'] = data1[data1Key].lon;
|
// data1[data1Key]['y'] = data1[data1Key].lat;
|
// data1[data1Key]['isPath'] = false;
|
// }
|
// for (var data2Key in data2) {//第三层节点
|
// var data3 = data2[data2Key].children;
|
// if (!data2[data2Key].hasOwnProperty('name')) {//没有name属性就添加
|
// data2[data2Key]['name'] = data2[data2Key].text;
|
// }
|
// if (data2[data2Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
|
// data2[data2Key]['x'] = data2[data2Key].lon;
|
// data2[data2Key]['y'] = data2[data2Key].lat;
|
// data2[data2Key]['isPath'] = false;
|
// }
|
// for(var data3Key in data3){//最后一层节点
|
// if (!data3[data3Key].hasOwnProperty('name')) {//没有name属性就添加
|
// data3[data3Key]['name'] = data3[data3Key].text;
|
// }
|
// if (data3[data2Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
|
// data3[data3Key]['x'] = data3[data3Key].lon;
|
// data3[data3Key]['y'] = data3[data3Key].lat;
|
// data3[data3Key]['isPath'] = false;
|
// }
|
// }
|
// }
|
// }
|
// }
|
// treeObj.addNodes(null, newNodes);//给ztree添加新节点
|
// }
|
// });
|
// },
|
// error: function (e) {
|
// console.log(e);
|
// alert("请求失败");
|
// }
|
// });
|
},
|
_beforeClick: function (treeId, treeNode) {
|
if (!treeNode.path && treeNode.isParent) {
|
var treeObj = $.fn.zTree.getZTreeObj(treeId);
|
treeObj.expandNode(treeNode, !treeNode.open, false, true, true);
|
}
|
return treeNode.path && !treeNode.isParent;
|
},
|
_zTreeOnCheck: function (event, treeId, treeNode) {
|
//复选框选择事件
|
var treeObj = $.fn.zTree.getZTreeObj("mapBrowseTree");
|
var nodes = treeObj.getChangeCheckedNodes(); //状态改变的节点
|
for (var index in nodes) {
|
//筛选根节点
|
if (!nodes[index].isParent && nodes[index].Url && nodes[index].isPath) {//图层服务
|
//选中的节点
|
if (nodes[index].checked) {
|
nodes[index].checkedOld = true;
|
var nodeobj = nodes[index];
|
var layerobj = nodeobj.Url;
|
var template = new InfoTemplate();
|
template.setTitle(MapBrowseObj._getGraphicTitle);
|
template.setContent(MapBrowseObj._getTextContent);
|
var baseurl = layerobj.substring(0, layerobj.lastIndexOf('/'));
|
var i = layerobj.substring(layerobj.lastIndexOf('/') + 1, layerobj.length) * 1;
|
var selectLayer = new ArcGISDynamicMapServiceLayer(baseurl, {id: nodes[index].tId});
|
var templates = {};
|
templates[i] = {
|
infoTemplate: template
|
};
|
selectLayer.setInfoTemplates(templates);
|
selectLayer.setVisibleLayers([i]);
|
// var selectLayer = new FeatureLayer(layerobj, {infoTemplate: template, outFields: ['*'],mode: FeatureLayer.MODE_ONDEMAND,displayOnPan:false});
|
selectLayer.on("error", function (evt) {
|
var msg = evt.error.message;
|
alert(msg);
|
});
|
ConfigData.layers[nodeobj.tId] = selectLayer;
|
MapBrowseObj._map.addLayer(selectLayer);
|
} else {
|
nodes[index].checkedOld = false;
|
if (ConfigData.layers[nodes[index].tId]) {
|
MapBrowseObj._map.removeLayer(ConfigData.layers[nodes[index].tId]);
|
}
|
ConfigData.layers[nodes[index].tId] = null;
|
delete ConfigData.layers[nodes[index].tId];
|
}
|
} else {//监测站点
|
if (nodes[index].checked) {//选中的节点
|
if (nodes[index].hasOwnProperty('x') && nodes[index].hasOwnProperty('y')) {//判断是否包含经纬度,包含则添加到地图上
|
nodes[index].checkedOld = true;
|
if(nodes[index].children){
|
|
}else{
|
if (!!window.ActiveXObject || "ActiveXObject" in window){
|
var isIE = true;
|
}else{
|
var isIE = false;
|
}
|
if(isIE){
|
var x = 5;
|
}else{
|
var x = -4;
|
}
|
var myPoint = {
|
"geometry": {
|
"x": nodes[index].x,
|
"y": nodes[index].y,
|
"spatialReference": {"wkid": 4490}
|
},
|
"attributes": {
|
id: nodes[index].id,
|
pId: nodes[index].pId,
|
name: nodes[index].name,
|
quanjingUrl: nodes[index].Url || null,
|
videoUrl: nodes[index].videoUrl || null,
|
videoType: nodes[index].videoType || null,
|
x: nodes[index].x,
|
y: nodes[index].y,
|
},
|
"symbol": {
|
"type": "esriPMS",
|
"url": 'images/monitor.png',
|
"imageData": null,
|
"contentType": "image/png",
|
"width": 15,
|
"height": 20,
|
"angle": 0,
|
"xoffset": 0,
|
"yoffset": 10
|
}
|
};
|
var text = {
|
"geometry": {
|
"x": nodes[index].x,
|
"y": nodes[index].y,
|
"spatialReference": {"wkid": 4490}
|
},
|
"symbol": {
|
"type": "esriTS",
|
"color": [16, 139, 171, 255],
|
"backgroundColor": [16, 139, 171, 255],
|
"borderLineSize": 1,
|
"borderLineColor": [16, 139, 171, 255],
|
"verticalAlignment": 'bottom',//<baseline | top | middle | bottom>
|
"horizontalAlignment": 'left',//<left | right | center | justify>
|
"rightToLeft": true,//<true | false>
|
"angle": 0,
|
"xoffset": 8,
|
"yoffset": x,
|
"kerning": true,//<true | false>
|
"font": {
|
"family": "wryh",
|
"size": 11,
|
"style": "normal",//<italic | normal | oblique>
|
"weight": 'bold',//<bold | bolder | lighter | normal>
|
"decoration": 'none',//<line-through | underline | none>
|
},
|
"text": nodes[index].name //only applicable when specified as a client-side graphic.
|
}
|
};
|
var gra = new Graphic(myPoint);
|
var textpt = new Graphic(text);
|
ConfigData.monitorSpots[nodes[index].tId] = [gra, textpt];
|
MapBrowseObj.monitorLayer.add(gra);
|
MapBrowseObj.monitorLayer.add(textpt);
|
}
|
}
|
} else {
|
nodes[index].checkedOld = false;
|
if (ConfigData.monitorSpots[nodes[index].tId]) {
|
MapBrowseObj.monitorLayer.remove(ConfigData.monitorSpots[nodes[index].tId][0]);
|
MapBrowseObj.monitorLayer.remove(ConfigData.monitorSpots[nodes[index].tId][1]);
|
}
|
ConfigData.monitorSpots[nodes[index].tId] = null;
|
delete ConfigData.monitorSpots[nodes[index].tId];
|
}
|
}
|
}
|
},
|
monitorSpotsOnClick: function (e) {
|
var graphic = e.graphic;
|
graphic.attributes.itemList = {
|
'实时数据': '鄱阳湖国家湿地公园',
|
'历史数据': '鄱阳湖国家湿地公园',
|
'全景': '鄱阳湖国家湿地公园',
|
'视频监控': '鄱阳湖国家湿地公园',
|
};
|
//派发监测点弹窗
|
AppEvent.dispatchAppEvent('popup', graphic);
|
},
|
_getGraphicTitle: function (graphic) {
|
var layer = graphic.getLayer();
|
if (layer.name.indexOf("城") != -1 && layer.name.indexOf("湿") != -1) {
|
var title = graphic.attributes[layer.displayField] + "第" + graphic.attributes["WETLAND_NO"] + "号湿地斑块";
|
} else {
|
var title = graphic.attributes[layer.displayField];
|
}
|
if (!title) {
|
title = layer.name;
|
}
|
return title;
|
},
|
_getTextContent: function (graphic) {
|
MapBrowseObj.content = '';
|
var id = graphic.attributes.OBJECTID;
|
MapBrowseObj.content += "<div class='con'>";
|
var layer = graphic.getLayer();
|
var layerName = layer.name;
|
if (layerName.indexOf("省重要") != -1) {
|
panoUrl = graphic.attributes.URL;
|
} else {
|
panoUrl = '';
|
}
|
for (var a = 0; a < layer.fields.length; a++) {
|
var ming = layer.fields[a].name;
|
var ali = layer.fields[a].alias;
|
if (ali != "OBJECTID" && graphic.attributes[ming]) {
|
var regs = new RegExp("[\\u4E00-\\u9FFF]+", "g");
|
if (regs.test(ali) && ali.toLowerCase().indexOf("object") == -1 && ali.toLowerCase().indexOf("shape") == -1 && ali.indexOf("area") == -1 &&
|
ali.indexOf("AREA") == -1 && ali.indexOf("Area") == -1 && ali.indexOf("FID") == -1) {
|
MapBrowseObj.content += "<div>" + layer.fields[a].alias + ":<b>" + graphic.attributes[ming] + "</b></div>";
|
}
|
}
|
}
|
if (layer.hasAttachments) {
|
var attach = 0; //附件的个数
|
var vedio = 0; //视频个数
|
var docu = 0; //文件个数
|
//根据返回的数据判断是否添加相应的字段;
|
//console.log(layer.name);
|
layer.queryAttachmentInfos(id, function (result) {
|
// console.log(result);
|
imgDiv = [];
|
vedioDiv = '';
|
docuDiv = '';
|
for (var i = 0; i < result.length; i++) {
|
var type = result[i].contentType;
|
if (type.indexOf('image') != -1) {
|
imgDiv.push("<div class='swiper-slide' num=" + attach + "><img src='" + result[i].url + "'/></div>");
|
attach++;
|
} else if (type.indexOf('video') != -1) {
|
vedio++;
|
vedioDiv = "<video controls><source src='" + result[i].url + "' type='video/mp4'></video>";
|
} else if (type.indexOf('application') != -1) {
|
docu++;
|
docuDiv += "<a href='" + result[i].url + "' style='display:block' download='" + result[i].name + "'>" + result[i].name + "</a>";
|
}
|
}
|
$('.actionList').children('a:first').nextAll().remove(); //清除“缩放至”之后的所有元素
|
//判断相应的文件是否存在来添加相应的按钮
|
if (attach > 0) {
|
if (layerName.indexOf("公园") != -1) {
|
$('.actionList').append("<a title=\"图片\" class=\"action zoomTo img\" href=\"javascript:void(0);\"><span>附件</span></a>");
|
} else {
|
$('.actionList').append("<a title=\"图片\" class=\"action zoomTo img\" href=\"javascript:void(0);\"><span>图片</span></a>");
|
}
|
}
|
if (panoUrl.length > 0) {
|
$('.actionList').append("<a title=\"全景\" class=\"action zoomTo qj\" href=\"javascript:void(0);\"><span>全景</span></a>");
|
}
|
if (vedio > 0) {
|
$('.actionList').append("<a title=\"视频\" class=\"action zoomTo vedio\" href=\"javascript:void(0);\"><span>视频</span></a>");
|
}
|
if (docu > 0) {
|
$('.actionList').append("<a title=\"文件\" class=\"action zoomTo docu\" href=\"javascript:void(0);\"><span>文件</span></a>");
|
}
|
if (result.length > 0 || panoUrl.length > 0) {
|
$('.actionList').append("<a title=\"详细信息\" class=\"action zoomTo msg\" href=\"javascript:void(0);\"><span>详细信息</span></a>");
|
}
|
MapBrowseObj.content += "</div>";
|
//相应按钮的点击事件
|
MapBrowseObj._infowindowClick();
|
// return MapBrowseObj.content;
|
}, function (result) {
|
console.log(result);
|
});
|
} else {
|
$('.actionList').children('a:first').nextAll().remove(); //清除“缩放至”之后的所有元素
|
if (layer.name.indexOf("省重要") != -1 && panoUrl.length > 0) {
|
$('.actionList').append("<a title=\"全景\" class=\"action zoomTo qj\" href=\"javascript:void(0);\"><span>全景</span></a>");
|
$('.actionList').append("<a title=\"详细信息\" class=\"action zoomTo msg\" href=\"javascript:void(0);\"><span>详细信息</span></a>");
|
}
|
MapBrowseObj._infowindowClick();
|
}
|
return MapBrowseObj.content;
|
},
|
_infowindowClick: function () {
|
//先清除上次弹窗所绑定的事件,防止重复执行
|
$('.actionList .img').unbind();
|
$('.actionList .qj').unbind();
|
$('.actionList .vedio').unbind();
|
var html;
|
var timer = setTimeout(function () {
|
html = $('.contentPane .con').html();
|
}, 500); //将记录界面重新写入;
|
//“图片”点击事件
|
$('.actionList .img').click(function () {
|
var inner = "<div class = 'swiper-wrapper'>" + imgDiv[0] + "</div>";
|
$('.contentPane .con').html(inner);
|
if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
|
$('.swiper-wrapper .swiper-slide img').smartZoom({
|
"containerClass": "zoomContainer"
|
});
|
} else {
|
$('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}
|
//图片的切换功能,
|
var nums = imgDiv.length;
|
if (nums > 1) {
|
Btns = "<img src='images/nextBtn.jpg' class='nextBtn'><img src='images/prevBtn.jpg' class='prevBtn'>";
|
$('.contentPane .con').append(Btns);
|
$('.nextBtn').click(function () {
|
var num;
|
num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
|
if (num == nums - 1) {
|
num = 0;
|
} else {
|
num++;
|
}
|
;
|
if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
|
$('.swiper-wrapper .swiper-slide img').smartZoom({
|
"containerClass": "zoomContainer"
|
});
|
} else {
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}
|
});
|
$('.prevBtn').click(function () {
|
var num;
|
num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
|
if (num == 0) {
|
num = nums - 1;
|
} else {
|
num--;
|
}
|
;
|
if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
|
$('.swiper-wrapper .swiper-slide img').smartZoom({
|
"containerClass": "zoomContainer"
|
});
|
} else {
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}
|
});
|
}
|
});
|
//文档点击事件
|
$('.actionList .docu').click(function () {
|
$('.contentPane .con').html('');
|
$('.contentPane .con').html(docuDiv);
|
});
|
//“全景”点击事件
|
$('.actionList .qj').click(function () {
|
if ($('.contentPane iframe').css('display') != "block" && $('.contentPane img').length == 0 && $('.contentPane video').length == 0) {
|
html = $('.contentPane .con').html(); //记录现有界面
|
}
|
$('.contentPane .con').empty();
|
$('.contentPane .con').append("<iframe name=\"i\" src=" + panoUrl + "></iframe>");
|
$('.contentPane .con iframe').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
});
|
//“视频”点击事件
|
$('.actionList .vedio').click(function () {
|
$('.contentPane .con').html(vedioDiv);
|
$('.contentPane .con video').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
});
|
//“详细信息”点击事件,点击返回属性页
|
$('.actionList .msg').click(function () { //返回按钮点击事件
|
$('.contentPane .con').html(html); //将记录界面重新写入
|
});
|
//关闭按钮点击事件
|
$(".close").click(function () {
|
if ($(".con").children("iframe").length > 0) {
|
$(".con").text('');
|
}
|
});
|
//“最大化按钮”点击事件,点击改变信息框样式
|
$('.titlePane .maximize').unbind().click(function () {
|
setTimeout(function () {
|
if ($(".titlePane [title = '恢复']").attr("title") == "恢复" && $('.swiper-wrapper .swiper-slide').length > 0) {
|
var num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
$('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
|
$('.swiper-wrapper .swiper-slide img').smartZoom({
|
"containerClass": "zoomContainer"
|
});
|
} else {
|
var num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
|
$('.contentPane .con .swiper-slide').remove();
|
$('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
|
$('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
|
$('.swiper-wrapper , .swiper-slide').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
$('.swiper-wrapper .swiper-slide div').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
$('.contentPane .con iframe').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}
|
if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
|
$('.contentPane .con iframe').css({
|
"width": $('.contentPane').css("width"),
|
"height": $('.contentPane').css("height")
|
});
|
} else {
|
$('.contentPane .con iframe').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}
|
$('.contentPane .con video').css({
|
"width": $('.contentPane').css("width"),
|
"height": "auto"
|
});
|
}, 100);
|
});
|
},
|
//ztree添加自定义图标
|
addHoverDom: function (treeId, treeNode) {
|
// debugger
|
if ($("#diyBtn_" + treeNode.id).length > 0 || treeNode.isParent) {
|
return;
|
}
|
|
var aObj = $("#" + treeNode.tId + "_a");
|
var editStr = "<span id='diyBtn_space_" + treeNode.id + "' > </span>"
|
+ "<button type='button' class='diyBtn1' id='diyBtn_" + treeNode.id
|
+ "' title='打开编辑' onfocus='this.blur();'></button>";
|
aObj.append(editStr);
|
var btn = $("#diyBtn_" + treeNode.id);
|
if (btn) {
|
btn.on("click", function () {
|
//根据节点生成featrueLayer替换原来的dynamicLayer
|
var layerobj = treeNode.Url;
|
var template = new InfoTemplate();
|
template.setTitle(MapBrowseObj._getGraphicTitle);
|
template.setContent(MapBrowseObj._getTextContent);
|
var selectLayer = new FeatureLayer(layerobj, {
|
id: treeNode.tId,
|
infoTemplate: template,
|
outFields: ['*'],
|
mode: FeatureLayer.MODE_ONDEMAND,
|
displayOnPan: false
|
});
|
selectLayer.on("error", function (evt) {
|
var msg = evt.error.message;
|
alert(msg);
|
});
|
//先移除地图上原有的动态图层,在将新图层添加上去,并替换configData里的图层
|
MapBrowseObj._map.removeLayer(ConfigData.layers[treeNode.tId]);
|
MapBrowseObj._map.addLayer(selectLayer);
|
ConfigData.layers[treeNode.tId] = selectLayer;
|
selectLayer.on('load', function (e) {
|
var selectedLayer = e.layer;
|
//点击设置,需要再次获取图层所有符号,因为可能更换过,而不是用初始符号
|
var symbols1 = [];
|
var renderer = selectedLayer.renderer;
|
if (renderer instanceof SimpleRenderer) {
|
symbols1[0] = {
|
label: selectedLayer.name,
|
symbol: renderer.symbol
|
};
|
} else if (renderer instanceof ClassBreaksRenderer) {
|
symbols1 = arrayUtils.map(renderer.infos, function (info) {
|
return {
|
label: info.value,
|
symbol: info.symbol
|
};
|
});
|
} else if (renderer instanceof UniqueValueRenderer) {
|
symbols1 = arrayUtils.map(renderer.infos, function (info) {
|
return {
|
label: info.value,
|
symbol: info.symbol
|
};
|
});
|
}
|
//调用自定义图层样式函数
|
MapBrowseObj._openSymbolStyler(selectedLayer, symbols1, 0, treeNode);
|
})
|
});
|
}
|
},
|
removeHoverDom: function (treeId, treeNode) {
|
$("#diyBtn_" + treeNode.id).unbind().remove();
|
$("#diyBtn_space_" + treeNode.id).unbind().remove();
|
},
|
//打开符号设置部件,参数说明,checkedLayer选中的图层,symbols图层符号数组,index符号索引。注意不能一次只能针对一个符号修改
|
_openSymbolStyler: function (checkedLayer, symbols, index, treeNode) {
|
MapBrowseObj._selectLayer = checkedLayer;
|
var defaultSymbol = symbols[index].symbol;
|
//判断是否为点图层
|
if (MapBrowseObj._selectLayer.geometryType != "esriGeometryPoint") {
|
if (MapBrowseObj._styler) {
|
|
} else {
|
// if(MapBrowseObj._selectLayer.geometryType != "esriGeometryPoint"){
|
|
// 销毁上次生成的节点,防止重复注册
|
// MapBrowseObj._styler.destroy();
|
// domConstruct.destroy("applySymboldiv");
|
// domConstruct.destroy("styler");
|
domConstruct.create('div', {
|
id: 'styler',
|
style: 'display:none'
|
}, 'editor');
|
var applySymboldiv = domConstruct.create("div", {
|
id: "applySymboldiv",
|
class: "options-panel"
|
});
|
|
domConstruct.place(applySymboldiv, "styler");
|
|
var applySymbolButton = domConstruct.create("input", {
|
type: "button",
|
value: "使用符号"
|
}, applySymboldiv);
|
var canelSymbolButton = domConstruct.create("input", {
|
type: "button",
|
value: "取消使用"
|
}, applySymboldiv);
|
|
on(applySymbolButton, "click", lang.hitch(applySymbolButton, function (a, evt) {
|
var style = MapBrowseObj._styler.getStyle();
|
|
if (MapBrowseObj._selectLayer.renderer instanceof SimpleRenderer) {
|
MapBrowseObj._selectLayer.renderer.symbol = style.symbol;
|
} else if (MapBrowseObj._selectLayer.renderer instanceof ClassBreaksRenderer) {
|
MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
|
} else if (MapBrowseObj._selectLayer.renderer instanceof UniqueValueRenderer) {
|
MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
|
} else {
|
|
}
|
//刷新图层,并隐藏窗口
|
MapBrowseObj._selectLayer.refresh();
|
domStyle.set("styler", "display", "none");
|
}, index));
|
|
on(canelSymbolButton, "click", lang.hitch(MapBrowseObj, function (evt) {
|
domStyle.set("styler", "display", "none");
|
}));
|
|
//Create instance of SymbolStyler and pass in the domNode,注意跨域会读取不到符号数据,需同源
|
MapBrowseObj._styler = new SymbolStyler({
|
portalUrl: ''
|
}, "styler");
|
//Must call startup
|
MapBrowseObj._styler.startup();
|
}
|
MapBrowseObj._styler.edit(defaultSymbol, MapBrowseObj._getStylerOptions(defaultSymbol));
|
$("#styler").show();
|
$("#point_styler").hide();
|
} else {
|
//自定义点图层样式修改窗体--目前只针对于SimpleRenderer
|
// console.log(MapBrowseObj._selectLayer.renderer.symbol);
|
$("#styler").hide();
|
//为table标签中添加子候选项---即icon列表,并添加点击事件
|
$("#icon_table").empty();
|
var table_row = ["black", "blue", "green", "red", "yellow"];
|
var arr_td = [];
|
//获取项目根目录当前所在地址
|
var baseUrl = getIndexUrl("/wetlandmap");
|
for (var x in table_row) {
|
for (var y = 1; y < 32; y++) {
|
arr_td.push("" + baseUrl + "<td><img src='/widgets/index/images/icon/" + table_row[x] + "/" + table_row[x] + y + ".png' /></td>" + "");
|
}
|
}
|
$("#icon_table").append("<tr ></tr>");
|
var td_num = 0;
|
for (var z in arr_td) {
|
if (td_num > 5) {
|
$("#icon_table").append("<tr ></tr>");
|
td_num = 0;
|
}
|
$("#icon_table tr:last").append(arr_td[z]);
|
td_num++;
|
}
|
$("#icon_table").unbind("click").click(function (evt) {
|
$("#icon_table img").removeClass("on_selected_td");
|
if (evt.target.localName == "img") {
|
$(evt.target).addClass("on_selected_td");
|
$("#original_img").attr("src", $("#icon_table .on_selected_td").attr("src"));
|
}
|
});
|
//为使用图像按钮添加点击事件,并为图像输入框添加change事件
|
$("#custom_img a").unbind("click").click(function () {
|
$("#custom_img input").toggle();
|
});
|
$("#custom_img input").change(function () {
|
$("#original_img").attr("src", $("#custom_img input").val());
|
var val = parseFloat($("#px_value").val());
|
$("#original_img").css("height", val + "px");
|
});
|
//像素值输入栏加减按钮添加点击事件,及输入框输入事件
|
$("#value_add").unbind("click").click(function () {
|
var val = parseFloat($("#px_value").val()) + 1;
|
$("#px_value").val(val);
|
$("#original_img").css("height", val + "px");
|
});
|
$("#value_dec").unbind("click").click(function () {
|
var val = parseFloat($("#px_value").val()) - 1;
|
$("#px_value").val(val);
|
$("#original_img").css("height", val + "px");
|
});
|
$("#px_value").unbind("change").change(function () {
|
var val = parseFloat($("#px_value").val());
|
$("#original_img").css("height", val + "px");
|
});
|
|
//添加确定和取消按钮并为其添加点击事件
|
domConstruct.destroy("applySymboldiv1");
|
|
var applySymboldiv1 = domConstruct.create("div", {
|
id: "applySymboldiv1",
|
class: "options-panel"
|
});
|
|
domConstruct.place(applySymboldiv1, "point_styler");
|
|
var applySymbolButton1 = domConstruct.create("input", {
|
type: "button",
|
value: "使用符号"
|
}, applySymboldiv1);
|
var canelSymbolButton1 = domConstruct.create("input", {
|
type: "button",
|
value: "取消使用"
|
}, applySymboldiv1);
|
|
on(applySymbolButton1, "click", lang.hitch(applySymbolButton1, function (a, evt) {
|
var imgsrc = null;
|
if ($("#custom_img input").is(":hidden") == false && $.trim($("#custom_img input").val())) {
|
imgsrc = $("#custom_img input").val();
|
} else if ($.trim($("#icon_table .on_selected_td").attr("src"))) {
|
imgsrc = $("#icon_table .on_selected_td").attr("src");
|
} else {
|
var persent = parseFloat(MapBrowseObj._selectLayer.renderer.symbol.width) / parseFloat(MapBrowseObj._selectLayer.renderer.symbol.height);
|
MapBrowseObj._selectLayer.renderer.symbol.height = $("#px_value").val();
|
MapBrowseObj._selectLayer.renderer.symbol.width = parseFloat($("#px_value").val()) * persent;
|
}
|
if (imgsrc) {
|
var icon_size = $("#px_value").val();
|
if (MapBrowseObj._selectLayer.renderer instanceof SimpleRenderer) {
|
var select_symbol = new PictureMarkerSymbol(imgsrc, icon_size, icon_size);
|
MapBrowseObj._selectLayer.renderer.symbol = select_symbol;
|
} else if (MapBrowseObj._selectLayer.renderer instanceof ClassBreaksRenderer) {
|
// MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
|
} else if (MapBrowseObj._selectLayer.renderer instanceof UniqueValueRenderer) {
|
// MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
|
} else {
|
|
}
|
}
|
//刷新图层,并隐藏窗口
|
MapBrowseObj._selectLayer.refresh();
|
domStyle.set("point_styler", "display", "none");
|
$("#original_img").css("height", "24px");
|
}, index));
|
|
on(canelSymbolButton1, "click", lang.hitch(this, function (evt) {
|
domStyle.set("point_styler", "display", "none");
|
$("#original_img").css("height", "24px");
|
}));
|
$("#point_styler").addClass("esriSymbolStyler");
|
$("#point_styler #original_img").attr("src", MapBrowseObj._selectLayer.renderer.symbol.url);
|
$("#point_styler #original_img").css("height", MapBrowseObj._selectLayer.renderer.symbol.height + "px");
|
$("#px_value").val(MapBrowseObj._selectLayer.renderer.symbol.height);
|
$("#point_styler").show();
|
}
|
},
|
_getStylerOptions: function (symbol) {
|
var styleModule = basic;
|
return {
|
schemes: styleModule.getSchemes({
|
theme: "default",
|
basemap: "topo",
|
geometryType: MapBrowseObj._getGeometryType(symbol)
|
})
|
}
|
|
},
|
_getGeometryType: function (symbol) {
|
var type = symbol.type;
|
return type === "picturefillsymbol" || type === "simplefillsymbol" ? "polygon" :
|
type === "cartographiclinesymbol" || type === "simplelinesymbol" ? "line" :
|
"point";
|
},
|
});
|
return Widget;
|
});
|