//工具条标注操作

function Label() {
    Label.graphic = null;
    Label.mapClickHandler = null;
}

Label.init = function () {
    Label();
};
//添加路段标注
Label.addRoadLabel = function (html) {
    var Graphic = MapAPI.getGraphic();
    var Draw = MapAPI.getDraw();
    var Color = MapAPI.getColor();
    if (!Label.draw) {
        Label.draw = new Draw(MapAPI.getMap());
    }
    var PictureFillSymbol = MapAPI.getPictureFillSymbol();
    var SimpleLineSymbol = MapAPI.getSimpleLineSymbol();
    var SimpleFillSymbol = MapAPI.getSimpleFillSymbol();
    var CartographicLineSymbol = MapAPI.getCartographicLineSymbol();
    var lineSymbol = new CartographicLineSymbol(
        CartographicLineSymbol.STYLE_SOLID,
        new Color([255, 0, 0]), 5,
        CartographicLineSymbol.CAP_ROUND,
        CartographicLineSymbol.JOIN_MITER, 5
    );
    if (!MapAPI.getMap().isPan) {
        MapAPI.getMap().enableMapNavigation();
        Label.draw.deactivate();
        Label.draw = null;
    } else {
        MapAPI.getMap().disableMapNavigation();
        Label.draw.activate('polyline');
        Label.draw.on("draw-end", function (evt) {
            console.log("evt.geometry", evt.geometry);
            var positionStr = '';
            for (var i = 0, len = evt.geometry.paths[0].length; i < len; i++) {
                var x = evt.geometry.paths[0][i][0];
                var y = evt.geometry.paths[0][i][1];
                if (i == len - 1) {
                    positionStr += x + ',' + y;
                } else {
                    positionStr += x + ',' + y + ";";
                }
            }
            var attr = {position: positionStr};
            var InfoTemplate = MapAPI.getInfoTemplate();
            var Point = MapAPI.getPoint();
            var point = new Point(evt.geometry.paths[0][evt.geometry.paths[0].length - 1][0], evt.geometry.paths[0][evt.geometry.paths[0].length - 1][1]);
            var infoTemplate = new InfoTemplate("绘制路段", html);
            Label.graphic = new Graphic(evt.geometry, lineSymbol, attr, infoTemplate);
            MapAPI.getRoadGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(point).then(function () {
                MapAPI.getMap().infoWindow.setTitle(infoTemplate.title);
                MapAPI.getMap().infoWindow.setContent(infoTemplate.content);
                MapAPI.getMap().infoWindow.show(point, MapAPI.getMap().getInfoWindowAnchor(point));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelRoad();
                    hide.remove();
                });
            });
            MapAPI.getMap().enableMapNavigation();
            Label.draw.deactivate();
            Label.draw = null;
        });
    }
};
//添加监控标注
Label.addCameraLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "tdmc": "标注摄像头"};
            Label.graphic = MapUtil.addPoint(data, html);
            MapAPI.getCameraGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelCamera();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
};

// 建筑物标注
Label.addJtjzwLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "jzwmc": "标注建筑物"};
            Label.graphic = MapUtil.addJtjzwPoint(data, html);
            MapAPI.getJtjzwGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelJtjzw();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 标志牌标注
Label.addNhywjtbzLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "bzmc": "标注标志牌"};
            Label.graphic = MapUtil.addNhywjtbzPoint(data, html);
            MapAPI.getNhywjtbzGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelNhywjtbz();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 交通标线标注
Label.addJtbxLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "bxmc": "标注标线"};
            Label.graphic = MapUtil.addJtbxPoint(data, html);
            MapAPI.getJtbxGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelJtbx();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 交通护栏标注
Label.addJthlLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "hlmc": "标注护栏"};
            Label.graphic = MapUtil.addJthlPoint(data, html);
            MapAPI.getJthlGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelJthl();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 交通信号灯标注
Label.addJtxhdLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "xhdmc": "标注信号灯"};
            Label.graphic = MapUtil.addJtxhdPoint(data, html);
            MapAPI.getJtxhdGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelJtxhd();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 交通诱导屏标注
Label.addJtydpLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "ledmc": "标注诱导屏"};
            Label.graphic = MapUtil.addJtydpPoint(data, html);
            MapAPI.getJtydpGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelJtydp();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}

// 地磁标注
Label.adddcLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"longitude": mapPoint.x, "latitude": mapPoint.y, "name": "标注地磁","detectortype":"GVD"};
            Label.graphic = MapUtil.adddetectorPoint(data, html);
            MapAPI.getJtdcGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.canceldetector("GVD");
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}


// 微波标注
Label.addwbLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"longitude": mapPoint.x, "latitude": mapPoint.y, "name": "标注微波","detectortype":"SMARTSENSOR"};
            Label.graphic = MapUtil.adddetectorPoint(data, html);
            MapAPI.getJtwbGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.canceldetector("SMARTSENSOR");
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}
// 雷达标注
Label.addldLabel = function (html) {
    if (Label.mapClickHandler) {
        Label.mapClickHandler.remove();
    }
    Label.mapClickHandler = MapAPI.getMap().on("click", function (e) {
        if (!e.graphic) {
            var mapPoint = MapAPI.getMap().toMap(e.screenPoint);
            var data = {"jd": mapPoint.x, "wd": mapPoint.y, "ldmc": "标注雷达"};
            Label.graphic = MapUtil.adddLdPoint(data, html);
            MapAPI.getJtldGraphicsLayer().add(Label.graphic);
            MapAPI.getMap().setInfoWindowOnClick(true);
            MapAPI.getMap().centerAt(Label.graphic.geometry).then(function () {
                MapAPI.getMap().infoWindow.setTitle(Label.graphic.getInfoTemplate().title);
                MapAPI.getMap().infoWindow.setContent(Label.graphic.getInfoTemplate().content);
                MapAPI.getMap().infoWindow.show(Label.graphic.geometry, MapAPI.getMap().getInfoWindowAnchor(e.screenPoint));
                MapAPI.getMap().infoWindow.setFeatures([Label.graphic]);
                var hide = MapAPI.getMap().infoWindow.on("hide", function () {
                    Label.cancelld();
                    hide.remove();
                });
            });
            if (Label.mapClickHandler) {
                Label.mapClickHandler.remove();
            }
        }
    });
}


//标注监控设备确认
Label.confirmCamera = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var sxt = $("#sxt").val();
    var xh = $("#videoId").val();
    var params = {"jd": jd, "wd": wd, "sxt": sxt, "xh": xh};
//		console.log("confirmCamera： ",params);
    if (sxt.trim() != '') {
        var data = {"jd": jd, "wd": wd, "tdmc": sxt, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + sxt + "</span></div>" +
            "<ul  class='bcontentItem'><li onclick='Label.realtimeVideo(\"" + xh + "\")'>视频</li>" +
            //							"<li onclick='Label.artificialAlarm(\""+xh+"\")'>人工告警</li>" +recordNav
            "<li onclick='Label.recordNav(\"" + xh + "\")'>录像</li>" +
            "<li onclick=' Label.editvideo(\"" + xh + "\")'>编辑</li>" +
            "<li onclick=' Label.detailInformation(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeCamera(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getCameraGraphicsLayer().remove(Label.graphic);
        MapUtil.addPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!update_Sbtdspsr.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("设备添加成功！");
                } else {
                    $.showMsg("设备添加失败!");
                }
            }
        });
    } else {
        $.showMsg("监控名称不能为空!");
    }
};

//标注路段设备确认
Label.confirmRoad = function () {

    var roadPart = $("#roadPart").val();
//	console.log("=======  Label.confirmRoad ========");
    var roadName = $("#roadName").val();
    var sxt = $("#sxt").val();
    var position = $("#position").val();
    var sbbh = $("#sbbh").val();
    var tdbh = $("#tdbh").val();
    var xh = $("#xh").val();
    var uuid = $.uniqueId();
    var params = {
        roadName: roadName, channelName: sxt, roadGridPosition: position,
        roadNumber: xh, vdid: sbbh, channelId: tdbh, remarks1: roadPart,
        remarks2: '1', roadGridId: uuid
    };
    var ssld = roadPart + "(" + roadName + ")";
// 	console.log("=======  Label.confirmRoad ========",params);
    if (roadPart.trim() != '' && sxt.trim() != '' && roadName.trim() != '') {

        $.ajax({										// 数据入库
            type: 'post',
            dataType: 'json',
            url: 'trafficroadgridinfoAction!insert_Trafficroadgridinfo.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {

                    var data = {"position": position, "sxt": roadName, "xh": uuid, "tdmc": roadPart};
                    var html = "<div class='bcontent'><div><span style='color:#75767A'>" + ssld + "</span></div>" +
                        "<ul  class='bcontentItem'>" +
                        "<li onclick=' Label.editroad(\"" + uuid + "\")'>编辑</li>" +
                        "<li onclick=' Label.detailInfoRoad(\"" + uuid + "\")'>详情</li>" +
                        "<li onclick='Label.deleteRoad(\"" + uuid + "\")'>删除路段</li>" +
                        "</ul></div>";

                    var result = [[]];
                    if (position != null && position.trim() != '') {
                        var positionArr = position.split(';');
                        for (var j = 0; j < positionArr.length; j++) {
                            result[0].push([positionArr[j].split(',')[0], positionArr[j].split(',')[1]]);
                        }
                    }
                    data.geometry = result;
                    MapUtil.addLine(data, html);
                    MapAPI.getMap().infoWindow.hide();
                    $.showMsg("路段标注成功！");
                } else {
                    $.showMsg("路段标注失败!");
                }
            }
        });
    } else {
        $.showMsg("监控名称路段名称,所属路段不能为空!");
    }
};
//标注建筑物确认
Label.confirmJtjzw = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var jzwmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJjzwmc": jzwmc, "XGTJxh": xh};
//		console.log("confirmCamera： ",params);
    if (jzwmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "jzwmc": jzwmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + jzwmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editJjzw(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationJtjzw(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeJtjzw(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJtjzwGraphicsLayer().remove(Label.graphic);
        MapUtil.addJtjzwPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtjzwxxbAction!update_Nhywjtjzwxxb.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("建筑物添加成功！");
                } else {
                    $.showMsg("建筑物添加失败!");
                }
            }
        });
    } else {
        $.showMsg("建筑物名称不能为空!");
    }
};
// 标注标志牌确认
Label.confirmNhywjtbz = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var bzmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJbzmc": bzmc, "XGTJxh": xh};
//	console.log("confirmCamera： ",params);
    if (bzmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "bzmc": bzmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + bzmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editbzp(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationNhywjtbz(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeNhywjtbz(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getNhywjtbzGraphicsLayer().remove(Label.graphic);
        MapUtil.addNhywjtbzPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbzglAction!update_Nhywjtbzgl.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("标志牌添加成功！");
                } else {
                    $.showMsg("标志牌添加失败!");
                }
            }
        });
    } else {
        $.showMsg("标志牌名称不能为空!");
    }
}

// 交通标线确认
Label.confirmJtbx = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var bxmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJbxmc": bxmc, "XGTJxh": xh};
//	console.log("confirmCamera： ",params);
    if (bxmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "bxmc": bxmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + bxmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editbx(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationJtbx(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeJtbx(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJtbxGraphicsLayer().remove(Label.graphic);
        MapUtil.addJtbxPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbxglAction!update_Nhywjtbxgl.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("标线添加成功！");
                } else {
                    $.showMsg("标线添加失败!");
                }
            }
        });
    } else {
        $.showMsg("标线名称不能为空!");
    }
}

// 交通护栏确认
Label.confirmJthl = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var hlmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJhlmc": hlmc, "XGTJxh": xh};
//	console.log("confirmCamera： ",params);
    if (hlmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "hlmc": hlmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + hlmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.edithl(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationJthl(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeJthl(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJthlGraphicsLayer().remove(Label.graphic);
        MapUtil.addJthlPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjthlglAction!update_Nhywjthlgl.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("护栏添加成功！");
                } else {
                    $.showMsg("护栏添加失败!");
                }
            }
        });
    } else {
        $.showMsg("护栏名称不能为空!");
    }
}

// 交通信号灯确认
Label.confirmJtxhd = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var xhdmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJxhdmc": xhdmc, "XGTJxh": xh};
//	console.log("confirmCamera： ",params);
    if (xhdmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "xhdmc": xhdmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + xhdmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editxhd(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationJtxhd(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeJtxhd(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJtxhdGraphicsLayer().remove(Label.graphic);
        MapUtil.addJtxhdPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtxhdglAction!update_Nhywjtxhdgl.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("信号灯添加成功！");
                } else {
                    $.showMsg("信号灯添加失败!");
                }
            }
        });
    } else {
        $.showMsg("信号灯名称不能为空!");
    }
}

//交通诱导屏确认
Label.confirmJtydp = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var ledmc = $("#sxt").val();
    var xh = $("#xh").val();
    var params = {"jd": jd, "wd": wd, "XGTJledmc": ledmc, "XGTJxh": xh};
//	console.log("confirmCamera： ",params);
    if (ledmc.trim() != '') {
        var data = {"jd": jd, "wd": wd, "ledmc": ledmc, "xh": xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + ledmc + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editydp(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationJtydp(\"" + xh + "\")'>详情</li>" +
            "<li onclick='removeJtydp(\"" + xh + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJtydpGraphicsLayer().remove(Label.graphic);
        MapUtil.addJtydpPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtledydpglAction!update_Nhywjtledydpgl.do',
            data: params,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("诱导屏添加成功！");
                } else {
                    $.showMsg("诱导屏添加失败!");
                }
            }
        });
    } else {
        $.showMsg("诱导屏名称不能为空!");
    }
}

//标注监控设备取消
Label.cancelCamera = function () {
    MapAPI.getCameraGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注监控设备取消成功!");
};
//标注路段设备取消
Label.cancelRoad = function () {
    MapAPI.getRoadGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注路段设备取消成功!");
};
//标注建筑物取消
Label.cancelJtjzw = function () {
    MapAPI.getJtjzwGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注建筑物取消成功!");
};
//标注标志牌取消
Label.cancelNhywjtbz = function () {
    MapAPI.getNhywjtbzGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注标志牌取消成功!");
}
//标注标线取消
Label.cancelJtbx = function () {
    MapAPI.getJtbxGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注标线取消成功!");
}
// 标注护栏取消
Label.cancelJthl = function () {
    MapAPI.getJthlGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注护栏取消成功!");
}
// 标注信号灯取消
Label.cancelJtxhd = function () {
    MapAPI.getJtxhdGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注信号灯取消成功!");
}
//标注诱导屏取消
Label.cancelJtydp = function () {
    MapAPI.getJtydpGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注诱导屏取消成功!");
}

//监控设备填充数据
Label.fillCamera = function (o) {
//	console.log("fillCamera：",o);
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));
//	console.log("数据填充: ",dataJson);
    $('#videoId').val(dataJson.xh);
    $("#sbbh").val(dataJson.sbbh);
    $("#tdbh").val(dataJson.tdbh);
    $("#sxt").val(dataJson.tdmc);
    $("#xh").val(dataJson.roadId);
    var roadName = $("#roadName").val();
    if (roadName == '' || roadName == null) {
        $("#roadName").val(dataJson.roadName);
    }
};
//路段填充数据
Label.fillRoad = function (o) {
//	console.log("fillRoad：",o);
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));

    $("#roadName").val(dataJson.roadname);
    $("#xh").val(dataJson.roadid);
};

//建筑物填充数据
Label.fillJtjzw = function (o) {
//	console.log("fillCamera：",o);
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));
//	console.log("数据建筑物填充: ",dataJson);

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.jzwmc);
    $("#jzwbh").val(dataJson.jzwbh);
};

// 标志牌填充数据
Label.fillNhywjtbz = function (o) {
//	console.log("fillCamera：",o);
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));
//	console.log("数据建筑物填充: ",dataJson);

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.bzmc);
    $("#bzbh").val(dataJson.bzbh);
}

// 标线填充数据
Label.fillJtbx = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.bxmc);
    $("#bxbh").val(dataJson.bxbh);
}

// 护栏填充数据
Label.fillJthl = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.hlmc);
    $("#hlbh").val(dataJson.hlbh);
}

// 交通信号灯填充数据
Label.fillJtxhd = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.xhdmc);
    $("#xhdbh").val(dataJson.xhdbh);
}

//交通诱导屏填充数据
Label.fillJtydp = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));

    $('#xh').val(dataJson.xh);
    $("#sxt").val(dataJson.ledmc);
    $("#ledbh").val(dataJson.ledbh);
}

//监控设备查询功能
Label.cameraSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/camera-search.jsp";
    top.windowid = top.$.createWin({
        title: '监控设备查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
};
//路段查询功能
Label.roadSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/road-search.jsp";
    top.windowid = top.$.createWin({
        title: '路段查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
};

//删除路段
Label.deleteRoad = function (xh) {
    console.log("删除路段：", xh);

    $.ajax({										// 数据入库
        type: 'post',
        dataType: 'json',
        url: 'trafficroadgridinfoAction!delete_Trafficroadgridinfo.do',
        data: {"roadGridId": xh},
        success: function (flag) {
            if (flag == "success") {
                var graphicArr = MapAPI.getRoadGraphicsLayer().graphics;
                var graphic = null;
                for (var i = 0, len = graphicArr.length; i < len; i++) {
                    if (graphicArr[i].attributes.xh == xh) {
                        graphic = graphicArr[i];
                        break;
                    }
                }
                if (graphic != null) {
                    MapAPI.getRoadGraphicsLayer().remove(graphic);
                    MapAPI.getMap().infoWindow.hide();
                    $.showMsg("标注路段删除成功!");
                }
            } else {
                $.showMsg("标注路段删除失败!");
            }
        }
    });

    /*var graphicArr=MapAPI.getRoadGraphicsLayer().graphics;
	var graphic=null;
	for(var i=0,len=graphicArr.length;i<len;i++){
		if(graphicArr[i].attributes.xh==xh){
			graphic=graphicArr[i];
			break;
		}
	}
	if(graphic!=null){
		MapAPI.getRoadGraphicsLayer().remove(graphic);
		MapAPI.getMap().infoWindow.hide();
		$.showMsg("标注路段设备删除成功!");
	}*/
};

//路段详细信息
Label.detailInfoRoad = function (xh) {
    var sysUrl = top.sysUrl;
    windowId = top.$.createWin({
        title: '详细信息',
        width: 650,
        height: 400,
        data: {"roadGridId": xh},
        url: sysUrl + "/yw/szmap/jx/roadDetail.jsp"
    });
};

//实时视频
Label.realtimeVideo = function (xh) {
//	console.log("xh：",xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!get_SbtdspsrDetail.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    //				console.log("res：",res);

                    res.video = "1";
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '实时视频',
                        width: 720,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/video.jsp"
                    });

                }
            }
        })
    }


};
//人工告警
Label.artificialAlarm = function (xh) {
//	console.log("xh：",xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!get_SbtdspsrDetail.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    //				console.log("res：",res);
                    res.video = "1";
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '录像',
                        width: 650,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/video.jsp"
                    });

                }
            }
        })
    }


};

// 录像
Label.recordNav = function (xh) {
//	console.log("xh：",xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!get_SbtdspsrDetail.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    //				console.log("res：",res);
                    res.video = "2";
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '录像',
                        width: 720,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/video.jsp"
                    });

                }
            }
        })
    }
};
//查看设备维修信息
Label.repaire = function (sbbh, tdbh) {
//	console.log("xh：",xh);
    var sysUrl = top.sysUrl;
    windowId = top.$.createWin({
        title: '维修信息',
        width: 890,
        height: 400,
        scrolling: true,
        url: sysUrl + "/yw/szmap/jobinfo/ywrepairDevicejobinfo.jsp?sbbh=" + sbbh + "&tdbh=" + tdbh
    });
}

//详细信息
Label.detailInformation = function (xh) {

//	console.log("xh：",xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!get_SbtdspsrDetail.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    //				console.log("res：",res);

                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 720,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/videoDetail.jsp"
                    });
                }
            }
        })
    }


};
//编辑监控
Label.editvideo = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'sbtdspsrAction!get_SbtdspsrDetail.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        id: $.uniqueId(),
                        title: '编辑设备',
                        width: 650,
                        data: res,
                        scrolling:true,
                        height: 800,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: savevideoNodeInfo
                        }],
                        url: sysUrl + "/yw/videomanage/videochannelset/sbtdspsr/sbtdspsr_show.jsp"
                    });
                }
            }
        });
    }


};

//建筑物详细信息
Label.detailInformationJtjzw = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtjzwxxbAction!get_Nhywjtjzwxxb.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    //				console.log("res：",res);

                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 720,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/jtjzwDetail.jsp"
                    });
                }
            }
        })
    }
};

// 标志牌详情
Label.detailInformationNhywjtbz = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbzglAction!get_Nhywjtbzgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
//					console.log("res-------------：",res);
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 860,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/nhywjtbzDetail.jsp"
                    });
                }
            }
        })
    }
}

// 标线详情
Label.detailInformationJtbx = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbxglAction!get_Nhywjtbxgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
//					console.log("res-------------：",res);
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 860,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/jtbxDetail.jsp"
                    });
                }
            }
        })
    }
}

// 护栏详情
Label.detailInformationJthl = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjthlglAction!get_Nhywjthlgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
//					console.log("res-------------：",res);
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 860,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/jthlDetail.jsp"
                    });
                }
            }
        })
    }
}

// 信号灯详情
Label.detailInformationJtxhd = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtxhdglAction!get_Nhywjtxhdgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
//					console.log("res-------------：",res);
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 860,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/jtxhdDetail.jsp"
                    });
                }
            }
        })
    }
}

//诱导屏详情
Label.detailInformationJtydp = function (xh) {
    console.log("res：", xh);
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtledydpglAction!get_Nhywjtledydpgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
//					console.log("res-------------：",res);
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 440,
                        height: 360,
                        data: res,
                        url: sysUrl + "/yw/szmap/jx/jtydpDetail.jsp"
                    });
                }
            }
        })
    }
}

Label.jtjzwSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/jtjzw-search.jsp";
    top.windowid = top.$.createWin({
        title: '建筑物查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
};

// 标志牌查询
Label.nhywjtbzSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/nhywjtbz-search.jsp";
    top.windowid = top.$.createWin({
        title: '标志牌查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

// 标线查询
Label.jtbxSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/jtbx-search.jsp";
    top.windowid = top.$.createWin({
        title: '标线查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

// 护栏查询
Label.jthlSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/jthl-search.jsp";
    top.windowid = top.$.createWin({
        title: '护栏查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

// 信号灯查询
Label.jtxhdSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/jtxhd-search.jsp";
    top.windowid = top.$.createWin({
        title: '信号灯查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

//诱导屏查询
Label.jtydpSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/jtydp-search.jsp";
    top.windowid = top.$.createWin({
        title: '诱导屏查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}


//雷达查询
Label.ldSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/ld-search.jsp";
    top.windowid = top.$.createWin({
        title: '雷达查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

//微波查询
Label.wbSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/detector-search.jsp?detectortype=SMARTSENSOR";
    top.windowid = top.$.createWin({
        title: '地磁查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

//地磁查询
Label.dcSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/detector-search.jsp??detectortype=GVD";
    top.windowid = top.$.createWin({
        title: '地磁查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}





//编辑信号灯
Label.editxhd = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtxhdglAction!get_Nhywjtxhdgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        title: '修改信息',
                        width: 650,
                        height: 620,
                        data: res,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: saveNodeInfo
                        }],
                        url: sysUrl + "/yw/nhyw/nhywjtxhdgl/nhywjtxhdgl_show.jsp"
                    });
                }
            }
        })
    }

}
//编辑护栏
Label.edithl = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjthlglAction!get_Nhywjthlgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        title: '修改信息',
                        width: 650,
                        height: 600,
                        data: res,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: savehlNodeInfo
                        }],
                        url: sysUrl + "/yw/nhyw/nhywjthlgl/nhywjthlgl_show.jsp"
                    });
                }
            }
        });
    }
}
//编辑诱导屏
Label.editydp = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtledydpglAction!get_Nhywjtledydpgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                            title: '修改信息',
                            width: 650,
                            height: 530,
                            data: res,
                            buttons: [{
                                text: $.fn.textbox.defaults.ok,
                                handler: saveydpNodeInfo
                            }],
                            url: sysUrl + "/yw/nhyw/nhywjtledydpgl/nhywjtledydpgl_show.jsp"
                        }
                    );
                }
            }
        });
    }
}

//编辑地磁,微波
Label.editdetector = function (id) {
    if (id != null && id != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'detectorAction!get_Detector.do',
            data: {id: id},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                            title: '修改信息',
                            width: 650,
                            height: 530,
                            data: res,
                            buttons: [{
                                text: $.fn.textbox.defaults.ok,
                                handler: saveDetectorNodeInfo
                            }],
                            url: sysUrl + "/yw/nhyw/detector/detector_show.jsp"
                        }
                    );
                }
            }
        });
    }
}

//编辑雷达
Label.editld = function (id) {
    if (id != null && id != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'zxldAction!get_Zxld.do',
            data: {xh: id},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                            title: '修改信息',
                            width: 650,
                            height: 530,
                            data: res,
                            buttons: [{
                                text: $.fn.textbox.defaults.ok,
                                handler: saveldNodeInfo
                            }],
                            url: sysUrl + "/yw/nhyw/zxld/zxld_show.jsp"
                        }
                    );
                }
            }
        });
    }
}

//编辑标线
Label.editbx = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbxglAction!get_Nhywjtbxgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        title: '修改信息',
                        width: 650,
                        height: 600,
                        data: res,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: savebxNodeInfo
                        }],
                        url: sysUrl + "/yw/nhyw/nhywjtbxgl/nhywjtbxgl_show.jsp"
                    });
                }
            }
        });
    }

}
//编辑标志牌
Label.editbzp = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtbzglAction!get_Nhywjtbzgl.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        title: '修改信息',
                        width: 650,
                        height: 600,
                        data: res,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: savebzpNodeInfo
                        }],
                        url: sysUrl + "/yw/nhyw/nhywjtbzgl/nhywjtbzgl_show.jsp"
                    });
                }
            }
        });
    }

}
//编辑建筑物
Label.editJjzw = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'nhywjtjzwxxbAction!get_Nhywjtjzwxxb.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    windowId = top.$.createWin({
                        title: '修改信息',
                        width: 650,
                        height: 600,
                        data: res,
                        buttons: [{
                            text: $.fn.textbox.defaults.ok,
                            handler: savejzwNodeInfo
                        }],
                        url: sysUrl + "/yw/nhyw/nhywjtjzwxxb/nhywjtjzwxxb_show.jsp"
                    });
                }
            }
        });
    }

}

//保存
function saveNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    console.log(model);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    model.cpsm = jq("#cpsm").val();
    model.bz = jq("#bz").val();
    var frame = top.$("#" + windowId).children("iframe")[0];
    var winf = frame.contentWindow || frame.window;
    var picfile = winf.$("#picFile").prop('files');
    if (picfile != undefined && !picfile.length) {
        var fileStr = uploadFile();
        var fileInfo = JSON.parse(fileStr);
        var flag = fileInfo.flag;
        if (flag == "fail") {
            $.showMsg('文件上传失败！');
        } else {
            var jcbg = fileInfo.url0;
            var sbzp = fileInfo.url1;
            if (jcbg != "" || jcbg != null) {
                model.jcbg = jcbg;
            }
            if (sbzp != "" || sbzp != null) {
                model.sbzp = sbzp;
            }
        }
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'nhywjtxhdglAction!update_Nhywjtxhdgl.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}

function savehlNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    var gysbh = jq("#gysbh").combotree("getValue");
    if (gysbh != null && gysbh != "") {
        model.gysmc = jq("#gysbh").combotree("getText");
    }
    var gxdwbm = jq("#gxdwbm").combotree("getValue")
    if (gxdwbm != "-1") {
        model.gxdwmc = jq("#gxdwbm").combotree("getText");
    } else {
        model.gxdwbm = "";
    }
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    var frame = top.$("#" + windowId).children("iframe")[0];
    var winf = frame.contentWindow || frame.window;
    var file = winf.$("#myfile").prop('files');
    if (!file.length) {
        //$.showMsg('请选择要上传的文件！');
        //return;
    } else {
        var fileStr = uploadFile();
        var fileInfo = JSON.parse(fileStr);
        var flag = fileInfo.flag;
        if (flag == "success") {
            model.sjzp = fileInfo.url;
//			model.wdmc = fileInfo.fileName;
//			model.kz1 = fileInfo.kz1;
            console.log("参数：", model);
        } else {
            $.showMsg('文件上传失败！');
            return;
        }
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'nhywjthlglAction!update_Nhywjthlgl.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}

function saveydpNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    model.XGTJid = jq('#id').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'detectorAction!update_Detector.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}

function saveldNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'zxldAction!update_Zxld.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}
function saveDetectorNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    model.XGTJid = jq('#id').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'detectorAction!update_Detector.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}


function savebxNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    var gysbh = jq("#gysbh").combotree("getValue");
    if (gysbh != null && gysbh != "") {
        model.gysmc = jq("#gysbh").combotree("getText");
    }
    var gxdwbm = jq("#gxdwbm").combotree("getValue");
    if (gxdwbm != "-1") {
        model.gxdwmc = jq("#gxdwbm").combotree("getText");
    } else {
        model.gxdwbm = "";
    }
    console.log(model);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    var frame = top.$("#" + windowId).children("iframe")[0];
    var winf = frame.contentWindow || frame.window;
    var file = winf.$("#myfile").prop('files');
    if (!file.length) {
        //$.showMsg('请选择要上传的文件！');
        //return;
    } else {
        var fileStr = uploadFile();
        var fileInfo = JSON.parse(fileStr);
        var flag = fileInfo.flag;
        if (flag == "success") {
            model.sjzp = fileInfo.url;
//			model.wdmc = fileInfo.fileName;
//			model.kz1 = fileInfo.kz1;
            console.log("参数：", model);
        } else {
            $.showMsg('文件上传失败！');
            return;
        }
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'nhywjtbxglAction!update_Nhywjtbxgl.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });

}

//保存
function savebzpNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    var gysbh = jq("#gysbh").combotree("getValue");
    if (gysbh != null && gysbh != "") {
        model.gysmc = jq("#gysbh").combotree("getText");
    }
    var gxdwbm = jq("#gxdwbm").combotree("getValue");
    if (gxdwbm != "-1" && gxdwbm != null && gxdwbm != "") {
        model.gxdwmc = jq("#gxdwbm").combotree("getText");
    } else {
        model.gxdwbm = "";
    }
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    var frame = top.$("#" + windowId).children("iframe")[0];
    var winf = frame.contentWindow || frame.window;
    var file = winf.$("#myfile").prop('files');
    if (!file.length) {
        //$.showMsg('请选择要上传的文件！');
        //return;
    } else {
        var fileStr = uploadFile();
        var fileInfo = JSON.parse(fileStr);
        var flag = fileInfo.flag;
        if (flag == "success") {
            model.sjzp = fileInfo.url;
//			model.wdmc = fileInfo.fileName;
//			model.kz1 = fileInfo.kz1;
            console.log("参数：", model);
        } else {
            $.showMsg('文件上传失败！');
            return;
        }
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'nhywjtbzglAction!update_Nhywjtbzgl.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });
}

function savevideoNodeInfo() {
    var frame = top.$("#" + windowId).children('iframe')[0];
    var win = frame.contentWindow || frame.window;
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    model.XGTJsbbh = model.xh;
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'sbtdspsrAction!update_Sbtdspsr.do',
        data: model,
        success: function (value) {
            if (value == 'success') {
                top.$("#" + windowId).dialog('close');
                $.showMsg('执行成功');
            }
        }
    });

}

function savejzwNodeInfo() {
    var win = $.getTopWindowById(windowId);
    var jq = win.$;
    var model = $.getFormValues("childform", windowId);
    if (!win.$('#childform').form('enableValidation').form('validate')) {
        return;
    }
    var frame = top.$("#" + windowId).children("iframe")[0];
    var winf = frame.contentWindow || frame.window;
    var file = winf.$("#myfile").prop('files');
    if (!file.length) {
        //$.showMsg('请选择要上传的文件！');
        //return;
    } else {
        var fileStr = uploadFile();
        var fileInfo = JSON.parse(fileStr);
        var flag = fileInfo.flag;
        if (flag == "success") {
            model.jzwtp1 = fileInfo.url;
            console.log("参数：", model);
        } else {
            $.showMsg('文件上传失败！');
            return;
        }
    }
    model.XGTJxh = jq('#xh').val();
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'nhywjtjzwxxbAction!update_Nhywjtjzwxxb.do',
        data: model,
        success: function (value) {
            if (value == "success") {
                $.showMsg("操作成功！");
                top.$("#" + windowId).dialog('close');
            } else if (value == "same") {
                $.showMsg("已存在！");
            } else {
                $.showMsg("操作失败！");
            }
        }
    });

}

function uploadFile() {
    var win = $.getTopWindowById(windowId);
    var res = '';
    win.$("#childform").ajaxSubmit({
        type: 'post', // 提交方式 get/post
        cache: false,
        dataType: 'text',
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        async: false,
        url: "http://" + window.location.host + "/impnhyw/UploadNhywCpxh", // 需要提交的 url
        success: function (responseText, statusText, xhr, $form) {
//	    	 console.log(responseText);
            res = responseText;
//	    	console.log("res：",res);
        }
    });
    return res;
}

//加载地磁，微波详细信息
Label.detailInformationDetector = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'detectorAction!get_Detector.do',
            data: {id: xh},
            success: function (res) {
                if (res) {
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 720,
                        height: 400,
                        data: res,
                        url: sysUrl + "/yw/nhyw/detector/detector_show.jsp"
                    });
                }
            }
        })
    }
};



//加载雷达详细信息
Label.detailInformationld = function (xh) {
    if (xh != null && xh != '') {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'zxldAction!get_Zxld.do',
            data: {xh: xh},
            success: function (res) {
                if (res) {
                    var sysUrl = top.sysUrl;
                    windowId = top.$.createWin({
                        title: '详细信息',
                        width: 620,
                        height: 430,
                        data: res,
                        url: sysUrl + "/yw/nhyw/zxld/zxld_show.jsp"
                    });
                }
            }
        })
    }
};



// 标注地磁、微波查询
Label.detectorSearch = function (detectortype) {
    var data_val = {Label: Label,detectortype:detectortype};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/detector-search.jsp";
    top.windowid = top.$.createWin({
        title: '查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}


//地磁、微波确认
Label.confirmdetector = function (detectortype) {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var name = $("#sxt").val();
    var id = $("#id").val();
//	console.log("confirmCamera： ",params);
    if (name.trim() != '') {
        var data = {"jd": jd, "wd": wd, "name": name,"XGTJid": id,"detectortype":detectortype,"id":id};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + name + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editdetector(\"" + id + "\")'>编辑</li>" +
            "<li onclick='Label.detailInformationDetector(\"" + id + "\")'>详情</li>" +
            "<li onclick='removedetector(\"" + id + "\")'>删除</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        if(detectortype=="GVD") {
            MapAPI.getJtwbGraphicsLayer().remove(Label.graphic);
        }else{
            MapAPI.getJtdcGraphicsLayer().remove(Label.graphic);
        }
        MapUtil.adddetectorPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'detectorAction!update_Detector.do',
            data: data,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("添加成功！");
                } else {
                    $.showMsg("添加失败!");
                }
            }
        });
    } else {
        $.showMsg("名称不能为空!");
    }
}

// 地磁、微波填充数据
Label.filldetector = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));
    $('#id').val(dataJson.id);
    $("#sxt").val(dataJson.name);
}

//标注地磁、微波取消
Label.canceldetector = function (detectortype) {
    if(detectortype=="GVD") {
        MapAPI.getJtwbGraphicsLayer().remove(Label.graphic);
    }else{
        MapAPI.getJtdcGraphicsLayer().remove(Label.graphic);
    }
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注取消成功!");
}


//雷达查询
Label.ldSearch = function () {
    var data_val = {Label: Label};
    var url = top.sysUrl + "/yw/szmap/map/toolbar_operation/itemPage/ld-search.jsp";
    top.windowid = top.$.createWin({
        title: '雷达查询',
        width: '700',
        height: '420',
        data: data_val,
        url: url
    });
}

//雷达确认
Label.confirmld = function () {
    var jd = $("#jd").val();
    var wd = $("#wd").val();
    var name = $("#sxt").val();
    var xh = $("#id").val();
//	console.log("confirmCamera： ",params);
    if (name.trim() != '') {
        var data = {"jd": jd, "wd": wd, "ldmc": name,"XGTJxh":xh};
        var html = "<div class='bcontent'><div><span style='color:#75767A'>" + name + "</span></div>" +
            "<ul  class='bcontentItem'>" +
            "<li onclick='Label.editdld(\"" + xh + "\")'>编辑</li>" +
            "<li onclick='removeld(\"" + xh + "\")'>删除</li>" +
            "<li onclick='Label.detailInformationld(\"" + xh + "\")'>详情</li>" +
            "</ul></div>";
        MapAPI.getMap().infoWindow.hide();
        MapAPI.getJtldGraphicsLayer().remove(Label.graphic);
        MapUtil.adddLdPoint(data, html);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'zxldAction!update_Zxld.do',
            data: data,
            success: function (flag) {
                if (flag == "success") {
                    $.showMsg("添加成功！");
                } else {
                    $.showMsg("添加失败!");
                }
            }
        });
    } else {
        $.showMsg("名称不能为空!");
    }
}

// 雷达填充数据
Label.fillld = function (o) {
    $("#arcgisIframe").hide();
    $(".esri-component").show();
    var dataJson = JSON.parse($(o).attr("data-json"));
    $("#sxt").val(dataJson.ldmc);
    $("#id").val(dataJson.xh);
}

//标注雷达取消
Label.cancelld = function () {
    MapAPI.getJtldGraphicsLayer().remove(Label.graphic);
    MapAPI.getMap().infoWindow.hide();
    $.showMsg("标注雷达设备取消成功!");
};