function startMarker(){

	//mapType = getUserStatus()?getUserStatus().mapType:3;
	//添加标注菜单
	addMarkerMenu();
	if(usertype=="-1000"||usertype=="-100"){ 			  
		document.getElementById("biaozhu_close").style.display = "none";
		document.getElementById("markerPermissionsPanelBtn").style.display = "none";
		document.getElementById("markerNamePermissionsPanelBtn").style.display = "none";
		document.getElementById("fencePermissionsPanelBtn").style.display = "none";
	}else{

		//点击地图时关闭已经打开的弹出框
		mapclickEvent();	 			  

		//获取标注Josn集
		getMarkerJson();

		//获取标注组Json集
		getGroupJson();

		//获取所有标注组Json集
		getAllMarkerGroupJson();

		//绘制标注树
		showMarkerGroupTree();

		//添加所有标注  
		addAllMarker();

		//添加标注组选择框
		//addMarkerGroupSelect("marker_group_option");

		//添加标注窗口开始
		frame("markerContentWin","moveMarkerWin","closecmarkerWin");
		//添加标注窗口结束

		//添加标注组窗口开始
		frame("addGroupContentWin","moveGroupWin","closeGroupWin");
		//添加标注组窗口结束

		//标注头像选择窗口开始
		frame("selectMarkerPhotoWin","moveSelectMarkerPhotoWin","closeSelectMarkerPhotoWin");
		//标注头像选择窗口结束

		//标注绑定设备窗口开始
		frame("marker_vehicle_binding_ContentWin","move_marker_vehicle_binding_Win","close_marker_vehicle_binding_Win");
		//标注绑定设备窗口结束

		//装载区域大小滑块
		loadAreaSlider();

		MarkerTreeMenu.init();
		if(mapType==2) $("#ico_weilan").show();

	}

	addEvent();

}

var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;

var markerGroupJson=null;
var allMarkerGroupJson=null;
var markerObject={
		markerJson : "",
		markerArr : {},
		myLatlng : null,
		infowindow : null,
		markerids : new Array(), 
		markertitlearr : new Array(),
		addMarker : function(_id,_lat,_lng,_icon){
			this.markerids.push(_id);
			try{
				this.myLatlng=new google.maps.LatLng(_lat,_lng);

				var image = {
						url: _icon,
						// This marker is 20 pixels wide by 32 pixels tall.
						size: new google.maps.Size(32, 32),
						// The origin for this image is 0,0.
						origin: new google.maps.Point(0,0),//位置
						// The anchor for this image is the base of the flagpole at 0,32.
						anchor: new google.maps.Point(16, 16)
				};

				return new google.maps.Marker({
					position: this.myLatlng,
					map: map,
					icon: image
				});
			}catch(e){}
		},
		addMarkerListener : function(_marker){
			try{ 
				google.maps.event.addListener(_marker.marker, "click", function (e) {
					menu.hide();
					markerObject.closeInfowindow();
					var contentHtml;
					if(_marker.competence==1){

						contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\"><b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br><b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lng.toFixed(5)+"</br><b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lat.toFixed(5)+"</br><b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br><b><a href=\"javascript:deleteMarker("+_marker.id+");\"><font color=\"#0000FF\">"+language.sh+"</font></a></b><b><a href=\"javascript:openUpdateMarkerWin("+_marker.id+");\"><font color=\"#0000FF\">"+language.xgbj+"<font></a></b></div>";
					}else{
						contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\"><b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br><b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lng.toFixed(5)+"</br><b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lat.toFixed(5)+"</br><b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br></div>";
					}

					markerObject.infowindow = new google.maps.InfoWindow({ 
						content:contentHtml,
						maxWidth:200
					}); 

					closeVehicleInfoWindow();

					if(mapType==1){

						openMarkerBaidu(_marker.id);

					}else{
						markerObject.infowindow.open(map,this);
					}

				});
			}catch(e){}

		},
		deleteMarker : function(_id){
			for(var i=0;i<markerObject.markerids.length;i++){
				if(_id==markerObject.markerids[i]){
					markerObject.markerids.remove(i);			
				}
			}
			markerObject.markerArr[_id].marker.setMap(null);
			if(markerObject.markerArr[_id].area!=null){
				markerObject.markerArr[_id].area.setMap(null);
			}
			markerObject.markerArr[_id]=null;
			if(markerObject.infowindow != null){
				markerObject.infowindow.close();
			}


			hideMarkerName();
		},
		closeInfowindow : function(){
			if(this.infowindow!=null){
				this.infowindow.close();
			}
		}, 
		clear : function(){

		}
}
function getMarkerJson(){

	$.ajax({
		type: "POST",
		dataType: "json",
		async:true,
		url: "json/markerAction_getMarker.action",
		success: function(json) {		         
		if (json.flag==true) {
			markerObject.markerJson=json;		        	 					           				
		}else{
			if(json.statecode){
				if(json.statecode==10000){
					if($.browser.msie) { 
						location.href = "../login.jsp";
					}else{
						location.href = "./gpsonline/jsp/login.jsp";
					}
				}
			}

		}
	},
	error: function() {}
	});	
}
function getAllMarkerGroupJson(){
	$.ajax({
		type: "POST",
		dataType: "json",
		async:true,
		url: "json/markerAction_getMarkerGroup.action",
		success: function(json) {		         
		if (json.flag==true) {
			allMarkerGroupJson=json;		        	 					           				
		}else{
			alert(json.msg);
		}
	},
	error: function() {}
	});	
}
function deleteMarker(id){

	markerObject.closeInfowindow();

	if(window.confirm(language.sfscbz)){
		if(markerObject.markerArr[id].competence==1){
			$.ajax({
				type: "POST",
				dataType: "json",
				async:false,
				url: "json/markerAction_delMarker.action",
				data: {"markerID":id},
				success: function(json){
					if (json.flag==true){
						deleteMarkerGroupTreeNode(id);
						if(mapType==1){
							delMarkerBaidu(id);
							for(var i=0;i<markerObject.markerids.length;i++){
								if(id==markerObject.markerids[i]){
									markerObject.markerids.remove(i);							
								}
							}
						}else if(mapType==3){
							GaoDemarkerShowOrHide();
						}else{
							markerObject.deleteMarker(id);
						}
						for(var i=0;i<markerObject.markerids.length;i++){
							if(id==markerObject.markerids[i]){
								markerObject.markerids.remove(i);
							}
							break;
						}
						for(var i=0;i<markerObject.markerJson.data.length;i++){
							if(id==markerObject.markerJson.data[i].id){
								markerObject.markerJson.data.remove(i);
								break;
							}

						}
						markerObject.markerJson.totalcount = markerObject.markerJson.data.length;


					}else{
						alert(json.msg);
					}
				},
				error: function() {}
			});	
		}else{
			alert(language.qxts);
		}
	}
}

function addMarker_Area(){

	$("#addMarkerButton").attr("disabled","disabled");//设置所有的button不可用 

	var title,desc,icon,lat,lng,groupid,leftlat,leftlng,rigthlat,rigthlng,customerNum;
	title=$("#markertitle").val();
	desc=$("#markerdesc").val();
	if (isChrome) {
		icon=$("#markerImagesrc").css("backgroundImage").split("(")[1].split(")")[0];
	}else{
		icon=$("#markerImagesrc").css("backgroundImage").split("\"")[1];
	}

	lat=$("#markerlat").val();
	lng=$("#markerlng").val();
	groupid=$("#markerGroupId").val();
	leftlat=$("#leftlat").val();
	leftlng=$("#leftlng").val();
	rigthlat=$("#rigthlat").val();
	rigthlng=$("#rigthlng").val();
	customerNum=$("#customerNum").val();
	if(title.length==0){
		$("#addmarkermsg").text(language.btbnwk);
		$("#addmarkermsg").css("color","red");
		$("#addMarkerButton").removeAttr("disabled");//去掉button的disabled属性，使button可用
		return;
	}else{
		$("#addmarkermsg").css("color","rgb(153, 153, 153)");

	}
	if(desc.length>150){
		$("#addmarkermsg").text(language.msbndy150gz);
		$("#addmarkermsg").css("color","red");
		$("#addMarkerButton").removeAttr("disabled");//去掉button的disabled属性，使button可用
		return;
	}

	var getcustomerNums = getCNum_vlaues();

	if( customerNum.length > 0 && ($.inArray(customerNum, getcustomerNums) < 0)){

		if(!window.confirm(language.yytwtjdkhh)){

			$("#addMarkerButton").removeAttr("disabled");

			return;

		}

	}

	$.ajax({
		type: "POST",
		dataType: "json",
		async:true,
		url: "json/markerAction_addOrUpdateUserMarker.action",
		data:{"title":title,"text":desc,"icon":icon,"lat":lng,"lng":lat,"groupid":groupid,"leftLat":leftlat,"leftLon":leftlng,"rightLat":rigthlat,"rightLon":rigthlng,"radius":markersize,"customerNum":getcustomerNums.join("/"),"mapType":mapType},
		success: function(json) {		         
			if (json.flag==true) {
				if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){			         		 

					var marker=markerObject.addMarker(json.data[0].id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);

					markerObject.markerArr[json.data[0].id]={};
					markerObject.markerArr[json.data[0].id].marker=marker;

					try {
						marker.setMap(map);
					} catch (e) {
						// TODO: handle exception
					}

					markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
					markerObject.markerArr[json.data[0].id].title=json.data[0].title;
					markerObject.markerArr[json.data[0].id].text=json.data[0].text;
					markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
					markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
					markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
					markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
					markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
					markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
					markerObject.markerArr[json.data[0].id].id=json.data[0].id;
					markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;

					markerObject.markerArr[json.data[0].id].isShow=true;


					markerObject.markerArr[json.data[0].id].areaRadius=markersize;

					markerObject.addMarkerListener(markerObject.markerArr[json.data[0].id]);	

					try {
						if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
							if(json.data[0].userMarkerArea.g_leftLat!=0 &&json.data[0].userMarkerArea.g_leftLon!=0 &&json.data[0].userMarkerArea.g_rightLat!=0 &&json.data[0].userMarkerArea.g_rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
								markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.g_leftLat,json.data[0].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.g_rightLat,json.data[0].userMarkerArea.g_rightLon));
							}else{
								markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));

							}
							markerObject.markerArr[json.data[0].id].area.setMap(null);
							markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
						}

					} catch (e) {
						// TODO: handle exception
					}


					markerRefreshObject.addMarkerGroup(json.data[0].groupid);//若标注树上没有标注组自动添加标注组

					addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);

					$("#markerId").attr("value",json.data[0].id);

					clearAreaLagLng();
					markerObject.markerJson.data.push(json.data[0]);
					markerObject.markerJson.totalcount = markerObject.markerJson.data.length;

					if($("#bzShowNamekbox").attr("checked")){

						markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition()));

					}

					if(mapType==1){
						baidMap.removeOverlay(oldPolygon);
						showMarkerBaidu(json);
						updateMarkerIsShow(json.data[0].id,true,false);
						showMarkersBaidu(json.data[0].id,false);
					}

					var curnode=treeObj.getNodeByParam("id",json.data[0].id);

					if(curnode != null){
						treeObj.checkNode(curnode, true, false, false);
					}




					if(selectImage!=null){
						selectImage.attr("class","unselected");
						selectImage=$("#selectImage");//用于保存当前选中的标记图标
						selectImage.attr("class","selected");
					}	 
				} $("#closecmarkerWin").click();
				$("#addMarkerButton").removeAttr("disabled");//去掉button的disabled属性，使button可用
			}else{
				if(json.msg!="10001"){
					$("#addmarkermsg").text(json.msg);
					$("#addmarkermsg").css("color","red");
				}else{
					$("#addmarkermsg").text(language.bzmbncf);
					$("#addmarkermsg").css("color","red");
				}
				$("#addMarkerButton").removeAttr("disabled");//去掉button的disabled属性，使button可用
			}
		},
		error: function() {$("#addMarkerButton").removeAttr("disabled");}
	});		   
}

function openUpdateMarkerWin(markerId){
	$("#updateMarkerButton").removeAttr("disabled");
	markerObject.closeInfowindow();
	$("#updateMarkerButton").show();
	$("#addMarkerButton").hide();

	var curMarkerObject=markerObject.markerArr[markerId];
	//$("#addMarkerGroupSelect").hide();
	//$("#markerGroupId").val(curMarkerObject.groupid);

	addMarkerGroupSelect();
	$("#addMarkerGroupSelect").show();

	$("#markerGroupId").val(curMarkerObject.groupid);

	$(".marker_group_option a").each(function(){

		if($(this).attr("name") == curMarkerObject.groupid ){

			$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(this).eq(0).text());

			$("#markerGroupId").val($(this).eq(0).attr("name"));

			return false;

		}

	});

	$("#markerName").text(language.xgbz); 	

	$("#markerlat").val(curMarkerObject.lat);
	$("#markerlng").val(curMarkerObject.lng);
	/*
	if(mapType - 1 == 0 && curMarkerObject.blat != 0 && curMarkerObject.blat != 0){

		 $("#markerlat").val(curMarkerObject.blat);
	     $("#markerlng").val(curMarkerObject.blng);

	}   
	 */
	$("#markertitle").val(curMarkerObject.title);
	$("#markerdesc").val(curMarkerObject.text);

	$("#markerImagesrc").css("backgroundImage","url("+curMarkerObject.icon+")"); 

	$("#markerId").attr("value",markerId);

	$("#customerNum").val("");
	initCustomerNum_vlaue(curMarkerObject.customerNum.split("/"))
	$("#addmarkermsg").text(language.btbnwk);
	$("#addmarkermsg").css("color","rgb(153, 153, 153)");

	markersize=curMarkerObject.areaRadius;
	if(curMarkerObject.area!=null){

		curMarkerObject.area.setMap(null);
		try {
			markerArea=drawMarkerArea(getAreaSWLatlng(curMarkerObject.lat,curMarkerObject.lng,markersize),getAreaNELatLng(curMarkerObject.lat,curMarkerObject.lng,markersize));	

		} catch (e) {
		}

	}else{
		try {
			markerArea=drawMarkerArea(new google.maps.LatLng(0,0),new google.maps.LatLng(0,0))
		} catch (e) {
		}
	}
	//if(mapType!=3){
		if( typeof curMarkerObject.areaRadius !="undefined"){
			$( "#markerArea" ).slider( "value", curMarkerObject.areaRadius);
		}else{
			$( "#markerArea" ).slider( "value", 0);
		}
	//}
	/*for(var i=0;i<markerGroupJson.totalcount;i++){
		if(markerGroupJson.data[i].id==curMarkerObject.groupid){
			$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(markerGroupJson.data[i].groupName);
    		$("#markerGroupId").val(curMarkerObject.groupid);
			break;
		}
	}*/

	$("#markerContentWin").show();
	$("#markerContentWin").center();
}

function updateMarker(){
	$("#updateMarkerButton").attr("disabled","disabled");//设置所有的button不可用 
	var id,title,desc,icon,lat,lng,groupid,leftlat,leftlng,rigthlat,rigthlng,customerNum;
	title=$("#markertitle").val();
	desc=$("#markerdesc").val();
	if (isChrome) {
		icon=$("#markerImagesrc").css("backgroundImage").split("(")[1].split(")")[0];
	}else{
		icon=$("#markerImagesrc").css("backgroundImage").split("\"")[1];
	}
	lat=$("#markerlat").val();
	lng=$("#markerlng").val();
	groupid=$("#markerGroupId").val();
	id=parseInt($("#markerId").attr("value"));
	leftlat=$("#leftlat").val();
	leftlng=$("#leftlng").val();
	rigthlat=$("#rigthlat").val();
	rigthlng=$("#rigthlng").val();
	customerNum=$("#customerNum").val();
	if(title.length==0){
		$("#addmarkermsg").text(language.btbnwk);
		$("#addmarkermsg").css("color","red");
		$("#updateMarkerButton").removeAttr("disabled");
		return;
	}else{
		$("#addmarkermsg").css("color","rgb(153, 153, 153)");

	}

	if(desc.length>150){
		$("#addmarkermsg").text(language.msbndy150gz);
		$("#addmarkermsg").css("color","red");
		$("#updateMarkerButton").removeAttr("disabled");
		return;
	}

	var getcustomerNums = getCNum_vlaues();

	if( customerNum.length > 0 && ($.inArray(customerNum, getcustomerNums) < 0)){

		if(!window.confirm(language.yytwtjdkhh)){

			$("#addMarkerButton").removeAttr("disabled");

			return;

		}
	}
	$.ajax({
		type: "POST",
		dataType: "json",
		async:true,
		url: "json/markerAction_addOrUpdateUserMarker.action",
		data:{"id":id,"title":title,"text":desc,"icon":icon,"lat":lng,"lng":lat,"groupid":groupid,"leftLat":leftlat,"leftLon":leftlng,"rightLat":rigthlat,"rightLon":rigthlng,"radius":markersize,"customerNum":getcustomerNums.join("/"),"mapType":mapType},
		success: function(json) {	
			console.info(JSON.stringify(json));
			if (json.flag==true) {

				if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){


					if(mapType != 1 && mapType != 3){
						markerObject.deleteMarker(id);
						markerObject.infowindow=null;
					}

					var marker=markerObject.addMarker(id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);				 			 
					markerObject.markerArr[json.data[0].id]={};
					markerObject.markerArr[json.data[0].id].marker=marker;
					markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
					markerObject.markerArr[json.data[0].id].title=json.data[0].title;
					markerObject.markerArr[json.data[0].id].text=json.data[0].text;
					markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
					markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
					markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
					markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
					markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
					markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
					markerObject.markerArr[json.data[0].id].id=json.data[0].id;
					markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
					markerObject.markerArr[json.data[0].id].isShow=true;

					markerObject.addMarkerListener(markerObject.markerArr[id]);	

					var curnode=treeObj.getNodeByParam("id",json.data[0].id);

					if (curnode!=null) {

						curnode.name = json.data[0].title;

						treeObj.updateNode(curnode);


						if(curnode.getParentNode().id != 'g_'+json.data[0].groupid){

							var prevParentNode = curnode.getParentNode();

							prevParentNode.count = parseInt(prevParentNode.count)-1 ;

							if(prevParentNode.count == 0){
								prevParentNode.name = prevParentNode.title;
							}else{
								prevParentNode.name = prevParentNode.title+"("+prevParentNode.count+")";
							}

							var curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);					

							if(curGroupnode == null){

								//添加标注所属组(若改组已经存在则不操作)
								markerRefreshObject.addMarkerGroup(json.data[0].groupid);
								curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);
							}

							curGroupnode.count = parseInt(curGroupnode.count)+1 ;

							curGroupnode.name = curGroupnode.title+"("+curGroupnode.count+")";

							treeObj.moveNode(curGroupnode, curnode, "inner");

							treeObj.updateNode(prevParentNode);
							treeObj.updateNode(curGroupnode);
						}



					}

					/*
						  	 deleteMarkerGroupTreeNode(id);	

						  	 treeObj.checkNode(addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title)[0], true, false, false);
					 */

					if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
						markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
						markerObject.markerArr[json.data[0].id].area.setMap(null);
						markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
					}

					for(var i=0;i<markerObject.markerJson.data.length;i++){
						if(json.data[0].id==markerObject.markerJson.data[i].id){
							markerObject.markerJson.data.remove(i);
							break;
						}
					}

					markerObject.markerJson.data.push(json.data[0]);

					if($("#bzShowNamekbox").attr("checked")){

						markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition()));

					}

					if(mapType==1){
						for(var i=0;i<markerObject.markerids.length;i++){
							if(json.data[0].id==markerObject.markerids[i]){
								markerObject.markerids.remove(i);
								break;
							}
						}
						updateBzMarkers(json);
					}
				}	

				if(selectImage!=null){
					selectImage.attr("class","unselected");
					selectImage=$("#selectImage");//用于保存当前选中的标记图标
					selectImage.attr("class","selected");
				}$("#closecmarkerWin").click(); 
				$("#updateMarkerButton").removeAttr("disabled");	 			  	 
			}else{
				if(json.msg!="10001"){
					$("#addmarkermsg").text(json.msg);
					$("#addmarkermsg").css("color","red");
				}else{
					$("#addmarkermsg").text(language.bzmbncf);
					$("#addmarkermsg").css("color","red");
				}
				$("#updateMarkerButton").removeAttr("disabled");
			}
		},
		error: function() {
			console.info("++++++++++666666666666666");
			$("#updateMarkerButton").removeAttr("disabled");
		}
	});	
}

function getGroupJson(){
	$.ajax({
		type: "POST",
		dataType: "json",
		async:false,
		url: "json/markerAction_getUserMarkerGroup.action",
		success: function(json) {		         
		if (json.flag==true) {
			markerGroupJson=json;		        	 					           				
		}else{
			alert(json.msg);
			if(json.statecode){
				if(json.statecode==10000){
					if($.browser.msie) { 
						location.href = "../login.jsp";
					}else{
						location.href = "./gpsonline/jsp/login.jsp";
					}
				}
			}
		}
	},
	error: function() {}
	});	
}
function addAllMarker(){
	if(mapType==2 && (typeof map=="undefined")){
		setTimeout('addAllMarker()',500);
		return;
	}
	if(markerObject.markerJson==""){
		setTimeout('addAllMarker()',500);
		return;
	}
	var marker,json = markerObject.markerJson;
	if(null!=json&&"" != json&&json.totalcount>0){
		for(var i=0;i<json.totalcount;i++){
			if(typeof json.data[i].id=="number" && typeof json.data[i].lat2=="number" && typeof json.data[i].lng2=="number" && json.data[i].icon.length!=0 &&json.data[i].lat2!=0&&json.data[i].lng2!=0){			
				marker=markerObject.addMarker(json.data[i].id,json.data[i].lng2,json.data[i].lat2,json.data[i].icon);
				try{
					//marker.setMap(null);
					markerObject.markerArr[json.data[i].id]={};
					markerObject.markerArr[json.data[i].id].marker=marker;
					markerObject.markerArr[json.data[i].id].competence=json.data[i].competence;		
					markerObject.markerArr[json.data[i].id].title=json.data[i].title;
					markerObject.markerArr[json.data[i].id].text=json.data[i].text;
					markerObject.markerArr[json.data[i].id].icon=json.data[i].icon;
					markerObject.markerArr[json.data[i].id].lat=json.data[i].lng2;
					markerObject.markerArr[json.data[i].id].lng=json.data[i].lat2;
					markerObject.markerArr[json.data[i].id].blng=json.data[i].blat;
					markerObject.markerArr[json.data[i].id].blat=json.data[i].blng;
					markerObject.markerArr[json.data[i].id].groupid=json.data[i].groupid;
					markerObject.markerArr[json.data[i].id].id=json.data[i].id;
					markerObject.markerArr[json.data[i].id].customerNum=json.data[i].markcode;
					markerObject.markerArr[json.data[i].id].isShow=false;

					markerObject.addMarkerListener(markerObject.markerArr[json.data[i].id]);
					if(json.data[i].userMarkerArea!=null&&json.data[i].userMarkerArea.leftLat!=0 &&json.data[i].userMarkerArea.leftLon!=0 &&json.data[i].userMarkerArea.rightLat!=0 &&json.data[i].userMarkerArea.rightLon!=0 &&json.data[i].userMarkerArea.markerRadius!=0){
						if(json.data[i].userMarkerArea.g_leftLat!=0 &&json.data[i].userMarkerArea.g_leftLon!=0 &&json.data[i].userMarkerArea.g_rightLat!=0 &&json.data[i].userMarkerArea.g_rightLon!=0 &&json.data[i].userMarkerArea.markerRadius!=0){
							markerObject.markerArr[json.data[i].id].area=drawMarkerArea(new google.maps.LatLng(json.data[i].userMarkerArea.g_leftLat,json.data[i].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[i].userMarkerArea.g_rightLat,json.data[i].userMarkerArea.g_rightLon));
						}else{
							markerObject.markerArr[json.data[i].id].area=drawMarkerArea(new google.maps.LatLng(json.data[i].userMarkerArea.leftLat,json.data[i].userMarkerArea.leftLon),new google.maps.LatLng(json.data[i].userMarkerArea.rightLat,json.data[i].userMarkerArea.rightLon));
						}
						markerObject.markerArr[json.data[i].id].area.setMap(null);
						markerObject.markerArr[json.data[i].id].areaRadius=json.data[i].userMarkerArea.markerRadius;
					}
				}catch(e){}
			}
		}
	}
}
var menu=null;
function addMarkerMenu(){
	if(typeof map=="undefined"){
		//setTimeout('addMarkerMenu()',500);  172
		return;
	}
	menu = new MenuControl(map);
	menu.sender = map;
	if(mapType==2){
		google.maps.event.addListener(map,"rightclick",
				function(e) {
			closeRectangShape();
			closeDistance();
			$("#closeGroupWin").click();
			$("#closecmarkerWin").click();
			$("#closeSelectMarkerPhotoWin").click();
			if (menu.isEnable) {
				menu.coordinate = {
						point: e.pixel,
						latlng: e.latLng
				};
				menu.container.style.left = e.pixel.x + "px";
				menu.container.style.top = e.pixel.y + "px";
				menu.show("map");
			}
		}); 
	}
	if(usertype =="0" || usertype=="1" || usertype=="2" || usertype=="-1"  || usertype=="10"){ 
		menu.addItem(new MenuItem({
			text: language.tjbj,
			icon: "",
			groupName: "map",
			handler: function(coor) { 

			$("#customerNum").val("");

			$("#customerNumListOutCanvas").html("");

			$("#addMarkerButton").removeAttr("disabled");//去掉button的disabled属性，使button可用
			addMarkerGroupSelect();
			$("#addMarkerGroupSelect").show();

			$("#markerName").text(language.tjbz);

			$("#markerlat").val(coor.latlng.lat());
			$("#markerlng").val(coor.latlng.lng());
			$("#markertitle").val("");
			$("#markerId").val("");
			$("#markerdesc").val("");
			$("#addmarkermsg").text(language.btbnwk);
			$("#addmarkermsg").css("color","rgb(153, 153, 153)");
			if($("#marker_group_option a").length!=1){
				$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
				$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
			}

			$("#markerImagesrc").css("backgroundImage","url(http://mapday.exlive.cn/mi/p/f/2/green.gif)");

			markerArea=drawMarkerArea(getAreaSWLatlng(coor.latlng.lat(),coor.latlng.lng(),500),getAreaNELatLng(coor.latlng.lat(),coor.latlng.lng(),500));
			$( "#markerArea" ).slider( "value", 500 );

			$("#addMarkerButton").show();
			$("#updateMarkerButton").hide();

			$("#markerContentWin").show();
			$("#markerContentWin").center();

		}
		}));
	}

	menu.addItem(new MenuItem({

		text: language.fdyj,
		groupName: "map",
		handler: function(coor) {
		map.setZoom(map.getZoom() + 1);
	}
	}));
	menu.addItem(new MenuItem({
		text: language.sxyj,
		groupName: "map",
		handler: function(coor) {
		map.setZoom(map.getZoom() - 1);
	}
	}));  
}

function addMarkerGroupSelect(){
	//获取标注组Json集
	getGroupJson();
	$(".marker_group_select_box").unbind("click")
	if(markerGroupJson==null){
		setTimeout("addMarkerGroupSelect()",500);
		return;
	}
	var optionStr="<a name=\"0\">--"+language.xzfz+"--</a>"; 
	for(var i=0;i<markerGroupJson.totalcount;i++){
		if(typeof markerGroupJson.data[i] !="undefined"){
			optionStr+="<a name=\""+markerGroupJson.data[i].id+"\">"+markerGroupJson.data[i].groupName+"</a>";
		}
	}
	optionStr+="<a name=\"-1\" style=\"color:rgb(153,153,153);\">"+language.tjbjz+"</a>";
	document.getElementById("marker_group_option").innerHTML=optionStr;

	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
	$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
	//添加标注组开始
	$(".marker_group_select_box").click(function(event){   
		event.stopPropagation();
		$(this).find(".marker_group_option").toggle();
		$(this).parent().siblings().find(".marker_group_option").hide();
	});
	$(document).click(function(event){
		var eo=$(event.target);
		if($(".marker_group_select_box").is(":visible") && eo.attr("class")!="marker_group_option" && !eo.parent(".marker_group_option").length)
			$('.marker_group_option').hide();									  
	});
	$(".marker_group_option a").click(function(){
		var value=$(this).attr("name");
		$(".marker_group_select_txt").text("");
		$("#markerGroupId").val("");
		if(value=="-1"){
			$("#groupPanel").text(language.tjz);
			$("#addMarkerGroup").show();
			$("#updateMarkerGroup").hide();
			$("#addMarkerGroup").removeAttr("disabled");
			$("#addGroupContentWin").css("z-index",$("#markerContentWin").css("z-index")+1);
			$("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
			$("#markerGroupName").val("");
			$("#addGroupContentWin").show();
			$("#addGroupContentWin").center();
		}else{
			$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
			$("#markerGroupId").val(value);
		}

	});
	//添加标注组结束

}

function addMarkerGroup(){
	$("#addMarkerGroup").attr("disabled","disabled");
	var groupName=$("#markerGroupName").val();

	if(groupName==""||groupName==null){
		$("#addMarkerGroupmsg").text(language.zmbnwk);
		$("#addMarkerGroupmsg").css("color","red");
		$("#addMarkerGroup").removeAttr("disabled");
		return;
	}

	$.ajax({
		type: "POST",
		dataType: "json",
		async:false,
		url: "json/markerAction_addOrUpdateUserMarkerGroup.action",
		data:{"groupName":groupName},
		success: function(json) {		         
			if (json.flag==true) {		         				         		

				$(".marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
				$("#markerGroupId").val(json.data[0].id); 
				var newoption=$("<a name=\""+json.data[0].id+"\">"+json.data[0].groupName+"</a>");
				$(".marker_group_option a").eq($(this).size()-2).before(newoption);
				addMarkerGroupTreeGroupNode(json.data[0].id,json.data[0].groupName);
				newoption.click(function(){
					var value=$(this).attr("name");
					$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
					$("#markerGroupId").val(value);				    							    
				});

				$("#closeGroupWin").click(); 
				$("#addMarkerGroup").removeAttr("disabled");	 					           				
			}else{
				if(json.msg != "10000"){
					$("#addMarkerGroupmsg").text(json.msg);
					$("#addMarkerGroupmsg").css("color","red");
				}else{
					$("#addMarkerGroupmsg").text(language.zmbncf);
					$("#addMarkerGroupmsg").css("color","red");
				}
				$("#addMarkerGroup").removeAttr("disabled");
			}
		},
		error: function() {$("#addMarkerGroup").removeAttr("disabled");}
	});	
}

var selectImage=null;
function getImgURL(el){

	$("#markerImagesrc").css("backgroundImage","url("+$(el).attr("src")+")"); 

	$("#label-icon-list").hide();

	$("#markerImagesrc").attr("class","markerImagesrc");

	isopenMarkerselectWin=true;

}

var isopenMarkerselectWin=true;

function openMarkerselectWin(){

	if(isopenMarkerselectWin){		

		$("#label-icon-list").show();

		$("#markerImagesrc").attr("class","markerImagesrc on");

		isopenMarkerselectWin=false;

		if($("#label-icon-list").children().length == 1){

			$("#MarkerImgloading").show();

			/*$.ajax({
		        type: "POST",
		        dataType: "json",
		        url: "markerImgJSON.jsp",
		        success: function(data) {

			       TuPian(data);

		        },
		        error: function() {}
	  		 });*/	

			$.getScript("http://www.exlive.cn/mi/markerImgJSON.jsp?gpscallback=TuPian",null);

		}
	}else{	
		$("#label-icon-list").hide();
		$("#markerImagesrc").attr("class","markerImagesrc");
		isopenMarkerselectWin=true;		
	}
}

function TuPian(data){
	var imgs = [];
	if(data!=null){
		for(var i=1;i<data.data.length;i++){
			if(data.data[i][0]=="false"){
				imgs.push("<li style='width: 280px;'><div style='overflow:hidden;background:#999;height:1px;'></div></li>");
			}else{
				imgs.push("<li><img src='http://www.exlive.cn/mi/"+data.data[i][2]+"' onclick='getImgURL(this);'/></li>");
			}
		}
	}

	$("#label-icon-list").append(imgs.join(""));
	$("#MarkerImgloading").hide();


}

function closeVehicleInfoWindow(){
	for(var i=0;i<vehicles.length;i++){
		vehicles[i].infowindow.close();
	}
}


//单击时关闭标注和设备弹出框
function mapclickEvent(){

	if(typeof map=="undefined"){
		setTimeout('mapclickEvent()',500);
		return;
	}

	google.maps.event.addListener(map, "click", function (e) {
		markerObject.closeInfowindow();
		closeVehicleInfoWindow();
	});
}

function close(){
	document.getElementById("biaozhu_open").style.display = "none"
	document.getElementById("biaozhu_close").style.display = "block"
	isopenmarkerPanelOpen=true;
}

function openMarkerPanel(){
	isopenmarkerPanelOpen=false;		
	document.getElementById("biaozhu_close").style.display = "none"
	document.getElementById("biaozhu_open").style.display = "block"



}
var isopenmarkerPanelOpen=true;
function openmarkerPanel(type_){
	if(isopenmarkerPanelOpen){



		document.getElementById("biaozhu_close").style.display = "none"
			document.getElementById("biaozhu_open").style.display = "block"

				isopenmarkerPanelOpen=false;


		if(type_==1){

			electronicFence.tree.hide();

		}else{

			electronicFence.tree.show();

		}

	}else{

		if((type_ == 1 && !electronicFence.tree.isShow) || (type_ == 2 && electronicFence.tree.isShow)){
			document.getElementById("biaozhu_open").style.display = "none"
				document.getElementById("biaozhu_close").style.display = "block"
					isopenmarkerPanelOpen=true;
		}

		if(type_==1){

			electronicFence.tree.hide();

		}else{

			electronicFence.tree.show();

		}

	}
}

var treeObj = null;

function showMarkerGroupTree(){
	if( markerObject.markerJson==""||allMarkerGroupJson==null){
		setTimeout("showMarkerGroupTree()",500);
		return;
	}
	if(allMarkerGroupJson.totalcount!=0){
		var groupNodeTreeStr="[";
		for(var i=0;i<allMarkerGroupJson.data.length;i++){
			//optionStr+="<a name=\""+markerGroupJson.data[i].id+"\">"+markerGroupJson.data[i].groupName+"</a>";
			if(typeof allMarkerGroupJson.data[i]!="undefined"){
				groupNodeTreeStr+="{ \"id\":\"g_"+allMarkerGroupJson.data[i].id+"\",\"title\":\""+allMarkerGroupJson.data[i].groupName+"\",\"name\":\""+allMarkerGroupJson.data[i].groupName+"\",\"icon\":\""+markerUrl.groupNodeicon+"\",\"count\":\"0\",\"pId\": \"0\"},";
			}
		}
		groupNodeTreeStr=groupNodeTreeStr.substring(0,groupNodeTreeStr.length-1);



		groupNodeTreeStr="[{\"id\":\"root_g_-1000\",\"open\":\"true\",\"title\":\""+language.yhbz+"\",\"name\":\""+language.yhbz+"\",\"icon\":\""+electronicFenceUrl.allDom+"\",\"pId\": \"-1000\","+
		"\"children\":"+groupNodeTreeStr+"]}]";
		groupNodeTreeStr=$.parseJSON(groupNodeTreeStr);
		var setting={
				callback: {
			onClick: zTreeOnClick,
			onCheck: zTreeOnCheck,
			onRightClick: OnRightClick
		},check: {
			enable: true
		},
		data: {
			simpleData: {
			enable: true,
			idKey: "id"
		}
		},
		view: {
			addHoverDom: addHoverDom,
			removeHoverDom: removeHoverDom
		}		
		}
		$.fn.zTree.init($("#markerGroupTree"),setting,groupNodeTreeStr);
		treeObj = $.fn.zTree.getZTreeObj("markerGroupTree");
		var parentNode,newNode;
		for(var i=0;i< markerObject.markerJson.data.length;i++){   
			addMarkerGroupTreeNode( markerObject.markerJson.data[i].id, markerObject.markerJson.data[i].groupid, markerObject.markerJson.data[i].title);
		}
	}
}

function addMarkerGroupTreeNode(id,parentId,title){

	var newNode = [{'id':id,'name':title,"icon":markerUrl.markericon}];
	parentNode=treeObj.getNodeByParam("id","g_"+parentId);

	if(parentNode!=null){

		newNode=treeObj.addNodes(parentNode,newNode,true);

		parentNode.count=parseInt(parentNode.count)+1;
		parentNode.name =parentNode.title+"("+parentNode.count+")";
		treeObj.updateNode(parentNode);			

	}else{

		parentNode=treeObj.getNodeByParam("id","g_0");
		newNode=treeObj.addNodes(parentNode,newNode,true);
		parentNode.count=parseInt(parentNode.count)+1;
		parentNode.name =parentNode.title+"("+parentNode.count+")";
		treeObj.updateNode(parentNode);	

	}

	return newNode;
}
function addMarkerGroupTreeGroupNode(id,title){

	var newNode =null;

	if(treeObj==null){
		var setting={
				callback: {
			onClick: zTreeOnClick,
			onCheck: zTreeOnCheck,
			onRightClick: OnRightClick
		},
		check: {
			enable: true
		},
		data: {
			simpleData: {
			enable: true,
			idKey: "id"
		}
		},
		view: {
			addHoverDom: addHoverDom,
			removeHoverDom: removeHoverDom
		}		
		}



		$.fn.zTree.init($("#markerGroupTree"),setting,[{id:"root_g_-1000",open:true,title:language.yhbz,name:language.yhbz,icon:electronicFenceUrl.allDom,pId: -1000,
			children:[{ id:"g_"+id, pId: 0,title: title,count:0,name:title,icon:markerUrl.groupNodeicon}]}]);
		treeObj = $.fn.zTree.getZTreeObj("markerGroupTree");

	}else{

		newNode= [{id:"g_"+id, pId: 0,title: title,count:0,name:title,"icon":markerUrl.groupNodeicon}];
		var parentNode=treeObj.getNodeByParam("id","root_g_-1000");

		treeObj.addNodes(parentNode,newNode,true);
	}

	//addHoverDom("markerGroupTree", newNode);
	//removeHoverDom("markerGroupTree", newNode);

	markerGroupJson.data.push({"id":id,"groupName":title});
	allMarkerGroupJson.data.push({"id":id,"groupName":title});


	//treeObj.destroy();
	//showMarkerGroupTree();
}
function deleteMarkerGroupTreeNode(nodeid){
	var curnode=treeObj.getNodeByParam("id",nodeid);
	var parentNode=curnode.getParentNode();
	treeObj.removeNode(curnode);  
	parentNode.count=parseInt(parentNode.count)-1;
	if(parentNode.count==0){
		parentNode.name =parentNode.title;
	}else{
		parentNode.name =parentNode.title+"("+parentNode.count+")";
	}
	treeObj.updateNode(parentNode);	
}

var showmarkersArr = new Array();
function zTreeOnClick(event, treeId, treeNode) {
	if(!treeNode.isParent){
		treeObj.checkNode(treeNode, true, false, false);
		if(mapType==1 && baidMap!=undefined){
			updateMarkerIsShow(treeNode.id,true,false);
			showMarkersBaidu(treeNode.id,false);
			openMarkerBaidu(treeNode.id);	

		}else if(mapType==3){
			var mnodes = treeObj.getCheckedNodes(true);
			GaoDemarkerShowOrHide();
			return;
		}else{
			var curmarker=markerObject.markerArr[treeNode.id];

			if(curmarker!=null){
				curmarker.isShow=true;
			}
			openMarker(treeNode.id);
		}

	}

}

function zTreeOnCheck(event,treeId,treeNode){
	
	//console.info("点击标注"+JSON.stringify(treeNode));
	if(treeObj==null){
		return;
	}
	if(mapType==3){
		var mnodes = treeObj.getCheckedNodes(true);
		GaoDemarkerShowOrHide();
		return;
	}
	if(mapType==2 && map!=undefined){
		if(markerObject.infowindow!=null){
			markerObject.infowindow.close();
		}
	}
	var isParent = false;

	var nodesNoChecked = treeObj.getCheckedNodes(false);
	if(mapType==1 && baidMap!=undefined){
		showMarkerBaidu(markerObject.markerJson);
	}
	for(var i=0;i<nodesNoChecked.length;i++){
		isParent=nodesNoChecked[i].isParent;
		if(!isParent){
			
			if(mapType==1 && baidMap!=undefined){
				updateMarkerIsShow(nodesNoChecked[i].id,false,false);
				hideMarkersBaidu(nodesNoChecked[i].id,false);
			}else{
				var curmarker=markerObject.markerArr[nodesNoChecked[i].id];
				if(curmarker!=null){
					curmarker.isShow=false;
					if(curmarker.marker != null){
						if(curmarker.marker.getMap() != null){
							curmarker.marker.setMap(null);
						}
					}

					if(curmarker.area != null){
						if(curmarker.area.getMap() != null){
							curmarker.area.setMap(null);
						}
					}
				}
			}
		}
	}


	var nodes = treeObj.getCheckedNodes(true);

	var curmarker=null;

	for(var i=0;i<nodes.length;i++){
		isParent=nodes[i].isParent;
		if(!isParent){
			if(mapType==1 && baidMap!=undefined){
				updateMarkerIsShow(nodes[i].id,true,false);
				showMarkersBaidu(nodes[i].id,false);	
			}else{
				curmarker=markerObject.markerArr[nodes[i].id];
				if(curmarker!=null){
					curmarker.isShow=true;
					if(curmarker.marker != null){
						if(curmarker.marker.getMap() == null){
							curmarker.marker.setMap(map);
						}
					}

					if(curmarker.area != null){
						if(curmarker.area.getMap() == null){
							curmarker.area.setMap(map);
						}
					}
				}
			}
		}
	}

	if($("#bzShowNamekbox").attr("checked")){
		hideMarkerName();
	}


}

function  OnRightClick(event, treeId, treeNode){	

	if(!treeNode){
		return;
	}

	if(treeNode.id == "root_g_-1000"){

	}else if(treeNode.getParentNode().id == "root_g_-1000"){

	}else{

		MarkerTreeMenu.showRMenu("marker", event.clientX, event.clientY,treeNode);
	}
}

function addHoverDom(treeId, treeNode) {
	if(treeNode!=null){
		if (treeNode.parentNode && treeNode.parentNode.id!=1) return;
		var aObj = $("#" + treeNode.tId + "_a");
		if ((treeNode.id+"").indexOf("_")>=0&&treeNode.id.split("_")[0]=="g"&&treeNode.id.split("_")[1]!="0") {
			for(var i=0;i<markerGroupJson.data.length;i++){
				if(typeof markerGroupJson.data[i]!="undefined"){
					if("g_"+markerGroupJson.data[i].id==treeNode.id){
						if ($("#diyBtn_space_"+treeNode.id).length>0) return;
						var editStr = "<span id='diyBtn_space_" +treeNode.id+ "' >&nbsp;</span><span class='button update' id='update_diyBtn_" +treeNode.id+ "' title='"+treeNode.name+"' onfocus='this.blur();'></span><span class='button delete' id='del_diyBtn_" +treeNode.id+ "' title='"+treeNode.name+"' onfocus='this.blur();'></span>";
						aObj.append(editStr);
						var delbtn = $("#del_diyBtn_"+treeNode.id);
						var updatebtn = $("#update_diyBtn_"+treeNode.id);
						if (delbtn) delbtn.bind("click", function(){
							if(treeNode!=null){
								if(confirm(language.qryscz)){
									deleteMarkerGroup(treeNode.id);
								}
							}
						});
						if (typeof updatebtn !="undefined") 
							updatebtn.bind("click", function(){if(treeNode!=null){openupdateGroupWin(treeNode.id);}});
						break;
					}
				}
			}
		}
	}
}

function removeHoverDom(treeId, treeNode) {
	if(treeNode!=null){
		$("#del_diyBtn_"+treeNode.id).unbind().remove();
		$("#update_diyBtn_"+treeNode.id).unbind().remove();
		$("#diyBtn_space_" +treeNode.id).unbind().remove();
	}
}

function deleteMarkerGroup(id){

	if(treeObj!=null){
		var curnode=treeObj.getNodeByParam("id",id);
		//判断是否不存在
		if(curnode!=null){
			//判断是否有子节点
			if(curnode.children==null || curnode.children.length==0){

				var groupid=parseInt(id.split("_")[1]);

				$.ajax({
					type: "POST",
					dataType: "json",
					async:false,
					url: "json/markerAction_delUserMarkerGroup.action",
					data:{"groupid":groupid+""},
					success: function(json) {		         
						if (json.flag==true) {
							//--删除组
							treeObj.removeNode(curnode);

							//--删除json中的组allMarkerGroupJson，markerGroupJson					 		     
							for(var i=0;i<allMarkerGroupJson.data.length;i++){

								if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==groupid){
									delete allMarkerGroupJson.data[i];
									break;
								}
							}

							for(var i=0;i<markerGroupJson.data.length;i++){
								if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==groupid){
									delete markerGroupJson.data[i];
									break;
								}
							}

							if($("#markerGroupId").attr("value")==groupid+""){
								$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
								$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
							}				 		     
							$("#addMarkerGroupSelect a[name='"+groupid+"']").remove(); 			           				
						}else{ 
							if( json.msg = "10002" ){
								alert(language.dqzxybzbnsc);
							}else{
								alert(json.msg);
							}
						}
					},
					error: function() {}
				});	

			}else{
				alert(language.dqzxybzbnsc);
			}
		}
	}
}

function openupdateGroupWin(id){
	$("#closeGroupWin").click();
	$("#updateMarkerGroup").removeAttr("disabled");
	for(var i=0;i<markerGroupJson.totalcount;i++){
		if( typeof markerGroupJson.data[i]!="undefined" && "g_"+markerGroupJson.data[i].id==id){
			$("#markerGroupName").val(markerGroupJson.data[i].groupName);
			$("#markerGroupId").val(markerGroupJson.data[i].id);
			break;
		}
	}
	$("#groupPanel").text(language.xgz);

	$("#updateMarkerGroup").show();
	$("#addMarkerGroup").hide();

	$("#addGroupContentWin").css("z-index",$("#markerContentWin").css("z-index")+1);
	$("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
	$("#addGroupContentWin").show();
	$("#addGroupContentWin").center();


}

function updateMarkerGroup(){

	$("#updateMarkerGroup").attr("disabled","disabled");
	var groupName=$("#markerGroupName").val();

	if(groupName==""||groupName==null){
		$("#addMarkerGroupmsg").text(language.zmbnwk);
		$("#addMarkerGroupmsg").css("color","red");
		$("#updateMarkerGroup").removeAttr("disabled");
		return;
	}

	var id=$("#markerGroupId").val();

	$.ajax({
		type: "POST",
		dataType: "json",
		async:false,
		url: "json/markerAction_addOrUpdateUserMarkerGroup.action",
		data:{"groupid":id,"groupName":groupName},
		success: function(json) {		         
			if(json.flag==true){
				if(json.data!=null&&json.data.length>0){

					var curnode=treeObj.getNodeByParam("id","g_"+id);

					if(curnode!=null){
						curnode.title=json.data[0].groupName;
						if(curnode.count!=0){
							curnode.name =curnode.title+"("+curnode.count+")";
						}else{
							curnode.name =curnode.title;
						}
						treeObj.updateNode(curnode);	         		 		
					}

					for(var i=0;i<allMarkerGroupJson.data.length;i++){

						if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==parseInt(id)){
							allMarkerGroupJson.data[i].groupName=json.data[0].groupName;
							break;
						}
					}

					for(var i=0;i<markerGroupJson.data.length;i++){
						if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==parseInt(id)){
							markerGroupJson.data[i].groupName=json.data[0].groupName;
							break;
						}
					}

					if($("#markerGroupId").attr("value")==id){
						$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
						$("#markerGroupId").val(json.data[0].id);
					}

					$("#addMarkerGroupSelect a[name='"+id+"']").text(json.data[0].groupName);
				}
				$("#closeGroupWin").click(); 
				$("#updateMarkerGroup").removeAttr("disabled");

			}else{
				if(json.msg != "10000"){
					$("#addMarkerGroupmsg").text(json.msg);
					$("#addMarkerGroupmsg").css("color","red");
				}else{
					$("#addMarkerGroupmsg").text(language.zmbncf);
					$("#addMarkerGroupmsg").css("color","red");
				}
				$("#updateMarkerGroup").removeAttr("disabled");
			}
		},
		error: function() {$("#updateMarkerGroup").removeAttr("disabled");}
	});	
}


function openMarker(_id){
	if(markerObject.infowindow!=null){
		markerObject.infowindow.close();
	}
	var curmarker=markerObject.markerArr[_id];
	if(curmarker!=null){
		map.setCenter(new google.maps.LatLng(curmarker.lat,curmarker.lng));
		map.setZoom(13);

		for(var i=0;i<markerObject.markerids.length;i++){
			if(markerObject.markerArr[markerObject.markerids[i]].marker != null && markerObject.markerArr[markerObject.markerids[i]].isShow){
				if(markerObject.markerArr[markerObject.markerids[i]].marker.getMap() == null){
					markerObject.markerArr[markerObject.markerids[i]].marker.setMap(map);
				}
			}
			if(markerObject.markerArr[markerObject.markerids[i]].area != null && markerObject.markerArr[markerObject.markerids[i]].isShow){
				if(markerObject.markerArr[markerObject.markerids[i]].area.getMap() == null){
					markerObject.markerArr[markerObject.markerids[i]].area.setMap(map);
				}
			}

			if(!markerObject.markerArr[markerObject.markerids[i]].isShow && markerObject.markerArr[markerObject.markerids[i]].marker != null){
				if(markerObject.markerArr[markerObject.markerids[i]].marker.getMap() != null){
					markerObject.markerArr[markerObject.markerids[i]].marker.setMap(null);
				}
			}

			if(!markerObject.markerArr[markerObject.markerids[i]].isShow && markerObject.markerArr[markerObject.markerids[i]].area != null){
				if(!markerObject.markerArr[markerObject.markerids[i]].area.getMap() != null){
					markerObject.markerArr[markerObject.markerids[i]].area.setMap(null);
				}
			}
		}

		if($("#bzShowNamekbox").attr("checked")){
			hideMarkerName();
		}

		if(curmarker.marker!=null){
			curmarker.marker.setMap(map);
			google.maps.event.trigger(curmarker.marker, 'click');
		}

		if(curmarker.area!=null){
			curmarker.area.setMap(map);
		}
	}
}


function showMarkerName(element){
	if(mapType==1){
		if($(element).attr("checked")){
			for(var j=0;j<bzMarkers.length;j++){
				if(bzMarkers[j].label != null){
					if(bzMarkers[j].isShow){
						baidMap.addOverlay(bzMarkers[j].label);
					}
				}
			}
		}else{
			for(var j=0;j<bzMarkers.length;j++){
				if(bzMarkers[j].label != null){
					baidMap.removeOverlay(bzMarkers[j].label);
				}
			}
		}
	}else if(mapType==3){
		if($(element).attr("checked")){
			for(var j=0;j<bz_gdMarkers.length;j++){
				var label = {//label默认蓝框白底左上角显示，样式className为：amap-marker-label
						offset: new AMap.Pixel(20,2),//修改label相对于maker的位置
						content:bz_gdMarkers[j].title
				};
				bz_gdMarkers[j].setLabel(label);
			}
		}else{
			for(var j=0;j<bz_gdMarkers.length;j++){
				bz_gdMarkers[j].setLabel(null);
			}
		}
	}else{
		if($(element).attr("checked")){
			for(var i=0;i<markerObject.markerids.length;i++){
				if(markerObject.markerArr[markerObject.markerids[i]] != null && markerObject.markerArr[markerObject.markerids[i]].isShow && markerObject.markerArr[markerObject.markerids[i]].marker != null){
					markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+markerObject.markerArr[markerObject.markerids[i]].title+"</div>",markerObject.markerArr[markerObject.markerids[i]].marker.getPosition()));
				}
			}
		}else{
			for(var i=0;i<markerObject.markerids.length;i++){
				if(markerObject.markertitlearr[i]!=null){
					//markerObject.markertitlearr[i].setMap(null);
					markerObject.markertitlearr[i]=null;
				}
			}
			markerObject.markertitlearr=new Array();
		}
	}
}

function hideMarkerName(){
	for(var i=0;i<markerObject.markerids.length;i++){
		if(markerObject.markertitlearr[i]!=null){
			markerObject.markertitlearr[i].setMap(null);
			markerObject.markertitlearr[i]=null;
		}
	}
	markerObject.markertitlearr=new Array();

	if($("#bzShowNamekbox").attr("checked")){
		for(var i=0;i<markerObject.markerids.length;i++){
			if(markerObject.markerArr[markerObject.markerids[i]] != null && markerObject.markerArr[markerObject.markerids[i]].isShow && markerObject.markerArr[markerObject.markerids[i]].marker != null){
				markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+markerObject.markerArr[markerObject.markerids[i]].title+"</div>",markerObject.markerArr[markerObject.markerids[i]].marker.getPosition()));
			}

		}

	}


}


function frame(framecontentId,framemovetitleId,closebuttonId){

	$("#"+closebuttonId).click(function(event){
		stopBubble(event);
		$("#"+framecontentId).hide();

		if(closebuttonId=="closeGroupWin"){
			var groupName=$(".marker_group_option a").parent().siblings(".marker_group_select_txt");
			var groupId=$("#markerGroupId");
			if(groupName.text()==""&&groupId.val()==""){
				groupName.text($(".marker_group_option a").eq(0).text());
				groupId.val($(".marker_group_option a").eq(0).attr("name"));
			}
			$("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
			$("#addMarkerGroupmsg").text(language.zmbnwk);

		}                 
		if(closebuttonId=="closecmarkerWin"){

			var curMarkerObject=markerObject.markerArr[$("#markerId").val()];

			if(baidMap != null){

				if(curMarkerObject){

					var pStart,pEnd;

					if(curMarkerObject.blat != 0 && curMarkerObject.blat != 0){
						pStart = getAreaNELatLngBaidu(curMarkerObject.blat,curMarkerObject.blng,curMarkerObject.areaRadius);
						pEnd = getAreaSWLatlngBaidu(curMarkerObject.blat,curMarkerObject.blng,curMarkerObject.areaRadius);
					}else{
						pStart = getAreaNELatLngBaidu(curMarkerObject.lat,curMarkerObject.lng,curMarkerObject.areaRadius);
						pEnd = getAreaSWLatlngBaidu(curMarkerObject.lat,curMarkerObject.lng,curMarkerObject.areaRadius);
					}

					updateMarkerBaidu(curMarkerObject.id,pStart,pEnd);

				}else{
					baidMap.removeOverlay(oldPolygon);
				}	    	
			}

			if(selectImage!=null){
				selectImage.attr("class","unselected");
				selectImage=$("#selectImage");//用于保存当前选中的标记图标
				selectImage.attr("class","selected");   			 
			}	
			isopenMarkerselectWin=false;
			openMarkerselectWin();
			isopenMarkerselectWin=true;

			if(markerArea!=null){
				markerArea.setMap(null); //删除未添加标注绘制的默认区域
				markerArea=null;   
			}



			if(curMarkerObject && curMarkerObject.area){
				curMarkerObject.area.setMap(map);
			}


			/*if($("#markerId").val().length!=0&&markerArea!=null){
	    			 	markerArea.setMap(null); //删除未添加标注绘制的默认区域
	    			 	markerArea=null;
	    			    clearAreaLagLng();    			   
    			 }else{
    			 		if(markerArea!=null){
	    			 		markerArea.setMap(null); //删除未添加标注绘制的默认区域
		    			 	markerArea=null;
	    			 	}
	    			    clearAreaLagLng(); 
    			 }*/

			$("#markerId").val("");

			clearAreaLagLng(); 

			$("#customerNum").val("");

			$("#customerNumListOutCanvas").html("");
			$("#addcustomerNum_Msg").html("&nbsp;");
		}
		if(closebuttonId=="closePasswordWin"){
			$("#updatePasswordMsg").css("color","rgb(153, 153, 153)");
			$("#updatePasswordMsg").text(language.mmbnwk);
			$("#curPassword").val("");
			$("#newPassword").val("");
			$("#renewPassword").val("");
			$("#updatePassBtn").removeAttr("disabled");
		}	   
	});
	$("#"+framemovetitleId).mousedown(function(dom){
		var top1=$("#"+framecontentId).css("top");
		var left1=$("#"+framecontentId).css("left");
		var x=dom.clientX;
		var y=dom.clientY;
		var x1=Math.abs(x-parseInt(left1));
		var y1=Math.abs(y-parseInt(top1));
		$("body").mousemove(function(dom){
			var x=dom.clientX;
			var y=dom.clientY;  
			$("#"+framecontentId).css({"top":y-y1,"left":x-x1});
		});
	}).mouseup(function(){
		$("body").unbind("mousemove"); 	
	});
}
/*
 *区域
 */
var markerArea=null;
var markersize=500;
function loadAreaSlider(){
	$( "#markerArea" ).slider({
		range : "min",
		max : 5000,
		min : 0,
		value : 0,
		orientation : 'horizontal'
	});
	$("#markerArea").bind('slidechange', function(event, ui) {
		/*var r=ui.value;
			var t=4;
			var w=100;
			var p=[500,800,1200,1500,2000,3000,5000];//[5000,3000,2000,1000,1500,800,500]
			var u=[0,20,40,60,80,100,120,140];
			for(var s=0,o=u.length-1;s<o;s++){
				if(r>=u[s]&&r<u[s+1]){
					t=s;
					break
				}
				if(r>=140){
					t=6;
					break
				}
			}*/
		markersize=ui.value;
		updateMarkerArea(ui.value,markerArea);
	});
}

function drawMarkerArea(lefttoplatlng_,rigthbelowlatlng_){

	return rectangle = new google.maps.Rectangle({
		strokeColor: '#0000FF',
		strokeOpacity: 0.8,
		strokeWeight: 2,
		fillColor: '#0000cc',
		fillOpacity: 0.35,
		zIndex:0,
		map: map,
		bounds: new google.maps.LatLngBounds(
				lefttoplatlng_,
				rigthbelowlatlng_)
	});  
}

function updateMarkerArea(len_,markerArea_){
	$("#markersize").text(len_+"m");
	if(mapType==1){
		var pStart = getAreaNELatLng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_);
		var pEnd = getAreaSWLatlng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_);

		if($("#markerId").attr("value")==""){
			addMarkerBaidu(pStart,pEnd);
		}else{
			updateMarkerBaidu($("#markerId").attr("value"),pStart,pEnd);
		}
	}else if(mapType==3){
		
	}else{
		markerArea_.setBounds(new google.maps.LatLngBounds(getAreaSWLatlng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_),getAreaNELatLng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_)));
	}
}

function getAreaNELatLng(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#rigthlat").val(lat_-dlat);
	$("#rigthlng").val(lng_+dlng);

	var obj = null;
	try{		
		obj = new google.maps.LatLng(lat_-dlat,lng_+dlng);
	}catch(e){
		obj = {				 
				lat:function(){
			return lat_-dlat
		},
		lng:function(){
			return lng_+dlng
		}	 
		}
	}
	return obj;
}
function getAreaSWLatlng(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#leftlat").val(lat_+dlat);
	$("#leftlng").val(lng_-dlng);

	var obj = null;
	try{
		obj = new google.maps.LatLng(lat_+dlat,lng_-dlng);
	}catch(e){	
		obj = {				 
				lat:function(){
			return lat_+dlat
		},
		lng:function(){
			return lng_-dlng
		}	 
		}
	}

	return obj;
}

function getAreaNELatLngBaidu(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#rigthlat").val(lat_-dlat);
	$("#rigthlng").val(lng_+dlng);
	return new BMap.Point(lng_+dlng,lat_-dlat);
}
function getAreaSWLatlngBaidu(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#leftlat").val(lat_+dlat);
	$("#leftlng").val(lng_-dlng);
	return new BMap.Point(lng_-dlng,lat_+dlat);
}

function clearAreaLagLng(){
	$("#leftlat").val("");
	$("#leftlng").val("");
	$("#rigthlat").val("");
	$("#rigthlng").val("");
	markersize=500;
}
/*
 *tool
 */
function showtoolPanel(){
	$("#tools_box").show();
}
function hidetoolPanel(){
	$("#tools_box").hide();
}

Array.prototype.remove=function(dx){
	if(isNaN(dx)||dx>this.length){return false;}
	for(var i=0,n=0;i<this.length;i++){
		if(this[i]!=this[dx]){
			this[n++]=this[i]
		}
	}
	this.length-=1
}

function initMarkerisShow(){

	if(treeObj==null){
		return;
	}
	if(mapType=="1" && baidMap!=undefined){
		var isParent = false;

		var nodesNoChecked = treeObj.getCheckedNodes(false);

		for(var i=0;i<nodesNoChecked.length;i++){
			isParent=nodesNoChecked[i].isParent;
			if(!isParent){			
				updateMarkerIsShow(nodesNoChecked[i].id,false,false);
				hideMarkersBaidu(nodesNoChecked[i].id,false);
			}
		}


		var nodes = treeObj.getCheckedNodes(true);

		var curmarker=null;

		for(var i=0;i<nodes.length;i++){
			isParent=nodes[i].isParent;
			if(!isParent){
				updateMarkerIsShow(nodes[i].id,true,false);
				showMarkersBaidu(nodes[i].id,false);
			}
		}
	}else{
		zTreeOnCheck(null,null,null);
	}
}
$(function(){
	Array.prototype.remove=function(dx)
	{
		if(isNaN(dx)||dx>this.length){return false;}
		for(var i=0,n=0;i<this.length;i++)
		{
			if(this[i]!=this[dx])
			{
				this[n++]=this[i]
			}
		}
		this.length-=1
	}
});
var markerRefreshObject = {
		refresh : function (id,groupId,eventName,isMarker){//alert("id="+id+",groupId="+groupId+",eventName="+eventName+",isMarker="+isMarker);
	switch(eventName){
	case "add" :    
		if(isMarker){
			markerRefreshObject.addMarker(id);
		}else{
			markerRefreshObject.addMarkerGroup(id);
		}

		break;

	case "delete" : 
		if(isMarker){
			markerRefreshObject.delMarker(id);
		}else{
			markerRefreshObject.delMarkerGroup(id);
		}

		break;

	case "update" : 
		if(isMarker){
			markerRefreshObject.updateMarker(id);
		}else{
			markerRefreshObject.updateMarkerGroup(id);
		}

		break;
	}
},
addMarker : function(id){
	if(treeObj!=null && treeObj.getNodeByParam("id",id) == null){
		$.ajax({
			type: "POST",
			dataType: "json",
			async:false,
			url: "json/markerAction_getMarker.action",
			data:{"id":id},
			success: function(json) {		         
				if (json.flag==true) {
					if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){

						var marker=markerObject.addMarker(json.data[0].id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);

						markerObject.markerArr[json.data[0].id]={};
						marker.setMap(null);
						markerObject.markerArr[json.data[0].id].marker=marker;
						markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
						markerObject.markerArr[json.data[0].id].title=json.data[0].title;
						markerObject.markerArr[json.data[0].id].text=json.data[0].text;
						markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
						markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
						markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
						markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
						markerObject.markerArr[json.data[0].id].id=json.data[0].id;
						markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
						markerObject.markerArr[json.data[0].id].isShow=false;

						markerObject.markerArr[json.data[0].id].area=markerArea;
						markerObject.markerArr[json.data[0].id].areaRadius=markersize;
						markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;

						markerObject.addMarkerListener(markerObject.markerArr[json.data[0].id]);	

						if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
							markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
							markerObject.markerArr[json.data[0].id].area.setMap(null);
							markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
						}

						//添加标注所属组(若改组已经存在则不操作)
						markerRefreshObject.addMarkerGroup(json.data[0].groupid);

						addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);

						markerObject.markerJson.data.push(json.data[0]);

						markerObject.markerJson.totalcount = markerObject.markerJson.data.length;

					}

				}
			}
		});	
	}
},
delMarker : function(id){
	if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){

		markerObject.deleteMarker(id);

		deleteMarkerGroupTreeNode(id);

		for(var i=0;i<markerObject.markerids.length;i++){
			if(id==markerObject.markerids[i]){
				markerObject.markerids.remove(i);
			}
			break;
		}

		for(var i=0;i<markerObject.markerJson.data.length;i++){
			if(id==markerObject.markerJson.data[i].id){
				markerObject.markerJson.data.remove(i);
				break;
			}

		}

		markerObject.markerJson.totalcount = markerObject.markerJson.data.length;
	}

},
updateMarker : function(id){
	if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){
		$.ajax({
			type: "POST",
			dataType: "json",
			async:false,
			url: "json/markerAction_getMarker.action",
			data:{"id":id},
			success: function(json) {		         
				if (json.flag==true) {

					if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){

						if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){

							var isShow = markerObject.markerArr[json.data[0].id].isShow;

							markerObject.deleteMarker(id);
							markerObject.infowindow=null;

							var marker=markerObject.addMarker(id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);				 			 
							markerObject.markerArr[json.data[0].id]={};
							marker.setMap(isShow?map:null);
							markerObject.markerArr[json.data[0].id].marker=marker;
							markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
							markerObject.markerArr[json.data[0].id].title=json.data[0].title;
							markerObject.markerArr[json.data[0].id].text=json.data[0].text;
							markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
							markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
							markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
							markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
							markerObject.markerArr[json.data[0].id].id=json.data[0].id;
							markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
							markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;

							markerObject.markerArr[json.data[0].id].isShow=isShow;

							markerObject.addMarkerListener(markerObject.markerArr[id]);	


							var curnode=treeObj.getNodeByParam("id",json.data[0].id);

							if (curnode!=null) {

								curnode.name = json.data[0].title;

								treeObj.updateNode(curnode);


								if(curnode.getParentNode().id != 'g_'+json.data[0].groupid){

									var prevParentNode = curnode.getParentNode();

									prevParentNode.count = parseInt(prevParentNode.count)-1 ;

									if(prevParentNode.count == 0){
										prevParentNode.name = prevParentNode.title;
									}else{
										prevParentNode.name = prevParentNode.title+"("+prevParentNode.count+")";
									}

									var curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);					

									if(curGroupnode == null){

										//添加标注所属组(若改组已经存在则不操作)
										markerRefreshObject.addMarkerGroup(json.data[0].groupid);

										curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);
									}

									curGroupnode.count = parseInt(curGroupnode.count)+1 ;

									curGroupnode.name = curGroupnode.title+"("+curGroupnode.count+")";

									treeObj.moveNode(curGroupnode, curnode, "inner");

									treeObj.updateNode(prevParentNode);
									treeObj.updateNode(curGroupnode);
								}



							}


							//deleteMarkerGroupTreeNode(id);	
							//addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);	

							if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
								markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
								markerObject.markerArr[json.data[0].id].area.setMap(isShow?map:null);
								markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
							}


							if(isShow){

								if($("#bzShowNamekbox").attr("checked")){

									markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition()));

								}									  	 
							}

							for(var i=0;i<markerObject.markerJson.data.length;i++){
								if(json.data[0].id==markerObject.markerJson.data[i].id){
									markerObject.markerJson.data.remove(i);
									break;
								}
							}

							markerObject.markerJson.data.push(json.data[0]);
						}	  	 
					}		 			  	 
				}
			}
		});
	}
},
addMarkerGroup : function(id){
	//查看标注所属组存不存在
	//不存在查找添加组
	//存在添加标注
	if(id != 0 && treeObj != null){
		var curnode=treeObj.getNodeByParam("id","g_"+id);
		//判断是否不存在
		if(curnode==null){
			//查找组
			$.ajax({
				type: "POST",
				dataType: "json",
				async:false,
				url: "json/markerAction_getUserMarkerGroup.action",
				data:{"groupid":id},
				success: function(json) {		         
					if (json.flag==true) {

						//**************
						if(parseInt($("#userId").val()) ==json.data[0].creater ){//判断是否是该用户的组

							if($("#addMarkerGroupSelect a[name='"+id+"']").length<=0){
								var newoption=$("<a name=\""+json.data[0].id+"\">"+json.data[0].groupName+"</a>");

								$(".marker_group_option a").eq($(this).size()-2).before(newoption);

								newoption.click(function(){

									var value=$(this).attr("name");
									$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
									$("#markerGroupId").val(value);	

								});
								markerGroupJson.data.push(json.data[0]);
							}			
						}else{									    			    				
							allMarkerGroupJson.data.push(json.data[0]);									    				
						}
						addMarkerGroupTreeGroupNode(json.data[0].id,json.data[0].groupName);			    						 
					}
				}
			});		    	  	
		}
	}
},
delMarkerGroup : function(id){
	if(treeObj!=null){
		var curnode=treeObj.getNodeByParam("id","g_"+id);
		//判断是否不存在
		if(curnode!=null){
			//判断是否有子节点
			if(curnode.children==null || curnode.children.length==0){

				var groupid=parseInt(id.split("_")[1]);

				//--删除组
				treeObj.removeNode(curnode);

				//--删除json中的组allMarkerGroupJson，markerGroupJson					 		     
				for(var i=0;i<allMarkerGroupJson.data.length;i++){

					if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==groupid){
						delete allMarkerGroupJson.data[i];
						break;
					}
				}

				for(var i=0;i<markerGroupJson.data.length;i++){
					if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==groupid){
						delete markerGroupJson.data[i];
						break;
					}
				}

				if($("#markerGroupId").attr("value")==groupid+""){
					$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
					$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
				}

				$("#addMarkerGroupSelect a[name='"+groupid+"']").remove();

			}else{
				alert(language.dqzxybzbnsc);
			}
		}
	}			    
},
updateMarkerGroup : function(id){
	$.ajax({
		type: "POST",
		dataType: "json",
		async:false,
		url: "json/markerAction_getUserMarkerGroup.action",
		data:{"groupid":id},
		success: function(json) {		         
			if(json.flag==true){
				if(json.data!=null&&json.data.length>0){

					var curnode=treeObj.getNodeByParam("id","g_"+id);

					if(curnode!=null){
						curnode.title=json.data[0].groupName;	         		 		
						if(curnode.count!=0){
							curnode.name =curnode.title+"("+curnode.count+")";
						}else{
							curnode.name =curnode.title;
						}
						treeObj.updateNode(curnode);
					}

					for(var i=0;i<allMarkerGroupJson.data.length;i++){

						if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==parseInt(id)){
							allMarkerGroupJson.data[i]=json.data[0];
							break;
						}
					}

					for(var i=0;i<markerGroupJson.data.length;i++){
						if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==parseInt(id)){
							markerGroupJson.data[i]=json.data[0];
							break;
						}
					}

					if($("#markerGroupId").attr("value")==id){
						$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
					}

					$("#addMarkerGroupSelect a[name='"+id+"']").text(json.data[0].groupName);

				}

			}
		},
		error: function() {}
	});
}
}

function addEvent(){

	var isOpencustomerNumListOutCanvas = false;
	var customerNumBlurEvent = null;
	var customerNumTimeoutEvent = null;
	var isOnAddCustomerNum = false;

	$("#customerNum").focus(function(){

		/*if(!isOpencustomerNumListOutCanvas){

			$("#customerNumListOutCanvas").show();

			isOpencustomerNumListOutCanvas = true;

		}else{*/

		$("#customerNumListOutCanvas").show();

		isOpencustomerNumListOutCanvas = true;

	});

	$("#customerNum").blur(function(){

		clearTimeout(customerNumBlurEvent);

		customerNumBlurEvent = setTimeout(function(){

			if(!isOnAddCustomerNum){

				isOpencustomerNumListOutCanvas = false;

			}

			clearTimeout(customerNumTimeoutEvent);

			customerNumTimeoutEvent = setTimeout(function(){

				if(!isOpencustomerNumListOutCanvas){

					$("#customerNumListOutCanvas").hide();

					isOpencustomerNumListOutCanvas = false;


					if($("#customerNum").val().lenght == 0){
						$("#addcustomerNum_Msg").html("&nbsp;");
					}

				}

			},100);

		},100);
	});	

	$("#customerNum").mouseover(function(){

		if($("#customerNumListOutCanvas").is(":visible")){

			isOpencustomerNumListOutCanvas = true;

		}



	});

	$("#customerNum").mouseleave(function(){

		isOpencustomerNumListOutCanvas = false;

		clearTimeout(customerNumTimeoutEvent);

		customerNumTimeoutEvent = setTimeout(function(){

			if(!isOpencustomerNumListOutCanvas){

				$("#customerNumListOutCanvas").hide();

				isOpencustomerNumListOutCanvas = false;

				$("#customerNum").blur();


				if($("#customerNum").val().lenght == 0){
					$("#addcustomerNum_Msg").html("&nbsp;");
				}

			}

		},100);
	});	


	$("#customerNumListOutCanvas").mouseover(function(){

		isOpencustomerNumListOutCanvas = true;

	});

	$("#customerNumListOutCanvas").click(function(){

		isOpencustomerNumListOutCanvas = true;

	});


	$("#addcustomerNum").mouseover(function(){

		isOnAddCustomerNum = true;

		if($("#customerNumListOutCanvas").is(":visible")){

			isOpencustomerNumListOutCanvas = true;

		}

	});

	$("#addcustomerNum").mouseleave(function(){

		isOnAddCustomerNum = false;

		isOpencustomerNumListOutCanvas = false;

		clearTimeout(customerNumTimeoutEvent);

		customerNumTimeoutEvent = setTimeout(function(){

			if(!isOpencustomerNumListOutCanvas){

				$("#customerNumListOutCanvas").hide();

				isOpencustomerNumListOutCanvas = false;

				$("#customerNum").blur();


				if($("#customerNum").val().lenght == 0){
					$("#addcustomerNum_Msg").html("&nbsp;");
				}

			}

		},100);


	});

	$("#addcustomerNum").click(function(){

		isOnAddCustomerNum = true;

		if($("#customerNumListOutCanvas").is(":visible")){

			isOpencustomerNumListOutCanvas = true;

		}

		var value = $("#customerNum").val();

		var customerNum_vlaueList = getcustomerNum_vlaues();

		$("#addcustomerNum_Msg").html("&nbsp;");

		if(value.length !=0 && ($.inArray(value, customerNum_vlaueList) < 0)){

			$("#customerNumListOutCanvas").prepend("<div class='search_item' onmouseover='over(this)' onmouseout='out(this)'><span name='customerNum_vlaue' style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' >"+value+"</span><span style='float:right;margin-right:5px;margin-top:2px;*margin-right:0px;*margin-top:-12px;display:inline-block;'><a href='javascript:;' onclick='deleteCustomerNumItem(this);'><img style='display:inline-block;' src='gpsonline/image/marker/ico_dele.png'></img></a></span></div>");

			$("#customerNum").val("");

		}else if(($.inArray(value, customerNum_vlaueList) >= 0)){

			$("#addcustomerNum_Msg").text(electronicFenceLanguage.ycz);

		}



	});




	$("#customerNumListOutCanvas").mouseleave(function(){

		isOpencustomerNumListOutCanvas = false;

		clearTimeout(customerNumTimeoutEvent);

		customerNumTimeoutEvent = setTimeout(function(){

			if(!isOpencustomerNumListOutCanvas){

				$("#customerNumListOutCanvas").hide();

				isOpencustomerNumListOutCanvas = false;

				$("#customerNum").blur();

				if($("#customerNum").val().lenght == 0){
					$("#addcustomerNum_Msg").html("&nbsp;");
				}

			}

		},100);
	});	


}

function getcustomerNum_vlaues(){
	var customerNum_vlaueList = [];

	$("span[name='customerNum_vlaue']").each(function(){

		customerNum_vlaueList.push($(this).text());

	});

	return 	customerNum_vlaueList;
}

function getCNum_vlaues(){
	var customerNum_vlaueList = [];

	$("span[name='customerNum_vlaue']").each(function(){

		customerNum_vlaueList.push($(this).text().replace("/","\\"));

	});

	return 	customerNum_vlaueList;
}

function initCustomerNum_vlaue(valuesArr){

	$("#customerNumListOutCanvas").html("");

	for(var i=0;i<valuesArr.length;i++){

		if(valuesArr[i].length != 0){

			$("#customerNumListOutCanvas").append("<div class='search_item' onmouseover='over(this)' onmouseout='out(this)'><span name='customerNum_vlaue' style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' >"+valuesArr[i].replace("\\","/")+"</span><span style='float:right;margin-right:5px;margin-top:2px;*margin-right:0px;*margin-top:-12px;display:inline-block;'><a href='javascript:;' onclick='deleteCustomerNumItem(this);'><img style='display:inline-block;' src='gpsonline/image/marker/ico_dele.png'></img></a></span></div>");

		}
	}
}

function over(el) {

	$(el).attr("class","customerNum_item_over");

}

function out(el) {

	$(el).attr("class","search_item");

}				 

function deleteCustomerNumItem(el){

	$(el).parent().parent().remove();

}



var MarkerTreeMenu = {
		marker_tree_Menu :null,
		init : function(){
	this.marker_tree_Menu = $("#marker_tree_Menu");
},
showRMenu : function(type, x, y,node) {

	$("#marker_tree_Menu_del").hide();
	$("#marker_tree_Menu_update").hide();
	$("#marker_tree_Menu_bingding").hide();
	$("#marker_tree_Menu").hide();
	$("#marker_tree_Menu ul").hide();



	if(type == "marker"){
		if(markerObject.markerArr[node.id].competence == 1){

			$("#marker_tree_Menu").show();
			$("#marker_tree_Menu ul").show();

			$("#marker_tree_Menu_del").show();								
			$("#marker_tree_Menu_del").attr("markerId",node.id);

			$("#marker_tree_Menu_update").show();								
			$("#marker_tree_Menu_update").attr("markerId",node.id);	

			$("#marker_tree_Menu_bingding").show();
			$("#marker_tree_Menu_bingding").attr("markerId",node.id);

		}							
	}

	if((y + $("#marker_tree_Menu").height())<$(window).height()){

		this.marker_tree_Menu.css({"top":y+"px", "left":x+"px", "visibility":"visible"});

	}else{

		this.marker_tree_Menu.css({"top":(y-$("#marker_tree_Menu").height())+"px", "left":x+"px", "visibility":"visible"});
	}

	$("body").bind("mousedown", MarkerTreeMenu.onBodyMouseDown);

},
hideRMenu : function() {

	if (this.marker_tree_Menu) this.marker_tree_Menu.css({"visibility": "hidden"});

	$("body").unbind("mousedown", MarkerTreeMenu.onBodyMouseDown);

},
onBodyMouseDown : function(event){

	if (!(event.target.id == "marker_tree_Menu" || $(event.target).parents("#marker_tree_Menu").length>0)) {

		MarkerTreeMenu.marker_tree_Menu.css({"visibility" : "hidden"});

	}

},
del : function(el){

	MarkerTreeMenu.hideRMenu();
	deleteMarker($(el).attr("markerId"));
},
update : function(el){

	MarkerTreeMenu.hideRMenu();
	var treeNode = treeObj.getNodeByParam("id",$(el).attr("markerId"));

	treeObj.checkNode(treeNode,true,false,false);

	if(mapType==1 && baidMap!=undefined){
		updateMarkerIsShow(treeNode.id,true,false);
		showMarkersBaidu(treeNode.id,false);
		openMarkerBaidu(treeNode.id);	

	}else if(mapType==3 && gaoMap!=undefined){
		var mnodes = treeObj.getCheckedNodes(true);
		GaoDemarkerShowOrHide();
	}else{
		var curmarker=markerObject.markerArr[treeNode.id];

		if(curmarker!=null){
			curmarker.isShow=true;
		}
		openMarker(treeNode.id);
	}

	openUpdateMarkerWin($(el).attr("markerId"));

},
bingding : function(el){

	MarkerTreeMenu.hideRMenu();
	$("#markersaveMsg").text("");
	$("#marker_vehicle_binding_ContentWin").show();
	$("#marker_vehicle_binding_ContentWin").center();

	showVechileGrouptoMarkerBangDingSelect($(el).attr("markerId"));
	showVechiletoMarkerbangdingTable($(el).attr("markerId"));

}

}


function showVechileGrouptoMarkerBangDingSelect(markerId){
	$("#marker_vehicle_group").html("");
	var options =[];
	var i=0;
	$.each(equipmentMap, function (k, v) {//迭代每一个组

		if(i<1){
			options.push("<option value='"+markerId+"_"+k+"' selected='selected' >"+v.getName()+"</option>");
			i++;
		}else{
			options.push("<option value='"+markerId+"_"+k+"' >"+v.getName()+"</option>");
		}	


	});

	$("#marker_vehicle_group").append(options.join(""));

	options="";

}

function showVechiletoMarkerbangdingTable(markerId){

	$("#saveMarkerBtn").attr("markerId",markerId);

	$("#markerBangdingVehicleTitle").text("标注("+treeObj.getNodeByParam("id",markerId).name+")绑定设备");

	$("#marker_vehicle_table_content tbody").html("");

	var groupId= $("#marker_vehicle_group").val();

	if(groupId.length == 0){

		groupId = -1;

	}else{

		groupId = groupId.split("_")[1];

	}



	if(cartIds.length == 0) return;


	var curGroupChildsIds = equipmentMap[groupId] ? (equipmentMap[groupId].getChildsIds()) : (new Array());
	var curGroupChildsIdsLength = curGroupChildsIds.length;

	var id,curVehicle;

	var rows=[],options="";



	var result = getBingdingVehicleFromMarkerData(markerId);

	var isBingdinged = false;

	for(i=0;i<curGroupChildsIdsLength;i++) {

		id=curGroupChildsIds[i];	

		isBingdinged = false;

		for(var j=0;j<result.length;j++){

			if(result[j].markId == markerId && result[j].vhcId == id){

				isBingdinged = true;

				break;
			}
		}



		curVehicle=equipmentObject[id];


		if(isBingdinged){

			rows.push("<tr name='marker_vechileId_"+result[j].id+"'>" +//onclick='clearCurSelect(this)'
					"<td align='center' style='width:100px;' name='"+curVehicle.id+"'><span style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' title='"+$.trim(curVehicle.vehicleName)+"'>"+$.trim(curVehicle.vehicleName)+"</span></td>"+
					"<td align='center' style='width:100px;'><select>"+(result[j].inalarm == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
					"<td align='center' style='width:100px;'><select>"+(result[j].outalarm == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
					"<td align='center' style='width:100px;'><select>"+(result[j].recregion == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
					"<td align='center'><input type='text' class='marker_vehicle_table_input'  value='"+(result[j].stopalarmmin==0?"":result[j].stopalarmmin)+"'></input></td>"+									  
			"</tr>");

		}else{

			rows.push("<tr name=''>" +//onclick='clearCurSelect(this)'
					"<td align='center' style='width:100px;' name='"+curVehicle.id+"'><span style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' title='"+$.trim(curVehicle.vehicleName)+"'>"+$.trim(curVehicle.vehicleName)+"</span></td>"+
					"<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
					"<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
					"<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
					"<td align='center'><input type='text' class='marker_vehicle_table_input' ></input></td>"+												    
			"</tr>");

		}

	}

	$("#marker_vehicle_table_content tbody").append(rows.join(""));

	rows=[];

}

function getBingdingVehicleFromMarkerData(markId){

	var result = null;

	$.ajax({
		type: "POST",
		dataType: "json",
		url: "json/markerAction_getMarkerVehicle.action",
		data: {markId:markId},
		async : false,
		success: function(json) {	

			if(json.flag == true && json.data.length > 0){

				result = json.data;

			}      
		},
		error: function() {}
	});	

	return result != null ? result : new Array();
}

function savebingdingVehicletoMarker(el){

	$("#saveMarkerBtn").attr("disabled","disabled");//设置所有的button不可用 

	if($("#marker_vehicle_table_content tbody").html().length == 0){

		$("#markersaveMsg").text(electronicFenceLanguage.qxzybddsb);

		$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用

		return ;

	}else{

		$("#markersaveMsg").text("");
	}


	var markerId = $(el).attr("markerId");

	var tds = null,vechileId="",inalarm=0,outalarm = 0,recregion=1,stopalarmmin=0,id="";

	var parmjson = new Array(),markerJson = null;

	$("#marker_vehicle_table_content tr").each(function(){
		id="";
		if($(this).attr("name").length!=0){
			id=$(this).attr("name").split("_")[2];
		}

		tds =$(this).find("td");
		vechileId = $(tds[0]).attr("name");	

		inalarm=$(tds[1]).find("select").val();
		outalarm=$(tds[2]).find("select").val();
		recregion=$(tds[3]).find("select").val();
		stopalarmmin=$(tds[4]).find("input").val();



		if(id.length >0){

			if((inalarm!=-1 && inalarm !=0) || (outalarm!=-1 && outalarm !=0) || (recregion!=-1 && recregion !=0) || stopalarmmin.length!=0){

				parmjson.push({id:id,markId : markerId,vhcId : vechileId,inalarm : inalarm==-1?0:inalarm,outalarm : outalarm==-1?0:outalarm,recregion :recregion==-1?0:recregion,stopalarmmin : stopalarmmin.length==0?0:stopalarmmin,type:2});  	

			}else{

				parmjson.push({id:id,vhcId : vechileId,type:1});   					

			}

		}else{

			if((inalarm!=-1 && inalarm !=0) || (outalarm!=-1 && outalarm !=0) || (recregion!=-1 && recregion !=0) || stopalarmmin.length!=0){

				parmjson.push({markId : markerId,vhcId : vechileId,inalarm : inalarm==-1?0:inalarm,outalarm : outalarm==-1?0:outalarm,recregion :recregion==-1?0:recregion,stopalarmmin : stopalarmmin.length==0?0:stopalarmmin,type:0});  					

			}

		}

	});


	if(parmjson.length == 0){

		$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用

		return;

	}

	//alert(JSON.stringify(parmjson));
	//$("#saveMarkerBtn").removeAttr("disabled");
	//return;
	//$("#markersaveMsg").text(manager.zztj);


	$.ajax({
		type: "POST",
		dataType: "json",
		url: "json/markerAction_addOrUpdateMarkerVehicle.action",
		data: {MarkerVehicleJson:JSON.stringify(parmjson)},
		async : false,
		success: function(json) {

			if(json.flag == true){

				$("#markersaveMsg").text(electronicFenceLanguage.bdcg);

				$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用

				showVechiletoMarkerbangdingTable(markerId);

			}else{

				$("#markersaveMsg").text(json.msg);



				$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用

			}
		},
		error: function() {}
	});	

}

function  addImportMarker(json){

	var markerData = json.data[0];

	var marker=markerObject.addMarker(markerData.id,markerData.lng2,markerData.lat2,markerData.icon);

	markerObject.markerArr[markerData.id]={};
	markerObject.markerArr[markerData.id].marker=marker;
	marker.setMap(map);
	markerObject.markerArr[markerData.id].competence=markerData.competence;		
	markerObject.markerArr[markerData.id].title=markerData.title;
	markerObject.markerArr[markerData.id].text=markerData.text;
	markerObject.markerArr[markerData.id].icon=markerData.icon;
	markerObject.markerArr[markerData.id].lng=markerData.lat2;
	markerObject.markerArr[markerData.id].lat=markerData.lng2;
	markerObject.markerArr[markerData.id].blng=markerData.blat;
	markerObject.markerArr[markerData.id].blat=markerData.blng;
	markerObject.markerArr[markerData.id].groupid=markerData.groupid;
	markerObject.markerArr[markerData.id].id=markerData.id;
	markerObject.markerArr[markerData.id].customerNum=markerData.markcode;

	markerObject.markerArr[markerData.id].isShow=true;


	markerObject.markerArr[markerData.id].areaRadius=markersize;

	markerObject.addMarkerListener(markerObject.markerArr[markerData.id]);	


	if(markerData.userMarkerArea!=null&&markerData.userMarkerArea.leftLat!=0 &&markerData.userMarkerArea.leftLon!=0 &&markerData.userMarkerArea.rightLat!=0 &&markerData.userMarkerArea.rightLon!=0 &&markerData.userMarkerArea.markerRadius!=0){
		if(markerData.userMarkerArea.g_leftLat!=0 &&markerData.userMarkerArea.g_leftLon!=0 &&markerData.userMarkerArea.g_rightLat!=0 &&markerData.userMarkerArea.g_rightLon!=0 &&markerData.userMarkerArea.markerRadius!=0){
			markerObject.markerArr[markerData.id].area=drawMarkerArea(new google.maps.LatLng(markerData.userMarkerArea.g_leftLat,markerData.userMarkerArea.g_leftLon),new google.maps.LatLng(markerData.userMarkerArea.g_rightLat,markerData.userMarkerArea.g_rightLon));
		}else{
			markerObject.markerArr[markerData.id].area=drawMarkerArea(new google.maps.LatLng(markerData.userMarkerArea.leftLat,markerData.userMarkerArea.leftLon),new google.maps.LatLng(markerData.userMarkerArea.rightLat,markerData.userMarkerArea.rightLon));

		}
		markerObject.markerArr[markerData.id].area.setMap(null);
		markerObject.markerArr[markerData.id].areaRadius=markerData.userMarkerArea.markerRadius;
	} 	 

	markerRefreshObject.addMarkerGroup(markerData.groupid);//若标注树上没有标注组自动添加标注组

	addMarkerGroupTreeNode(markerData.id,markerData.groupid,markerData.title);

	$("#markerId").attr("value",markerData.id);

	clearAreaLagLng();
	markerObject.markerJson.data.push(markerData);
	markerObject.markerJson.totalcount = markerObject.markerJson.data.length;

	if($("#bzShowNamekbox").attr("checked")){

		markerObject.markertitlearr.push(new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+markerData.title+"</div>",marker.getPosition()));

	}

	if(mapType==1){
		baidMap.removeOverlay(oldPolygon);
		showMarkerBaidu(json);
		updateMarkerIsShow(markerData.id,true,false);
		showMarkersBaidu(markerData.id,false);
	}

	var curnode=treeObj.getNodeByParam("id",markerData.id);

	if(curnode != null){
		treeObj.checkNode(curnode, true, false, false);
	}

	if(selectImage!=null){
		selectImage.attr("class","unselected");
		selectImage=$("#selectImage");//用于保存当前选中的标记图标
		selectImage.attr("class","selected");
	}	 
}