Lin_Ye_Fang_Huo/public/widgets/plot/js/vew.work.js

635 lines
17 KiB
JavaScript
Raw Normal View History

2023-07-18 09:04:15 +08:00
"use script"; //开发环境建议开启严格模式
2023-07-08 15:37:34 +08:00
//对应widget.js中MyWidget实例化后的对象
2023-07-18 09:04:15 +08:00
var thisWidget;
2023-07-08 15:37:34 +08:00
//当前页面业务
function initWidgetView(_thisWidget) {
2023-07-18 09:04:15 +08:00
thisWidget = _thisWidget;
2023-07-08 15:37:34 +08:00
//清除所有标号
2023-07-18 09:04:15 +08:00
$("#btn_plot_delall").click(function () {
thisWidget.deleteAll();
2023-07-08 15:37:34 +08:00
// tab2plot()
2023-07-18 09:04:15 +08:00
});
$("#btn_plot_end").click(function (e) {
thisWidget.endDraw();
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
$("#btn_plot_socket").click(function (e) {
thisWidget.socketConfig();
});
2023-07-08 15:37:34 +08:00
//是否可以编辑
2023-07-18 09:04:15 +08:00
var isedit = true;
$("#btn_plot_isedit").click(function () {
isedit = !isedit;
2023-07-08 15:37:34 +08:00
if (isedit) {
2023-07-18 09:04:15 +08:00
$(this).removeClass("active");
$(this).children().removeClass("fa-lock").addClass("fa-unlock");
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
$(this).addClass("active");
$(this).children().removeClass("fa-unlock").addClass("fa-lock");
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
thisWidget.hasEdit(isedit);
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var isPopup = false;
$("#btn_plot_ispopup").click(function () {
isPopup = !isPopup;
2023-07-08 15:37:34 +08:00
if (isPopup) {
2023-07-18 09:04:15 +08:00
$(this).removeClass("active");
$(this).children().removeClass("fa-file-text").addClass("fa-file-text-o");
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
$(this).addClass("active");
$(this).children().removeClass("fa-file-text-o").addClass("fa-file-text");
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
thisWidget.hasPopup(isPopup);
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
plotFile.initEvent();
plotlist.bindSelList();
treeWork.initEvent();
2023-07-08 15:37:34 +08:00
}
//文件处理
var plotFile = {
initEvent: function () {
2023-07-18 09:04:15 +08:00
var that = this;
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
$("#btn_plot_openfile").click(function () {
that.openPlotFile({ clear: true });
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
$("#btn_plot_openfile2").click(function () {
that.openPlotFile({ clear: false });
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
$("#btn_plot_savefile").click(function () {
thisWidget.downloadJson("标绘");
});
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
$("#input_plot_file").change(function (e) {
var file = this.files[0];
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var fileName = file.name;
var fileType = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length).toLowerCase();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
that.loadJsonOptions.symbol = null;
if (fileType == "json" || fileType == "geojson") {
let reader = new FileReader();
reader.readAsText(file, "UTF-8");
2023-07-08 15:37:34 +08:00
reader.onloadend = function (e) {
2023-07-18 09:04:15 +08:00
let json = this.result;
thisWidget.loadGeoJSON(json, that.loadJsonOptions);
that.clearPlotFile();
};
} else if (fileType == "kml") {
let reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onloadend = function (e) {
let strkml = this.result;
parent.kgUtil.toGeoJSON(strkml).then((geojoson) => {
console.log("kml2geojson", geojoson);
that.loadJsonOptions.symbol = that.kmlDefSymbol;
thisWidget.loadGeoJSON(geojoson, that.loadJsonOptions);
});
that.clearPlotFile();
};
} else if (fileType == "kmz") {
//加载input文件控件的二进制流
parent.kgUtil.toGeoJSON(file).then((geojoson) => {
console.log("kmz2geojson", geojoson);
that.loadJsonOptions.symbol = that.kmlDefSymbol;
thisWidget.loadGeoJSON(geojoson, that.loadJsonOptions);
that.clearPlotFile();
});
} else {
toastr.error("暂不支持 " + fileType + " 文件类型的数据!");
that.clearPlotFile();
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
});
},
openPlotFile: function (options) {
this.loadJsonOptions = options;
this.loadJsonOptions.flyTo = true;
$("#input_plot_file").click();
2023-07-08 15:37:34 +08:00
},
clearPlotFile: function () {
if (!window.addEventListener) {
2023-07-18 09:04:15 +08:00
document.getElementById("input_plot_file").outerHTML += ""; //IE
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
document.getElementById("input_plot_file").value = ""; //FF
2023-07-08 15:37:34 +08:00
}
},
2023-07-18 09:04:15 +08:00
//kml的默认样式处理
kmlDefSymbol: function (attr, style, featue) {
style.clampToGround = true; //贴地
let geoType = featue.geometry?.type;
if (geoType == "Point") {
return {
image: "img/marker/di3.png",
verticalOrigin: 1,
scale: 0.4,
clampToGround: true,
label: {
text: attr.name,
font_size: 18,
color: "#ffffff",
outline: true,
outlineColor: "#000000",
pixelOffsetY: -20,
scaleByDistance: true,
scaleByDistance_far: 990000,
scaleByDistance_farValue: 0.3,
scaleByDistance_near: 10000,
scaleByDistance_nearValue: 1,
},
};
}
return style;
},
};
2023-07-08 15:37:34 +08:00
//标号列表相关
var plotlist = {
//绑定标号列表切换下拉框
bindSelList: function () {
2023-07-18 09:04:15 +08:00
var that = this;
var $sel_plot_list = $("#sel_plot_list");
$.getJSON("config/plotlist.json", function (plotlist) {
var inhtml = "";
var defval;
var count = 0;
2023-07-08 15:37:34 +08:00
for (var i in plotlist) {
2023-07-18 09:04:15 +08:00
inhtml += '<option value="' + i + '">' + i + "(" + plotlist[i].length + ")</option>";
2023-07-08 15:37:34 +08:00
if (defval == null) {
2023-07-18 09:04:15 +08:00
defval = i;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
count++;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var historyval = haoutil.storage.get("plot_list");
2023-07-08 15:37:34 +08:00
if (historyval) {
2023-07-18 09:04:15 +08:00
defval = historyval;
2023-07-08 15:37:34 +08:00
}
if (defval && plotlist[defval]) {
2023-07-18 09:04:15 +08:00
that.showPlotList(plotlist[defval]);
$sel_plot_list.attr("data-value", defval);
2023-07-08 15:37:34 +08:00
}
if (count > 1) {
2023-07-18 09:04:15 +08:00
$sel_plot_list.html(inhtml);
$sel_plot_list.select();
2023-07-08 15:37:34 +08:00
$sel_plot_list.change(function () {
2023-07-18 09:04:15 +08:00
var val = $(this).attr("data-value");
var list = plotlist[val];
that.showPlotList(list);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
haoutil.storage.add("plot_list", val); //记录历史值
});
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
$sel_plot_list.hide();
$(".mp_mark").css({ "margin-top": "10px" });
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
});
2023-07-08 15:37:34 +08:00
},
_listData: null,
showPlotList: function (list) {
2023-07-18 09:04:15 +08:00
this._listData = list;
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var inhtml = "";
2023-07-08 15:37:34 +08:00
for (var i = 0; i < list.length; i++) {
2023-07-18 09:04:15 +08:00
var item = list[i];
2023-07-08 15:37:34 +08:00
if (item.hide) {
2023-07-18 09:04:15 +08:00
continue;
2023-07-08 15:37:34 +08:00
}
//处理模型url
2023-07-18 09:04:15 +08:00
if (item.style && item.style.url) {
item.style.url = thisWidget.updateTemplateValues(item.style.url);
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var defStyle = thisWidget.getDefStyle(item.edittype || item.type);
2023-07-08 15:37:34 +08:00
//使用图片图标
2023-07-18 09:04:15 +08:00
var image;
2023-07-08 15:37:34 +08:00
if (defStyle) {
2023-07-18 09:04:15 +08:00
image = defStyle.image;
2023-07-08 15:37:34 +08:00
}
if (item.style && item.style.image) {
2023-07-18 09:04:15 +08:00
image = item.style.image;
2023-07-08 15:37:34 +08:00
}
if (item.image) {
2023-07-18 09:04:15 +08:00
image = item.image;
2023-07-08 15:37:34 +08:00
}
if (image) {
2023-07-18 09:04:15 +08:00
image = thisWidget.updateTemplateValues(image);
if (image.startsWith("http") || image.startsWith("//")) {
2023-07-08 15:37:34 +08:00
//不用特殊处理
2023-07-18 09:04:15 +08:00
} else if (image.startsWith("{plotPath}")) {
image = image.replace("{plotPath}", "."); //是模块内部本级图片
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
image = "../../" + image; //相对于父级index页面的图片
2023-07-08 15:37:34 +08:00
}
inhtml +=
' <li onclick="plotlist.startPlot(' +
i +
',this)"> <i title="' +
item.name +
'" > <img src="' +
image +
2023-07-18 09:04:15 +08:00
'" onerror="plotlist.imgerrorfun();"/></i></li>';
2023-07-08 15:37:34 +08:00
}
// else if (item.style && item.style.html) {
// inhtml += ' <li onclick="plotlist.startPlot(' + i + ',this)"> <i title="' + item.name + '" > ' + item.style.html + '</i></li>';
// }
else {
//使用字体图标
2023-07-18 09:04:15 +08:00
var icon;
var clr = "#000000";
2023-07-08 15:37:34 +08:00
if (defStyle) {
2023-07-18 09:04:15 +08:00
icon = defStyle.iconClass;
clr = defStyle.color;
2023-07-08 15:37:34 +08:00
}
if (item.iconClass) {
2023-07-18 09:04:15 +08:00
icon = item.iconClass;
2023-07-08 15:37:34 +08:00
}
if (item.style && item.style.iconClass) {
2023-07-18 09:04:15 +08:00
icon = item.style.iconClass;
2023-07-08 15:37:34 +08:00
}
if (item.color) {
2023-07-18 09:04:15 +08:00
clr = item.color;
2023-07-08 15:37:34 +08:00
}
if (item.style && item.style.color) {
2023-07-18 09:04:15 +08:00
clr = item.style.color;
2023-07-08 15:37:34 +08:00
}
if (icon) {
inhtml +=
2023-07-18 09:04:15 +08:00
'<li onclick="plotlist.startPlot(' + i + ',this)"><i title="' + item.name + '" class="' + icon + '" style="color:' + clr + '"></i></li>';
2023-07-08 15:37:34 +08:00
} else {
inhtml +=
2023-07-18 09:04:15 +08:00
'<li onclick="plotlist.startPlot(' + i + ',this)"><i title="' + item.name + '" style="font-size: 13px;">' + item.name + "</i></li>";
2023-07-08 15:37:34 +08:00
}
}
}
2023-07-18 09:04:15 +08:00
$("#plotlist").html(inhtml);
2023-07-08 15:37:34 +08:00
},
imgerrorfun: function () {
2023-07-18 09:04:15 +08:00
var img = event.srcElement;
img.src = "../../../img/favicon/app-icon72x72@2x.png";
img.onerror = null;
2023-07-08 15:37:34 +08:00
},
//激活标绘
_lastLi: null,
//开始绘制
startPlot: function (idx, li) {
2023-07-18 09:04:15 +08:00
var _thisli = $(li);
_thisli.addClass("markon");
2023-07-08 15:37:34 +08:00
if (this._lastLi) {
2023-07-18 09:04:15 +08:00
this._lastLi.removeClass("markon");
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
this._lastLi = _thisli;
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var item = haoutil.system.clone(this._listData[idx] || {});
delete item.image;
2023-07-08 15:37:34 +08:00
//赋值默认样式
2023-07-18 09:04:15 +08:00
var defStyle = thisWidget.getDefStyle(item.edittype || item.type);
2023-07-08 15:37:34 +08:00
if (defStyle) {
2023-07-18 09:04:15 +08:00
item.style = item.style || {};
2023-07-08 15:37:34 +08:00
for (var i in defStyle) {
if (item.style[i] == null) {
2023-07-18 09:04:15 +08:00
item.style[i] = defStyle[i];
2023-07-08 15:37:34 +08:00
}
}
}
//赋值默认属性
item.attr = {
2023-07-18 09:04:15 +08:00
id: "",
name: "",
remark: "",
};
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
thisWidget.startDraw(item);
2023-07-08 15:37:34 +08:00
},
//绘制结束
plotEnd: function () {
//取消选中状态
if (this._lastLi) {
2023-07-18 09:04:15 +08:00
this._lastLi.removeClass("markon");
2023-07-08 15:37:34 +08:00
}
},
2023-07-18 09:04:15 +08:00
};
2023-07-08 15:37:34 +08:00
//标号树处理
2023-07-18 09:04:15 +08:00
var objFeature = {};
var treeObj;
2023-07-08 15:37:34 +08:00
var treeWork = {
initEvent: function () {
2023-07-18 09:04:15 +08:00
$("#btn_plot_addgroup").click(function (e) {
thisWidget.editGroupName();
});
$("#btn_plot_delAllGroup").click(function (e) {
thisWidget.deleteEmptyLayer();
});
bindRightMenuEvnet(); //右键
thisWidget.showLayerTree();
2023-07-08 15:37:34 +08:00
},
loadData: function (arrGroup) {
//初始化树 http://www.treejs.cn/v3/api.php
var setting = {
check: {
enable: true,
},
edit: {
drag: {
isMove: true,
},
showRemoveBtn: false,
showRenameBtn: false,
enable: true,
},
data: {
simpleData: {
enable: true,
},
},
callback: {
beforeDrag: treeOverlays_beforeDrag,
beforeDrop: treeOverlays_beforeDrop,
onDrop: treeOverlays_onDrop,
onCheck: treeOverlays_onCheck,
onRightClick: treeOverlays_OnRightClick,
onClick: treeOverlays_onClick,
onRemove: treeOverlays_onRemove,
},
2023-07-18 09:04:15 +08:00
};
2023-07-08 15:37:34 +08:00
//构造树节点
2023-07-18 09:04:15 +08:00
objFeature = {};
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var zNodes = [];
2023-07-08 15:37:34 +08:00
for (var i = 0; i < arrGroup.length; i++) {
2023-07-18 09:04:15 +08:00
var layer = arrGroup[i];
var arrGraphic = layer.getGraphics();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var name = layer.name + "(" + arrGraphic.length + "个)";
2023-07-08 15:37:34 +08:00
if (layer.isActivate) {
2023-07-18 09:04:15 +08:00
name += "-激活";
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var oldNode = treeObj && treeObj.getNodeByParam("id", layer.uuid);
2023-07-08 15:37:34 +08:00
//添加分组
var groupNode = {
2023-07-18 09:04:15 +08:00
id: layer.uuid,
2023-07-08 15:37:34 +08:00
pId: layer.pid,
name: name,
2023-07-18 09:04:15 +08:00
icon: "img/tree/folder.png",
2023-07-08 15:37:34 +08:00
isGroup: true,
checked: layer.show,
open: oldNode && oldNode.open, //是否展开分组
2023-07-18 09:04:15 +08:00
};
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
zNodes.push(groupNode);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
objFeature[groupNode.id] = layer;
2023-07-08 15:37:34 +08:00
for (var j = 0, len = arrGraphic.length; j < len; j++) {
2023-07-18 09:04:15 +08:00
var graphic = arrGraphic[j];
2023-07-08 15:37:34 +08:00
//添加标号
var plotNode = {
2023-07-18 09:04:15 +08:00
id: graphic.uuid,
2023-07-08 15:37:34 +08:00
pId: groupNode.id,
2023-07-18 09:04:15 +08:00
name: graphic.attr?.name || graphic.name || "未命名",
2023-07-08 15:37:34 +08:00
checked: graphic.show,
2023-07-18 09:04:15 +08:00
icon: "img/tree/plot.png",
};
zNodes.push(plotNode);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
objFeature[plotNode.id] = graphic;
2023-07-08 15:37:34 +08:00
}
}
2023-07-18 09:04:15 +08:00
$.fn.zTree.destroy();
treeObj = $.fn.zTree.init($("#treeOverlays"), setting, zNodes);
2023-07-08 15:37:34 +08:00
},
2023-07-18 09:04:15 +08:00
updateNode: function (graphic) {
var treeObj = $.fn.zTree.getZTreeObj("treeOverlays");
var node = treeObj.getNodeByParam("id", graphic.uuid, null);
if (node) {
node.name = graphic.attr?.name || graphic.name || "未命名";
var show = graphic.isAdded && graphic.show;
if (node.checked != show) {
node.checkedOld = node.checked;
node.checked = show;
}
treeObj.updateNode(node);
}
},
};
2023-07-08 15:37:34 +08:00
//===================================单击定位图层====================================
function treeOverlays_onClick(event, treeId, treeNode) {
if (treeNode == null || treeNode.id == null) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var layer = objFeature[treeNode.id];
2023-07-08 15:37:34 +08:00
if (layer == null) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
thisWidget.flyTo(layer);
2023-07-08 15:37:34 +08:00
}
//===================================勾选显示隐藏图层====================================
function treeOverlays_onCheck(e, treeId, setreeNode) {
//获得所有改变check状态的节点
2023-07-18 09:04:15 +08:00
var changedNodes = treeObj.getChangeCheckedNodes();
2023-07-08 15:37:34 +08:00
for (var i = 0; i < changedNodes.length; i++) {
2023-07-18 09:04:15 +08:00
var treeNode = changedNodes[i];
treeNode.checkedOld = treeNode.checked;
// if (treeNode.check_Child_State == 1) {
// // 0:无子节点被勾选, 1:部分子节点被勾选, 2:全部子节点被勾选, -1:不存在子节点 或 子节点全部设置为 nocheck = true
// continue
// }
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var layer = objFeature[treeNode.id];
2023-07-08 15:37:34 +08:00
if (layer == null) {
2023-07-18 09:04:15 +08:00
continue;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
layer.show = treeNode.checked;
2023-07-08 15:37:34 +08:00
}
}
//===================================右键菜单====================================
2023-07-18 09:04:15 +08:00
var lastRightClickTreeId;
var lastRightClickTreeNode;
2023-07-08 15:37:34 +08:00
function treeOverlays_OnRightClick(event, treeId, treeNode) {
if (treeNode == null || objFeature[treeNode.id] == null) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
//右击时的节点
2023-07-18 09:04:15 +08:00
lastRightClickTreeId = treeId;
lastRightClickTreeNode = treeNode;
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var top = event.clientY;
var left = event.clientX;
var maxtop = document.body.offsetHeight - 100;
var maxleft = document.body.offsetWidth - 100;
2023-07-08 15:37:34 +08:00
if (top > maxtop) {
2023-07-18 09:04:15 +08:00
top = maxtop;
2023-07-08 15:37:34 +08:00
}
if (left > maxleft) {
2023-07-18 09:04:15 +08:00
left = maxleft;
2023-07-08 15:37:34 +08:00
}
if (treeNode.isGroup) {
2023-07-18 09:04:15 +08:00
$("#plot_rMenu_group .group").show();
$("#plot_rMenu_group .plot").hide();
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
$("#plot_rMenu_group .group").hide();
$("#plot_rMenu_group .plot").show();
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
$("#plot_rMenu_group")
2023-07-08 15:37:34 +08:00
.css({
2023-07-18 09:04:15 +08:00
top: top + "px",
left: left + "px",
2023-07-08 15:37:34 +08:00
})
2023-07-18 09:04:15 +08:00
.show();
$("body").bind("mousedown", onBodyMouseDown);
2023-07-08 15:37:34 +08:00
}
function bindRightMenuEvnet() {
2023-07-18 09:04:15 +08:00
$("#plot_rMenu_group li").on("click", function () {
hideRMenu();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
var type = $(this).attr("data-type");
moveNodeAndLayer(type);
});
2023-07-08 15:37:34 +08:00
}
function onBodyMouseDown(event) {
2023-07-18 09:04:15 +08:00
if (!(event.target.id == "plot_rMenu_group" || $(event.target).parents("#plot_rMenu_group").length > 0)) {
hideRMenu();
2023-07-08 15:37:34 +08:00
}
}
function hideRMenu() {
2023-07-18 09:04:15 +08:00
$("body").unbind("mousedown", onBodyMouseDown);
$("#plot_rMenu_group").hide();
2023-07-08 15:37:34 +08:00
}
//移动节点及图层位置
function moveNodeAndLayer(type) {
2023-07-18 09:04:15 +08:00
var thisNode = lastRightClickTreeNode;
var thisLayer = objFeature[thisNode.id];
2023-07-08 15:37:34 +08:00
switch (type) {
default:
2023-07-18 09:04:15 +08:00
break;
case "g_act": //置为激活分组
thisWidget.changeSelectedLayer(thisLayer);
break;
case "g_name": //重命名分组
thisWidget.editGroupName(thisLayer);
break;
case "g_del": //删除分组
2023-07-08 15:37:34 +08:00
// if (thisWidget.checkRemoveGroup(thisLayer)) {
2023-07-18 09:04:15 +08:00
treeObj.removeNode(thisNode);
thisWidget.deleteLayer(thisLayer);
2023-07-08 15:37:34 +08:00
// }
2023-07-18 09:04:15 +08:00
break;
case "p_del": //删除标号
treeObj.removeNode(thisNode);
thisWidget.deleteEntity(thisLayer);
break;
case "g_json": //导出GeoJson
thisWidget.downloadJson("标绘分组_" + thisNode.name, thisLayer);
break;
case "g_kml":
thisWidget.downloadKml("标绘分组_" + thisNode.name, thisLayer);
break;
case "p_json": //导出GeoJson
thisWidget.downloadJson(thisNode.name, thisLayer);
break;
case "p_kml":
thisWidget.downloadKml(thisNode.name, thisLayer);
break;
case "g_imp": //导入GeoJson到分组中
plotFile.openPlotFile({ layer: thisLayer.name });
break;
2023-07-08 15:37:34 +08:00
}
}
//===================================删除处理====================================
function treeOverlays_onRemove(event, treeId, treeNode) {
if (treeNode == null || treeNode.id == null) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
2023-07-18 09:04:15 +08:00
var layer = objFeature[treeNode.id];
2023-07-08 15:37:34 +08:00
if (layer == null) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
if (treeNode.isGroup) {
2023-07-18 09:04:15 +08:00
thisWidget.deleteLayer(layer);
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
thisWidget.deleteEntity(layer);
2023-07-08 15:37:34 +08:00
}
}
//===================================拖拽调整层次处理====================================
function treeOverlays_beforeDrag(treeId, treeNodes) {
for (var i = 0, l = treeNodes.length; i < l; i++) {
if (treeNodes[i].isGroup) {
2023-07-18 09:04:15 +08:00
return false; //禁止拖拽
2023-07-08 15:37:34 +08:00
}
}
2023-07-18 09:04:15 +08:00
return true;
2023-07-08 15:37:34 +08:00
}
function treeOverlays_beforeDrop(treeId, treeNodes, targetNode, moveType) {
if (targetNode && targetNode.isGroup) {
2023-07-18 09:04:15 +08:00
return true;
2023-07-08 15:37:34 +08:00
} else {
2023-07-18 09:04:15 +08:00
return false;
2023-07-08 15:37:34 +08:00
} //禁止拖拽到我身上
}
function treeOverlays_onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy) {
if (!targetNode) {
2023-07-18 09:04:15 +08:00
return;
2023-07-08 15:37:34 +08:00
}
// var group = targetNode.name //分组名称
2023-07-18 09:04:15 +08:00
var layerGroup = objFeature[targetNode.id]; //分组
var graphic = objFeature[treeNodes[0].id];
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
thisWidget.moveToLayer(graphic, layerGroup);
2023-07-08 15:37:34 +08:00
}