//工具条标注操作

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.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.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.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.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.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.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.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.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.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.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.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
	 });
}