/**
|
* 分屏时间选择widget
|
* @author Liuyl
|
* @date 2015/10/15
|
*/
|
define([
|
"dojo/_base/declare",
|
"dojo/_base/array",
|
"dojo/_base/lang",
|
"iframe/jcyj/js/dataShow.js",
|
"dojo/dom",
|
"dojo/dom-style",
|
"dojo/dom-class",
|
"dojo/dom-attr",
|
"dojo/dom-construct",
|
"dojo/topic",
|
"dijit/_WidgetBase",
|
"dijit/_TemplatedMixin",
|
"dojo/text!controls/Splittime/SplittimeControl.html",
|
"base/BaseControl",
|
"base/AppEvent",
|
"base/ConfigData",
|
"controls/Splittime/SplittimeControl",
|
"dojo/on",
|
"esri/layers/ArcGISDynamicMapServiceLayer",
|
"esri/InfoTemplate"
|
], function (declare,
|
arrayUtil,
|
lang,
|
dataShow,
|
dom,
|
domStyle,
|
domClass,
|
domAttr,
|
domConstruct,
|
topic,
|
_WidgetBase,
|
_TemplatedMixin,
|
template,
|
BaseControl,
|
AppEvent,
|
ConfigData,
|
SplittimeControl,
|
on,
|
ArcGISDynamicMapServiceLayer,
|
InfoTemplate) {
|
var Widget = declare("SplittimeControl", [BaseControl], {
|
templateString: template,
|
SplitObj: null,
|
//selectLayer:null,
|
constructor: function (options) {
|
},
|
startup: function () {
|
SplitObj = this;
|
var tu = domConstruct.create("select", {
|
class: "split_tuselect",
|
}, this.domNode);
|
var layer = domConstruct.create("select", {
|
class: "split_layerselect",
|
}, this.domNode);
|
// var times = domConstruct.create("select", {
|
// class: "split_timesselect"
|
// }, this.domNode);
|
// domConstruct.create("option", {
|
// value:2016,
|
// innerHTML: 2016,
|
// selected:true
|
// }, times);
|
// $(times).append("<option selected=\"selected\">2016</option><option>2017</option><option >2018</option>");
|
// setlayer(times.value);
|
setlayer();
|
|
function setlayer(year) {
|
$.ajax({
|
type: "get",
|
// url: ConfigData.ajaxURL,
|
url:getNativePath() + "resources/queryResourcesTree.do",
|
data: {
|
"limit": 1000,
|
// "Q_resourcesSpare1_S_EQ": year
|
},
|
dataType: "json",
|
async: false,
|
success: function (result) {
|
$(tu).empty().append("<option value=''>请选择目录</option>");
|
$(layer).empty().append("<option value=''>请选择图层</option>");
|
var resultObj = result.data;
|
for (var i = 0; i < resultObj.length; i++) {
|
if (resultObj[i].resourcesPid == 0) {
|
$(tu).append("<option value=\"" + resultObj[i].resourcesId + "\">" + resultObj[i].resourcesName + "</option>");
|
}
|
}
|
},
|
error: function (e) {
|
console.log(e);
|
alert("请求失败");
|
}
|
});
|
}
|
//
|
// on(times, "change", lang.hitch(this, function () {
|
// if (this.id == "SplittimeControl_0") {
|
// var mianSelectLayer = this.map.getLayer('mianSelectLayer');
|
// if (mianSelectLayer) {
|
// this.map.removeLayer(mianSelectLayer);
|
// }
|
// }
|
// else {
|
// var otherSelectLayer = this.map.getLayer('otherSelectLayer');
|
// if (otherSelectLayer) {
|
// this.map.removeLayer(otherSelectLayer);
|
// }
|
// }
|
// setlayer(times.value);
|
// }));
|
on(tu, "change", lang.hitch(this, function () {
|
$.ajax({
|
type: "get",
|
// url: ConfigData.ajaxURL,
|
url:getNativePath() + "resources/queryResourcesTree.do",
|
data: {
|
"limit": 1000,
|
// "Q_resourcesSpare1_S_EQ": times.value
|
},
|
dataType: "json",
|
async: false,
|
success: function (result) {
|
var values = tu.value;
|
$(layer).empty().append("<option value=''>请选择图层</option>");
|
var resultObj = result.data;
|
for (var i = 0; i < resultObj.length; i++) {
|
if (values == resultObj[i].resourcesPid) {
|
$(layer).append("<option value=\"" + resultObj[i].resourcesUrl + "\">" + resultObj[i].resourcesName + "</option>");
|
}
|
}
|
},
|
error: function (e) {
|
console.log(e);
|
alert("请求失败");
|
}
|
});
|
}));
|
on(layer, "change", lang.hitch(this, function () {
|
var URL = layer.value.substring(0,layer.value.lastIndexOf("/"));
|
if (this.id == "SplittimeControl_0") {
|
var mianSelectLayer = this.map.getLayer('mianSelectLayer');
|
if (mianSelectLayer) {
|
this.map.removeLayer(mianSelectLayer);
|
}
|
var selectLayer = new ArcGISDynamicMapServiceLayer(URL);
|
var i = layer.value.substring(layer.value.lastIndexOf('/') + 1, layer.value.length) * 1;
|
selectLayer.on("load", lang.hitch(this,function () {
|
selectLayer.setVisibleLayers([i]);
|
selectLayer.id = 'mianSelectLayer';
|
var template = new InfoTemplate();
|
template.setTitle(SplitObj._getGraphicTitle);
|
template.setContent(SplitObj._getTextContent);
|
var templates = {};
|
templates[i] = {
|
infoTemplate: template
|
};
|
selectLayer.setInfoTemplates(templates);
|
this.map.addLayer(selectLayer);
|
}));
|
}
|
else {
|
var otherSelectLayer = this.map.getLayer('otherSelectLayer');
|
if (otherSelectLayer) {
|
this.map.removeLayer(otherSelectLayer);
|
}
|
var selectLayer = new ArcGISDynamicMapServiceLayer(URL);
|
var i = layer.value.substring(layer.value.lastIndexOf('/') + 1, layer.value.length) * 1;
|
selectLayer.on("load", lang.hitch(this,function () {
|
selectLayer.setVisibleLayers([i]);
|
selectLayer.id = 'otherSelectLayer';
|
var template = new InfoTemplate();
|
template.setTitle(SplitObj._getGraphicTitle);
|
template.setContent(SplitObj._getTextContent);
|
var templates = {};
|
templates[i] = {
|
infoTemplate: template
|
};
|
selectLayer.setInfoTemplates(templates);
|
this.map.addLayer(selectLayer);
|
}));
|
}
|
}));
|
},
|
_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];
|
}
|
return title;
|
},
|
_getTextContent: function (graphic) {
|
var content = "";
|
content += "<div class='con'>";
|
var layer = graphic.getLayer();
|
for (var a = 0; a < layer.fields.length; a++) {
|
var ming = layer.fields[a].name;
|
var ali = layer.fields[a].alias;
|
if (ali != "OBJECTID") {
|
var regs = new RegExp("[\\u4E00-\\u9FFF]+", "g");
|
if (regs.test(ali) && graphic.attributes[ming] != null) {
|
content += "<div>" + layer.fields[a].alias + ":<b>" + graphic.attributes[ming] + "</b></div>";
|
}
|
}
|
}
|
content += "</div>";
|
//移除其他模块添加的<a>标签
|
if ($('.actionList .img').length != 0) {
|
$('.actionList .img').remove();
|
}
|
if ($('.actionList .qj').length != 0) {
|
$('.actionList .qj').remove();
|
}
|
if ($('.actionList .vedio').length != 0) {
|
$('.actionList .vedio').remove();
|
}
|
if ($('.actionList .msg').length != 0) {
|
$('.actionList .msg').remove();
|
}
|
return content;
|
}
|
});
|
return Widget;
|
});
|