var xyMap;
var xyMarkers;
var labels =[];

function loadXyMap(){

	$("#map_canvas").empty();

	if(document.readyState=="complete"){
		if(xyMap!=null)xyMap.destroy();
			xyMap = new IMAP.Map("map_canvas",{
				minZoom:4,//最小地图级别
				maxZoom:18,//最大地图级别
				zoom:12//初始化级别
			});
		xyMap.addControl(new IMAP.NavigationControl({visible:true}));//加导航条
		xyMap.addControl(new IMAP.ScaleControl({visible:true}));//加比例尺
	}else{
		setTimeout('loadXyMap()',500);
		return;
	}
	loadXYPoint();
	closeMask();
}

//在地图上面打点
function loadXYPoint(){
	xyMarkers = [];
	//num_s =10;
	if(num_s == 10 ){
		num_s = getRefreshTime();
		countDown();//每隔15秒执行函数al
	}
	for(i=0;i<carList.data.length;i++){
		var lnglat=new IMAP.LngLat(carList.data[i].positionLast.lng,carList.data[i].positionLast.lat);

		var s=10;
		var condition=carList.data[i].positionLast.state2;
		var sp = parseInt(carList.data[i].positionLast.speed);
		if (condition != null){
			if (condition.indexOf("不在线")>=0 || condition.indexOf("掉线")>=0)
				s = 2;
			else {
				if (condition.indexOf("速报警")>=0)
					s = 4;
				else if (condition.indexOf("报警")>=0)
					s = 3;
				else if (sp > 0.5)
					s = 0;
				else
					s = 1;
			}
			if (s != 4 && s != 3 && condition.indexOf("停车")>=0
					&& !condition.indexOf("不在线")>= 0)
			{
				if(condition.indexOf("停车超时")>=0){
					s = 5;
				}else{
					s = 6;
				}
			}
		}else{
			if (sp > 0.5)
				s = 0;
			else
				s = 1;
		}
		if( carList.data[i].positionLast.av == 0){
			s=7;
		}
		var newtime = new Date().getTime();
		var ttime = carList.data[i].positionLast.recvtime.replace("-","/");
		ttime = ttime.replace("-","/");
		ttime = ttime.replace("T"," ");
		var oldtime = new Date(ttime).getTime();
		if(newtime-oldtime > 600000){
			s=2;
		}

		var state =s;
		var pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/red_0.gif";
		if(state == 0) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/green_";
		else if(state == 1) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/red_";
		else if(state == 2) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/gray_";
		else if(state == 3) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/yellow_";
		else if(state == 4) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/pink_";
		else if(state == 5) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/stopalarm";
		else if(state == 7) pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/blue_";
		else pngicon = "gpsonline/image/pic/"+carList.data[i].icon+"/red_";
		var direction="";
		var t = parseInt(carList.data[i].positionLast.direct);
		if(t>27 && t<=72){
			if(state == 5){
				var image=".gif";
			}else{
				var image="45.gif";
			}
			direction="东北";
		}else if(t>72 && t<=117){
			if(state == 5){
				var image=".gif";
			}else{
				var image="90.gif";
			}

			direction="东";
		}
		else if(t>117 && t<=162){
			if(state == 5){
				var image=".gif";
			}else{
				var image="135.gif";
			}
			direction="东南";
		}
		else if(t>162 && t<=207){
			if(state == 5){
				var image=".gif";
			}else{
				var image="180.gif";
			}
			direction="南";
		}
		else if(t>207 && t<=252){
			if(state == 5){
				var image=".gif";
			}else{
				var image="225.gif";
			}
			direction="西南";
		}
		else if(t>252 && t<=297){
			if(state == 5){
				var image=".gif";
			}else{
				var image="270.gif";
			}
			direction="西";
		}
		else if(t>297 && t<=342){
			if(state == 5){
				var image=".gif";
			}else{
				var image="315.gif";
			}
			direction="西北";
		}
		else {
			if(state == 5){
				var image=".gif";
			}else{
				var image="0.gif";
			}
			direction="北";
		}
		var carname = encodeURI(encodeURI(carList.data[i].vhcCode));

		var temp,temp1,temp2,temp3,temp4;
		if(carList.data[i].positionLast.temperature != null && carList.data[i].positionLast.temperature <=127){
			temp=carList.data[i].positionLast.temperature +" ℃";
		}else{
			temp="无效";
		}
		if(carList.data[i].positionLast.temp1 != null && carList.data[i].positionLast.temp1 <=127){
			temp1=carList.data[i].positionLast.temp1 +" ℃";
		}else{
			temp1="无效";
		}
		if(carList.data[i].positionLast.temp2 != null && carList.data[i].positionLast.temp2 <=127){
			temp2=carList.data[i].positionLast.temp2 +" ℃";
		}else{
			temp2="无效";
		}
		if(carList.data[i].positionLast.temp3 != null && carList.data[i].positionLast.temp3 <=127){
			temp3=carList.data[i].positionLast.temp3 +" ℃";
		}else{
			temp3="无效";
		}
		if(carList.data[i].positionLast.temp4 != null && carList.data[i].positionLast.temp4 <=127){
			temp4=carList.data[i].positionLast.temp4 +" ℃";
		}else{
			temp4="无效";
		}
		var WinShowParms = getCurUserWinShowParms();
		var Nhtml =	"<a  href='javascript:void(0);' onclick='closexyInfoWindow("+carList.data[i].id+");' style='display:block;width:15px;height:15px;font-size:24px;color:#8c8b8b;position:absolute;top:10px;right:10px;text-align:center;line-height: 15px;'>×</a><a href='javascript:void(0);' class='map_setting_ico' onclick='setSystemObject.openWin(1);'style='right:25px;'><span></span></a>" +
		"<div id='app_"+carList.data[i].id+"' style='font-weight:normal;'>"
		for ( var ws = 0; ws < WinShowParms.length; ws++){
			if(WinShowParms[ws]==1){
				Nhtml+="<div id='app1_"+carList.data[i].id+"'><b>设备名称：</b>"+carList.data[i].vhcCode+"</br></div>"
			}
			if(WinShowParms[ws]==2){
				Nhtml+="<div id='app2_"+carList.data[i].id+"'><b>服务器时间：</b>"+carList.data[i].positionLast.recvtime+"</br></div>"
			}
			if(WinShowParms[ws]==3){
				Nhtml+="<div id='app3_"+carList.data[i].id+"'><b>速度：</b>"+carList.data[i].positionLast.speed.toFixed(1)+"km/h </br></div>"
			}
			if(WinShowParms[ws]==4){
				Nhtml+="<div id='app4_"+carList.data[i].id+"'><b>方向：</b>"+direction+"</br></div>"
			}
			if(WinShowParms[ws]==5){
				Nhtml+="<div id='app5_"+carList.data[i].id+"'><b>温度：</b>"+temp+" | <b>温度1：</b>"+temp1+" | <b>温度2：</b>"+temp2+" | <b>温度3：</b>"+temp3+" | <b>温度4：</b>"+temp4+"</br></div>"
			}
			if(WinShowParms[ws]==6){
				Nhtml+="<div id='app6_"+carList.data[i].id+"'><b>油量：</b>"+carList.data[i].positionLast.oilMN1+" L</br></div>"
			}
			if(WinShowParms[ws]==7){
				Nhtml+="<div id='app7_"+carList.data[i].id+"'><b>当日里程：</b>"+carList.data[i].positionLast.distance+" km</br></div>"
			}
			if(WinShowParms[ws]==8){
				Nhtml+="<div id='app8_"+carList.data[i].id+"'><b>总里程：</b>"+carList.data[i].positionLast.totalDistance+" km</br></div>"
			}
			if(WinShowParms[ws]==9){
				Nhtml+="<div id='app9_"+carList.data[i].id+"'><b>状态：</b>"+carList.data[i].positionLast.state2+"</br></div>"
			}
			if(WinShowParms[ws]==10){
				Nhtml+="<div id='app10_"+carList.data[i].id+"'><b>位置：</b>"+carList.data[i].positionLast.memo+"</br></div>"
			}
			if(WinShowParms[ws]==11 && eqVisualPower.sim){
				Nhtml+="<div id='app11_"+carList.data[i].id+"'><b>SIM卡号：</b>"+carList.data[i].simCode+"</br></div>"
			}
			if(WinShowParms[ws]==12){
				Nhtml+="<div id='app12_"+carList.data[i].id+"'><b>GPS时间：</b>"+carList.data[i].positionLast.gpstime+"</br></div>"
			}
			if(WinShowParms[ws]==13){
				Nhtml+="<div id='app13_"+carList.data[i].id+"'><b>OBD/CAN数据：</b><a href='javascript:opobd("+carList.data[i].id+");'><font color='#0000FF'>详细</font></a></br></div>"
			}
			if(WinShowParms[ws]==14 && eqVisualPower.remark){
				Nhtml+="<div id='app14_"+carList.data[i].id+"'><b>备注：</b>"+carList.data[i].remark+"</br></div>"
			}
			if(WinShowParms[ws]==15){
				Nhtml+="<div id='app15_"+carList.data[i].id+"'><b>经纬度：</b>"+carList.data[i].positionLast.lng+","+carList.data[i].positionLast.lat+"</br></div>"
			}
			if(WinShowParms[ws]==16){
				Nhtml+="<div id='app16_"+carList.data[i].id+"'><b>到期时间：</b>"+(carList.data[i].overduetime != null && carList.data[i].overduetime.indexOf("19") != 0 ? carList.data[i].overduetime:"")+"</br></div>"
			}
			if(WinShowParms[ws]==17){
				Nhtml+="<div id='app17_"+carList.data[i].id+"'><b>启用时间：</b>"+(carList.data[i].posavtime != null && carList.data[i].posavtime.indexOf("19") != 0 ? carList.data[i].posavtime :"")+"</br></div>"
			}
			if(WinShowParms[ws]==18 && eqVisualPower.gprs){
				Nhtml+="<div id='app18_"+carList.data[i].id+"'><b>设备ID：</b>"+carList.data[i].gprsCode+"</br></div>"
			}
			if(WinShowParms[ws]==19){
				Nhtml+="<div id='app19_"+carList.data[i].id+"'><b>备注2：</b>"+carList.data[i].remark2+"</br></div>"
			}
		}
		//Nhtml+="<a href='javascript:streeViewObject.open("+carList.data[i].id+","+carList.data[i].positionLast.blat+","+carList.data[i].positionLast.blng+","+t+","+3+");'><font color='#0000FF'>街景</font> | </a><a href='gpsonline/jsp/TrackMap.jsp?carid="+carList.data[i].id+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+carList.data[i].id+"&carname="+carname+"&icon="+carList.data[i].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font> | </a> <a href='javascript:;' ><font color='#0000FF' onclick=\"openDriverInfo("+carList.data[i].id+");\" >驾驶员</font> | </a> <a href='javascript:;' ><font color='#0000FF' onclick=\"updateWeizhi("+carList.data[i].id+");\" >刷新位置</font> | </a><a id='sim_"+carList.data[i].simCode+"' href='javascript:;' ><font color='#0000FF' onclick=\"openSim("+carList.data[i].simCode+");\">SIM </font> | </a> <a id='more_"+carList.data[i].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";

		Nhtml+="<a href='javascript:streeViewObject.open("+carList.data[i].id+","+carList.data[i].positionLast.blat+","+carList.data[i].positionLast.blng+","+t+","+3+");'><font color='#0000FF'>街景</font> | </a><a href='gpsonline/jsp/TrackMap.jsp?carid="+carList.data[i].id+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a>";
		if(eqVisualPower.play)Nhtml+="<a id='play_"+carList.data[i].id+"' href='gpsonline/jsp/monitor/playBack.jsp?carid="+carList.data[i].id+"&carname="+carname+"&icon="+carList.data[i].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font> | </a>";
		Nhtml+="<a href='javascript:;' ><font color='#0000FF' onclick=\"openDriverInfo("+carList.data[i].id+");\" >驾驶员</font> | </a> <a href='javascript:;' ><font color='#0000FF' onclick=\"updateWeizhi("+carList.data[i].id+");\" >刷新位置</font> | </a>";
		if(eqVisualPower.sim)Nhtml+="<a id='sim_"+carList.data[i].id+"' href='javascript:;' ><font color='#0000FF' onclick=\"openSim("+carList.data[i].simCode+");\">SIM </font> | </a>";
		Nhtml+="<a id='more_"+carList.data[i].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";

		var icon_size = real(carList.data[i].icon);
		var opts=new IMAP.MarkerOptions();
		opts.anchor = IMAP.Constants.BOTTOM_CENTER;
		opts.icon=new IMAP.Icon(pngicon+image,{"size":new IMAP.Size(35, 30),"offset":new IMAP.Pixel(5, 0)});
		var marker=new IMAP.Marker(lnglat,opts);
		marker.id = carList.data[i].id;
		xyMap.getOverlayLayer().addOverlay(marker,true);

		var label=new IMAP.Label(carList.data[i].vhcCode,{"position":lnglat,"anchor":IMAP.Constants.LEFT_BOTTOM});
		labels.push(label);
		if($('#isShowCarName').is(':checked')){
			xyMap.getOverlayLayer().addOverlay(label);
		}
		marker.addEventListener(IMAP.Constants.CLICK, function(event){
			for(var k = 0;k <xyMarkers.length;k++){
				if(event.target.id == xyMarkers[k].id){
					xyMarkers[k].marker.openInfoWindow(xyMarkers[k].info,{position:lnglat,autoPan:true,type:IMAP.Constants.OVERLAY_INFOWINDOW_CUSTOM,offset:new IMAP.Pixel(-10,-40)});
				}
			}
		},marker);

		var markerManger = new Object();
		markerManger.id = carList.data[i].id;
		markerManger.vhcCode = carList.data[i].vhcCode;
		markerManger.marker = marker;
		markerManger.gprs = carList.data[i].gprsCode;
		markerManger.label = label;
		markerManger.remark = carList.data[i].remark;
		markerManger.remark2 = carList.data[i].remark2;
		markerManger.icon = carList.data[i].icon;
		markerManger.simCode = carList.data[i].simCode;
		markerManger.info = Nhtml;
		markerManger.lnglat = lnglat;
		xyMarkers.push(markerManger);
	}
}
function centerXiuYouMap(data){
	var boo = false;//用来定义是否地图打过点
	var myLnglat = new IMAP.LngLat(data.data[0].positionLast.lng,data.data[0].positionLast.lat);
	var s=10;
	var condition=data.data[0].positionLast.state2;
	var sp = parseInt(data.data[0].positionLast.speed);
	if(condition != null){
		if (condition.indexOf("不在线")>=0 || condition.indexOf("掉线")>=0)
			s = 2;
		else{
			if (condition.indexOf("速报警")>=0)
				s = 4;
			else if (condition.indexOf("报警")>=0)
				s = 3;
			else if (sp > 0.5)
				s = 0;
			else
				s = 1;
		}
		if (s != 4 && s != 3 && condition.indexOf("停车")>=0
				&& !condition.indexOf("不在线")>= 0)
		{
			if(condition.indexOf("停车超时")>=0){
				s = 5;	
			}else{
				s = 6;
			}
		}
	}else{
		if (sp > 0.5)
			s = 0;
		else
			s = 1;
	}
	if( data.data[0].positionLast.av == 0 ){
		s=7;
	}
	var newtime = new Date().getTime();
	var ttime = data.data[0].positionLast.recvtime.replace("-","/");
	ttime = ttime.replace("-","/");
	ttime = ttime.replace("T"," ");
	var oldtime = new Date(ttime).getTime();
	if(newtime-oldtime > 600000){
		s=2;
	}

	var state =s;
	var pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/red_0.gif";
	if(state == 0) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/green_";
	else if(state == 1) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/red_";
	else if(state == 2) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/gray_";
	else if(state == 3) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/yellow_";
	else if(state == 4) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/pink_";
	else if(state == 5) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/stopalarm";
	else if(state == 7) pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/blue_";
	else pngicon = "gpsonline/image/pic/"+data.data[0].icon+"/red_";
	var direction="";
	var t = parseInt(data.data[0].positionLast.direct);
	if(t>27 && t<=72){
		if(state == 5){
			var image=".gif";
		}else{
			var image="45.gif";
		}
		direction="东北";
	}else if(t>72 && t<=117){
		if(state == 5){
			var image=".gif";
		}else{
			var image="90.gif";
		}

		direction="东";
	}
	else if(t>117 && t<=162){
		if(state == 5){
			var image=".gif";
		}else{
			var image="135.gif";
		}
		direction="东南";
	}
	else if(t>162 && t<=207){
		if(state == 5){
			var image=".gif";
		}else{
			var image="180.gif";
		}
		direction="南";
	}
	else if(t>207 && t<=252){
		if(state == 5){
			var image=".gif";
		}else{
			var image="225.gif";
		}
		direction="西南";
	}
	else if(t>252 && t<=297){
		if(state == 5){
			var image=".gif";
		}else{
			var image="270.gif";
		}
		direction="西";
	}
	else if(t>297 && t<=342){
		if(state == 5){
			var image=".gif";
		}else{
			var image="315.gif";
		}
		direction="西北";
	}
	else {
		if(state == 5){
			var image=".gif";
		}else{
			var image="0.gif";
		}
		direction="北";
	}

	var carname = encodeURI(encodeURI(data.data[0].vhcCode)); 

	var temp,temp1,temp2,temp3,temp4;
	if(data.data[0].positionLast.temperature != null && data.data[0].positionLast.temperature <=127){
		temp=data.data[0].positionLast.temperature +" ℃";
	}else{
		temp="无效";
	}
	if(data.data[0].positionLast.temp1 != null && data.data[0].positionLast.temp1 <=127){
		temp1=data.data[0].positionLast.temp1 +" ℃";
	}else{
		temp1="无效";
	}
	if(data.data[0].positionLast.temp2 != null && data.data[0].positionLast.temp2 <=127){
		temp2=data.data[0].positionLast.temp2 +" ℃";
	}else{
		temp2="无效";
	}
	if(data.data[0].positionLast.temp3 != null && data.data[0].positionLast.temp3 <=127){
		temp3=data.data[0].positionLast.temp3 +" ℃";
	}else{
		temp3="无效";
	}
	if(data.data[0].positionLast.temp4 != null && data.data[0].positionLast.temp4 <=127){
		temp4=data.data[0].positionLast.temp4 +" ℃";
	}else{
		temp4="无效";
	}
	var icon_size=real(data.data[0].icon);
	//自定义图标
	var cyIcon= new IMAP.Icon(pngicon+image,{"size":new IMAP.Size(35, 30),"offset":new IMAP.Pixel(5, 0)});
	var WinShowParms = getCurUserWinShowParms();
	var Nhtml =	"<a  href='javascript:void(0);' onclick='closexyInfoWindow("+data.data[0].id+");' style='display:block;width:15px;height:15px;font-size:24px;color:#8c8b8b;position:absolute;top:10px;right:10px;text-align:center;line-height: 15px;'>×</a><a href='javascript:void(0);' class='map_setting_ico' onclick='setSystemObject.openWin(1);'style='right:36px;top:10px'><span></span></a><div id='app_"+data.data[0].id+"' style='font-weight:normal;'>"
	for ( var ws = 0; ws < WinShowParms.length; ws++){
		if(WinShowParms[ws]==1){
			Nhtml+="<div id='app1_"+data.data[0].id+"'><b>设备名称：</b>"+data.data[0].vhcCode+"</br></div>"
		}
		if(WinShowParms[ws]==2){
			Nhtml+="<div id='app2_"+data.data[0].id+"'><b>服务器时间：</b>"+data.data[0].positionLast.recvtime+"</br></div>"
		}
		if(WinShowParms[ws]==3){
			Nhtml+="<div id='app3_"+data.data[0].id+"'><b>速度：</b>"+data.data[0].positionLast.speed.toFixed(1)+"km/h </br></div>"
		}
		if(WinShowParms[ws]==4){
			Nhtml+="<div id='app4_"+data.data[0].id+"'><b>方向：</b>"+direction+"</br></div>"
		}
		if(WinShowParms[ws]==5){
			Nhtml+="<div id='app5_"+data.data[0].id+"'><b>温度：</b>"+temp+" | <b>温度1：</b>"+temp1+" | <b>温度2：</b>"+temp2+" | <b>温度3：</b>"+temp3+" | <b>温度4：</b>"+temp4+"</br></div>"
		}
		if(WinShowParms[ws]==6){
			Nhtml+="<div id='app6_"+data.data[0].id+"'><b>油量：</b>"+data.data[0].positionLast.oilMN1+" L</br></div>"
		}
		if(WinShowParms[ws]==7){
			Nhtml+="<div id='app7_"+data.data[0].id+"'><b>当日里程：</b>"+data.data[0].positionLast.distance+" km</br></div>"
		}
		if(WinShowParms[ws]==8){
			Nhtml+="<div id='app8_"+data.data[0].id+"'><b>总里程：</b>"+data.data[0].positionLast.totalDistance+" km</br></div>"
		}
		if(WinShowParms[ws]==9){
			Nhtml+="<div id='app9_"+data.data[0].id+"'><b>状态：</b>"+data.data[0].positionLast.state2+"</br></div>"
		}
		if(WinShowParms[ws]==10){
			Nhtml+="<div id='app10_"+data.data[0].id+"'><b>位置：</b>"+data.data[0].positionLast.memo+"</br></div>"
		}
		if(WinShowParms[ws]==11 && eqVisualPower.sim){
			Nhtml+="<div id='app11_"+data.data[0].id+"'><b>SIM卡号：</b>"+data.data[0].simCode+"</br></div>"
		}
		if(WinShowParms[ws]==12){
			Nhtml+="<div id='app12_"+data.data[0].id+"'><b>GPS时间：</b>"+data.data[0].positionLast.gpstime+"</br></div>"
		}
		if(WinShowParms[ws]==13){
			Nhtml+="<div id='app13_"+data.data[0].id+"'><b>OBD/CAN数据：</b><a href='javascript:opobd("+data.data[0].id+");'><font color='#0000FF'>详细</font></a></br></div>"
		}
		if(WinShowParms[ws]==14 && eqVisualPower.remark){
			Nhtml+="<div id='app14_"+data.data[0].id+"'><b>备注：</b>"+data.data[0].remark+"</br></div>"
		}
		if(WinShowParms[ws]==15){
			Nhtml+="<div id='app15_"+data.data[0].id+"'><b>经纬度：</b>"+data.data[0].positionLast.lng+","+data.data[0].positionLast.lat+"</br></div>"
		}
		if(WinShowParms[ws]==16){
			Nhtml+="<div id='app16_"+data.data[0].id+"'><b>到期时间：</b>"+(data.data[0].overduetime != null && data.data[0].overduetime.indexOf("19") != 0 ? data.data[0].overduetime:"")+"</br></div>"
		}
		if(WinShowParms[ws]==17){
			Nhtml+="<div id='app17_"+data.data[0].id+"'><b>启用时间：</b>"+(data.data[0].posavtime != null && data.data[0].posavtime.indexOf("19") != 0 ? data.data[0].posavtime :"")+"</br></div>"
		}
		if(WinShowParms[ws]==18 && eqVisualPower.gprs){
			Nhtml+="<div id='app18_"+data.data[0].id+"'><b>设备ID：</b>"+data.data[0].gprsCode+"</br></div>"
		}
		if(WinShowParms[ws]==19){
			Nhtml+="<div id='app19_"+data.data[0].id+"'><b>备注2：</b>"+data.data[0].remark2+"</br></div>"
		}
	}
	Nhtml+="<a href='javascript:streeViewObject.open("+data.data[0].id+","+data.data[0].positionLast.blat+","+data.data[0].positionLast.blng+","+t+","+3+");'><font color='#0000FF'>街景</font> | </a><a href='gpsonline/jsp/TrackMap.jsp?carid="+data.data[0].id+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a>";
	if(eqVisualPower.play)Nhtml+="<a id='play_"+data.data[0].id+"' href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[0].id+"&carname="+carname+"&icon="+data.data[0].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font> | </a>";
	Nhtml+="<a href='javascript:;' ><font color='#0000FF' onclick=\"openDriverInfo("+data.data[0].id+");\" >驾驶员</font> | </a> <a href='javascript:;' ><font color='#0000FF' onclick=\"updateWeizhi("+data.data[0].id+");\" >刷新位置</font> | </a>";
	if(eqVisualPower.sim)Nhtml+="<a id='sim_"+data.data[0].id+"' href='javascript:;' ><font color='#0000FF' onclick=\"openSim("+data.data[0].simCode+");\">SIM </font> | </a>";
	Nhtml+="<a id='more_"+data.data[0].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";

	for (var k = 0;k < xyMarkers.length;k++){
		if(data.data[0].id == xyMarkers[k].id){
			boo = true;
			xyMarkers[k].label.setContent(data.data[0].vhcCode +"("+data.data[0].positionLast.speed.toFixed(1)+"km/h)");
			if( namekg == false){
				xyMarkers[k].marker.setLabel(xyMarkers[k].label);
			}else{
				xyMarkers[k].marker.setLabel(null);
			}
			xyMarkers[k].marker.setIcon(cyIcon);
			xyMarkers[k].marker.setPosition(myLnglat);
			boo = true;
			xyMarkers[k].info = Nhtml;
			//xyMarkers[k].infoWindow.setPosition(myLnglat);
			xyMarkers[k].marker.openInfoWindow(xyMarkers[k].info,{position:myLnglat,autoPan:true,type:IMAP.Constants.OVERLAY_INFOWINDOW_CUSTOM,offset:new IMAP.Pixel(-10,-40)});

		}
	}
	if(!boo){
		var opts=new IMAP.MarkerOptions();
		//opts.icon=new IMAP.Icon(pngicon+image,{"size":new IMAP.Size(icon_size,icon_size),"offset":new IMAP.Pixel(-15,-15)});
		opts.anchor = IMAP.Constants.BOTTOM_CENTER;
		opts.icon=new IMAP.Icon(pngicon+image,{"size":new IMAP.Size(35, 30),"offset":new IMAP.Pixel(5, 0)});
		var marker=new IMAP.Marker(myLnglat,opts);
		marker.id = data.data[0].id;
		xyMap.getOverlayLayer().addOverlay(marker,true);

		var label=new IMAP.Label(data.data[0].vhcCode,{"position":myLnglat,"anchor":IMAP.Constants.LEFT_BOTTOM});
		labels.push(label);
		if($('#isShowCarName').is(':checked')){
			xyMap.getOverlayLayer().addOverlay(label);
		}
		marker.openInfoWindow(Nhtml,{position:myLnglat,autoPan:true,type:IMAP.Constants.OVERLAY_INFOWINDOW_CUSTOM,offset:new IMAP.Pixel(-10,-40)});
		var markerManger = new Object();
		markerManger.id = carList.data[i].id;
		markerManger.vhcCode = carList.data[i].vhcCode;
		markerManger.marker = marker;
		markerManger.gprs = carList.data[i].gprsCode;
		markerManger.label = label;
		markerManger.remark = carList.data[i].remark;
		markerManger.remark2 = carList.data[i].remark2;
		markerManger.icon = carList.data[i].icon;
		markerManger.simCode = carList.data[i].simCode;
		markerManger.info = Nhtml;
		markerManger.lnglat = myLnglat;
		xyMarkers.push(markerManger);
		marker.addEventListener(IMAP.Constants.CLICK, function(event){
			for(var k = 0;k <xyMarkers.length;k++){
				if(event.target.id == xyMarkers[k].id){
					xyMarkers[k].marker.openInfoWindow(xyMarkers[k].info,{position:myLnglat,autoPan:true,type:IMAP.Constants.OVERLAY_INFOWINDOW_CUSTOM,offset:new IMAP.Pixel(-10,-40)});
				}
			}
		},marker);
	}
	xyMap.setZoom(14);
	xyMap.setCenter(myLnglat);
}

function updateXiuYouMap(){
//	console.info("----------------++++++++++++++"+JSON.stringify(newdata));
	for(var i=0;i<newdata.data.length;i++){
		for(var k=0;k<xyMarkers.length;k++){
			if(newdata.data[i].vehicleId == xyMarkers[k].id){

				var myLnglat = new IMAP.LngLat(newdata.data[i].lng,newdata.data[i].lat);
				var s = 10;
				var condition = newdata.data[i].state2;
				var sp = parseInt(newdata.data[i].speed);
				if(condition != null){
					if (condition.indexOf("不在线")>=0 || condition.indexOf("掉线")>=0)
						s = 2;
					else{
						if (condition.indexOf("速报警")>=0)
							s = 4;
						else if (condition.indexOf("报警")>=0)
							s = 3;
						else if (sp > 0.5)
							s = 0;
						else
							s = 1;
					}
					if (s != 4 && s != 3 && condition.indexOf("停车")>=0
							&& !condition.indexOf("不在线")>= 0)
					{
						if(condition.indexOf("停车超时")>=0){
							s = 5;	
						}else{
							s = 6;
						}
					}
				}else{
					if (sp > 0.5)
						s = 0;
					else
						s = 1;
				}
				if(newdata.data[i].av == 0 ){
					s=7;
				}
				var newtime = new Date().getTime();
				var ttime = newdata.data[i].recvtime.replace("-","/");
				ttime = ttime.replace("-","/");
				ttime = ttime.replace("T"," ");
				var oldtime = new Date(ttime).getTime();
				if(newtime-oldtime > 600000){
					s=2;
				}

				var state =s;
				var pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/red_0.gif";
				if(state == 0) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/green_";
				else if(state == 1) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/red_";
				else if(state == 2) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/gray_";
				else if(state == 3) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/yellow_";
				else if(state == 4) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/pink_";
				else if(state == 5) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/stopalarm";
				else if(state == 7) pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/blue_";
				else pngicon = "gpsonline/image/pic/"+xyMarkers[k].icon+"/red_";
				var direction="";
				var t = parseInt(newdata.data[i].direct);
				if(t>27 && t<=72){
					if(state == 5){
						var image=".gif";
					}else{
						var image="45.gif";
					}
					direction="东北";
				}else if(t>72 && t<=117){
					if(state == 5){
						var image=".gif";
					}else{
						var image="90.gif";
					}

					direction="东";
				}
				else if(t>117 && t<=162){
					if(state == 5){
						var image=".gif";
					}else{
						var image="135.gif";
					}
					direction="东南";
				}
				else if(t>162 && t<=207){
					if(state == 5){
						var image=".gif";
					}else{
						var image="180.gif";
					}
					direction="南";
				}
				else if(t>207 && t<=252){
					if(state == 5){
						var image=".gif";
					}else{
						var image="225.gif";
					}
					direction="西南";
				}
				else if(t>252 && t<=297){
					if(state == 5){
						var image=".gif";
					}else{
						var image="270.gif";
					}
					direction="西";
				}
				else if(t>297 && t<=342){
					if(state == 5){
						var image=".gif";
					}else{
						var image="315.gif";
					}
					direction="西北";
				}
				else {
					if(state == 5){
						var image=".gif";
					}else{
						var image="0.gif";
					}
					direction="北";
				}

				var carname = encodeURI(encodeURI(newdata.data[i].vhcCode)); 

				var temp,temp1,temp2,temp3,temp4;
				if(newdata.data[i].temperature != null && newdata.data[i].temperature <=127){
					temp=newdata.data[i].temperature +" ℃";
				}else{
					temp="无效";
				}
				if(newdata.data[i].temp1 != null && newdata.data[i].temp1 <=127){
					temp1=newdata.data[i].temp1 +" ℃";
				}else{
					temp1="无效";
				}
				if(newdata.data[i].temp2 != null && newdata.data[i].temp2 <=127){
					temp2=newdata.data[i].temp2 +" ℃";
				}else{
					temp2="无效";
				}
				if(newdata.data[i].temp3 != null && newdata.data[i].temp3 <=127){
					temp3=newdata.data[i].temp3 +" ℃";
				}else{
					temp3="无效";
				}
				if(newdata.data[i].temp4 != null && newdata.data[i].temp4 <=127){
					temp4=newdata.data[i].temp4 +" ℃";
				}else{
					temp4="无效";
				}
				var icon_size=real(xyMarkers[k].icon);
				var cyIcon= new IMAP.Icon(pngicon+image,{"size":new IMAP.Size(35, 30),"offset":new IMAP.Pixel(5, 0)});
				xyMarkers[k].label.setContent(xyMarkers[k].vhcCode +"("+newdata.data[i].speed.toFixed(1)+"km/h)");
				xyMarkers[k].label.setPosition(myLnglat);
				if( namekg == false){
					xyMap.getOverlayLayer().addOverlay(xyMarkers[k].label);
				}else{
					xyMap.getOverlayLayer().removeOverlay(xyMarkers[k].label);
				}
				xyMarkers[k].marker.setIcon(cyIcon);
				xyMarkers[k].marker.moveTo(myLnglat,120);
				xyMarkers[k].marker.setPosition(myLnglat);
				xyMarkers[k].myLnglat = myLnglat;
				var WinShowParms = getCurUserWinShowParms();
				var Nhtml =	"<a  href='javascript:void(0);' onclick='closexyInfoWindow("+newdata.data[i].vehicleId+");' style='display:block;width:15px;height:15px;font-size:24px;color:#8c8b8b;position:absolute;top:10px;right:10px;text-align:center;line-height: 15px;'>×</a><a href='javascript:void(0);' class='map_setting_ico' onclick='setSystemObject.openWin(1);'style='right:36px;top:10px'><span></span></a><div id='app_"+newdata.data[i].vehicleId+"' style='font-weight:normal;'>"
				for ( var ws = 0; ws < WinShowParms.length; ws++){
					if(WinShowParms[ws]==1){
						Nhtml+="<div id='app1_"+newdata.data[i].vehicleId+"'><b>设备名称：</b>"+xyMarkers[k].vhcCode+"</br></div>"
					}
					if(WinShowParms[ws]==2){
						Nhtml+="<div id='app2_"+newdata.data[i].vehicleId+"'><b>服务器时间：</b>"+newdata.data[i].recvtime+"</br></div>"
					}
					if(WinShowParms[ws]==3){
						Nhtml+="<div id='app3_"+newdata.data[i].vehicleId+"'><b>速度：</b>"+newdata.data[i].speed.toFixed(1)+"km/h </br></div>"
					}
					if(WinShowParms[ws]==4){
						Nhtml+="<div id='app4_"+newdata.data[i].vehicleId+"'><b>方向：</b>"+direction+"</br></div>"
					}
					if(WinShowParms[ws]==5){
						Nhtml+="<div id='app5_"+newdata.data[i].vehicleId+"'><b>温度：</b>"+temp+" | <b>温度1：</b>"+temp1+" | <b>温度2：</b>"+temp2+" | <b>温度3：</b>"+temp3+" | <b>温度4：</b>"+temp4+"</br></div>"
					}
					if(WinShowParms[ws]==6){
						Nhtml+="<div id='app6_"+newdata.data[i].vehicleId+"'><b>油量：</b>"+newdata.data[i].oilMN1+" L</br></div>"
					}
					if(WinShowParms[ws]==7){
						Nhtml+="<div id='app7_"+newdata.data[i].vehicleId+"'><b>当日里程：</b>"+newdata.data[i].distance+" km</br></div>"
					}
					if(WinShowParms[ws]==8){
						Nhtml+="<div id='app8_"+newdata.data[i].vehicleId+"'><b>总里程：</b>"+newdata.data[i].totalDistance+" km</br></div>"
					}
					if(WinShowParms[ws]==9){
						Nhtml+="<div id='app9_"+newdata.data[i].vehicleId+"'><b>状态：</b>"+newdata.data[i].state2+"</br></div>"
					}
					if(WinShowParms[ws]==10){
						Nhtml+="<div id='app10_"+newdata.data[i].vehicleId+"'><b>位置：</b>"+newdata.data[i].memo+"</br></div>"
					}
					if(WinShowParms[ws]==11 && eqVisualPower.sim){
						Nhtml+="<div id='app11_"+newdata.data[i].vehicleId+"'><b>SIM卡号：</b>"+xyMarkers[k].simCode+"</br></div>"
					}
					if(WinShowParms[ws]==12){
						Nhtml+="<div id='app12_"+newdata.data[i].vehicleId+"'><b>GPS时间：</b>"+newdata.data[i].gpstime+"</br></div>"
					}
					if(WinShowParms[ws]==13){
						Nhtml+="<div id='app13_"+newdata.data[i].vehicleId+"'><b>OBD/CAN数据：</b><a href='javascript:opobd("+newdata.data[i].vehicleId+");'><font color='#0000FF'>详细</font></a></br></div>"
					}
					if(WinShowParms[ws]==14 && eqVisualPower.remark){
						Nhtml+="<div id='app14_"+newdata.data[i].vehicleId+"'><b>备注：</b>"+xyMarkers[k].remark+"</br></div>"
					}
					if(WinShowParms[ws]==15){
						Nhtml+="<div id='app15_"+newdata.data[i].vehicleId+"'><b>经纬度：</b>"+newdata.data[i].lng+","+newdata.data[i].lat+"</br></div>"
					}
					if(WinShowParms[ws]==16){
						Nhtml+="<div id='app16_"+newdata.data[i].vehicleId+"'><b>到期时间：</b>"+(newdata.data[i].overduetime != null && newdata.data[i].overduetime.indexOf("19") != 0 ? newdata.data[i].overduetime:"")+"</br></div>"
					}
					if(WinShowParms[ws]==17){
						Nhtml+="<div id='app17_"+newdata.data[i].vehicleId+"'><b>启用时间：</b>"+(newdata.data[i].posavtime != null && newdata.data[i].posavtime.indexOf("19") != 0 ? newdata.data[i].posavtime :"")+"</br></div>"
					}
					if(WinShowParms[ws]==18 && eqVisualPower.gprs){
						Nhtml+="<div id='app18_"+newdata.data[i].vehicleId+"'><b>设备ID：</b>"+xyMarkers[k].gprs+"</br></div>"
					}
					if(WinShowParms[ws]==19){
						Nhtml+="<div id='app19_"+newdata.data[i].vehicleId+"'><b>备注2：</b>"+xyMarkers[k].remark2+"</br></div>"
					}
				}
				Nhtml+="<a href='javascript:streeViewObject.open("+newdata.data[i].vehicleId+","+newdata.data[i].blat+","+newdata.data[i].blng+","+t+","+3+");'><font color='#0000FF'>街景</font> | </a><a href='gpsonline/jsp/TrackMap.jsp?carid="+newdata.data[i].vehicleId+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a>";
				if(eqVisualPower.play)Nhtml+="<a href='gpsonline/jsp/monitor/playBack.jsp?carid="+newdata.data[i].vehicleId+"&carname="+xyMarkers[k].vhcCode+"&icon="+xyMarkers[k].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font> | </a>";
				Nhtml+="<a href='javascript:;' ><font color='#0000FF' onclick=\"openDriverInfo("+newdata.data[i].vehicleId+");\" >驾驶员</font> | </a> <a href='javascript:;' ><font color='#0000FF' onclick=\"updateWeizhi("+newdata.data[i].vehicleId+");\" >刷新位置</font> | </a>";
				if(eqVisualPower.sim)Nhtml+="<a id='sim_"+xyMarkers[k].simCode+"' href='javascript:;' ><font color='#0000FF' onclick=\"openSim("+xyMarkers[k].simCode+");\">SIM </font> | </a>";
				Nhtml+="<a id='more_"+newdata.data[i].vehicleId+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
				xyMarkers[k].info = Nhtml;
			}
		}
	}
}

//关闭infowindow
function closexyInfoWindow(id){
	for (var k = 0;k < xyMarkers.length;k++){
		if(id == xyMarkers[k].id){
			xyMarkers[k].marker.closeInfoWindow();
		}
	}
}