var mapType;
var baidMap;
var idsData;
var markers =[];
var car;
var markersarr = [];
var photourl;
var myDis;
var label;
var errorFilter=false;
function googleToBaidu(glng,glat){
	
	var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
	//alert(x_pi);
	var x = glng, y = glat;
	var z =Math.sqrt(x * x + y * y) + 0.00002 *Math.sin(y * x_pi);
	var theta =Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
	var lng = z *  Math.cos(theta) + 0.0065;
	var lat = z *  Math.sin(theta) + 0.006;
	var myLatlng = new BMap.Point(lng,lat);
	return myLatlng;
	
}

function cutoverMap() {
	 topics.length=0;
	 times.length = 0;
	 var myselect = document.getElementById("select");
	 var index = myselect.selectedIndex;
	 mapType = myselect.options[index].value;
	 document.getElementById("lic").innerHTML="";
	 document.getElementById("youh").innerHTML="";
	 document.getElementById("time").innerHTML="";
	 if(car!=null){
	   	  clearTimeout(yctime);
	  	  var chart = $('#container').highcharts();
	      if (chart.series.length) {
	             chart.series[0].setData([]);
	             chart.series[1].setData([]);
	             chart.series[2].setData([]);
	      }
	      for(var i=1;i<=car.topics.length;i++){
	      		$('#row'+i).remove();
	      }
	      
	  	  initialize2();
	  	  playkg = null;
	  	  bol = false;
	  	 
	  	  $("#startplay").val("轨迹回放");
	  	  row_count = 1;
	  	  //$( "#slider" ).slider( "option", "value", 0 );
	      $( "#slider" ).slider( "disable" );
	  	  // document.getElementById("f5").style.display = "none";
	 	  car = null;
	 	  $('#f5').attr('disabled', true);
	 	  $('#end').attr('disabled', false);
		  $('#start').attr('disabled', false);
		  tnum = 0;
		  Ascending =0;
		 
	 }
	 if(1==mapType){
		 markers.length=0;
		 baidMap = new BMap.Map("map_canvas");      // 创建地图实例    
		 var point = new BMap.Point(111, 34);  // 创建点坐标
		 baidMap.centerAndZoom(point, 5);
		 baidMap.addControl(new BMap.NavigationControl());  //缩放轴
		 baidMap.addControl(new BMap.OverviewMapControl());    //缩略图
		 baidMap.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_HYBRID_MAP ]})); //地图类型
		
		 baidMap.enableScrollWheelZoom(); //启用滚轮放大缩小
		 baidMap.addControl(new BMap.ScaleControl());   // 添加默认比例尺控件
		
		
	 }else{
		 if(typeof(google)=="undefined"){
			 loadGoogleMapJs();
		 }
		 initialize2();
	 }
	 
	 var treeObj = $.fn.zTree.getZTreeObj("markerGroupTree");
	 
	 treeObj.checkNode(treeObj.getNodeByParam("id","root_g_-1000"), false, true);
	
}
	
	function openDistance(){
		if(myDis!=null)myDis.close();
		myDis = new BMapLib.DistanceTool(baidMap);
		myDis.open(); //开启鼠标测距
	}
	var labelOpenOrNo = true;
	function openOrCloseLabel(){
		if($('#label_show').is(':checked')){
			labelOpenOrNo = true;
			baidMap.addOverlay(label);
		}else{
			labelOpenOrNo = false;
			baidMap.removeOverlay(label);
		}
	}
	
	
function baiduMap(){
	 baidMap = new BMap.Map("map_canvas");      // 创建地图实例    
	 var point = new BMap.Point(111, 34);  // 创建点坐标
	 baidMap.centerAndZoom(point,5);
	 baidMap.addControl(new BMap.NavigationControl());  //缩放轴
	 baidMap.addControl(new BMap.OverviewMapControl());    //缩略图
	 baidMap.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_HYBRID_MAP ]})); //地图类型
	
	 baidMap.enableScrollWheelZoom(); //启用滚轮放大缩小
	 baidMap.addControl(new BMap.ScaleControl());   // 添加默认比例尺控件
	 
	 var type = g("uType").value;
		var name = g("uName").value;
		var pass = g("uPass").value;
		var startTime = g("startTime").value;
		var endTime = g("endTime").value;
		var jiekoukg = false;
		if(name != "null" && pass != "null"){
		     if(type == "null"){
		     	type=-100;
		     }
			 $('#startplay').attr('disabled', true);
			 $.ajax({
			       type: "POST",
			       dataType: "json",
			       cache:true,
			       url: "json/loginAction_login.action?request_locale=zh_CN",
			       data: { userName: name, userPass: pass,userType:type},
			       success: function(json) {
				         if (json.flag==true) {	  
				        	$('#startplay').attr('disabled', false);
				        	document.getElementById("carid").value=json.data[0].id;
							if(startTime!="null" && endTime != "null"){
								  startTime = startTime.replace("-","/");
								  startTime=startTime.replace("-","/");
								  startTime=startTime.replace("T"," ");
					   					
					 			  endTime = endTime.replace("-","/");
								  endTime=endTime.replace("-","/");
								  endTime=endTime.replace("T"," ");
								  if(new Date(endTime).getTime() - new Date(startTime).getTime()<=864000000){
									  $("#start").val(startTime);
									  $("#end").val(endTime);
									  play();
								  }else{
								  	alert("对不起，日期数据不合法，请对照接口文档检查.");
								  }
							}
		  
		
				         }else {
				         	  var name2 = g("uName2").value;
				        	  $.ajax({
							       type: "POST",
							       dataType: "json",
							       cache:true,
							       url: "json/loginAction_login.action?request_locale=zh_CN",
							       data: { userName: name2, userPass: pass,userType:type},
							       success: function(json) {
								         if (json.flag==true) {	  
								        	$('#startplay').attr('disabled', false);
								        	document.getElementById("carid").value=json.data[0].id;
								        	 if(startTime!="null" && endTime != "null"){
								        		 startTime = startTime.replace("-","/");
									   			 startTime=startTime.replace("-","/");
									   			 startTime=startTime.replace("T"," ");
									      					
									    		 endTime = endTime.replace("-","/");
									   			 endTime=endTime.replace("-","/");
									   			 endTime=endTime.replace("T"," ");
												 if(new Date(endTime).getTime() - new Date(startTime).getTime()<=864000000){
													 $("#start").val(startTime);
													 $("#end").val(endTime);
												 	play();
												 }else{
												  	alert("对不起，日期数据不合法，请对照接口文档检查.");
												 }
											 }
								         }else {
								        	  alert(json.msg);
								         }
							       },
							       error: function() {
							            //alert('获取账号信息失败...请稍后重试!');
							       }
							  });
				         }
			       },
			       error: function() {
			            //alert('获取账号信息失败...请稍后重试!');
			       }
			  });
		}else if(startTime!="null" && endTime != "null"){
			// $("#start").val(startTime);
			// $("#end").val(endTime);
			 $("#start").val(startTime);
			 $("#end").val(endTime);
	
		      startTime = startTime.replace("-","/");
			  startTime=startTime.replace("-","/");
			  startTime=startTime.replace("T"," ");
					
			  endTime = endTime.replace("-","/");
			  endTime=endTime.replace("-","/");
			  endTime=endTime.replace("T"," ");
			  if(new Date(endTime).getTime() - new Date(startTime).getTime()<=5184000000){
			  	  play();
			  }else{
			  	  alert("对不起，日期数据不合法，请对照接口文档检查.");
			  }
		}
		if(errorFilter!=true){
			startMarker();
			openMarkerPanel();
		}
}

//获取两个时间之间分钟数
function getMiuntesByStartAndEnd(start,end){
	
	if(start != null && start != "" && end != null && end != ""){
		start = start.replace("T"," ");
		end = end.replace("T"," ");
		
		var startArr = start.split(" ");
		var   endArr = end.split(" ");
		
		var startDate = new Date(startArr[0].split("-")[0],startArr[0].split("-")[1]-1,startArr[0].split("-")[2],startArr[1].split(":")[0],startArr[1].split(":")[1],startArr[1].split(":")[2]);
		var   endDate = new Date(endArr[0].split("-")[0],endArr[0].split("-")[1]-1,endArr[0].split("-")[2],endArr[1].split(":")[0],endArr[1].split(":")[1],endArr[1].split(":")[2]);
				
		return Math.floor((endDate.getTime()-startDate.getTime())/(60*1000));
    }else{
      return -1;
    }
}


var carid;
var carIcon;
var playDis = 0;

function baiduMapDraw(datas,xb){
	 //baidMap.setZoom(18);
	 carid = document.getElementById("carid").value;
	 carIcon = document.getElementById("icon").value;
	 //console.info("------" + datas.topics.length);
	 if(datas.topics.length>2){
		 playDis = datas.topics[datas.topics.length-1].totaldistance - datas.topics[0].totaldistance;
	 }
	if(datas.topics.length>0){
 		$("#slider").slider("option","max",datas.topics.length-1);
 		car = datas;
 		var point =googleToBaidu((datas.topics[xb].lng+datas.topics[xb].lng_xz),(datas.topics[xb].lat+datas.topics[xb].lat_xz)); 
 		baidMap.centerAndZoom(point, 13);
  		
 		var qidianIcon = new BMap.Icon("gpsonline/image/map/marker_qidian.png", new BMap.Size(35,35));
		var qidian = new BMap.Marker(
				//googleToBaidu((datas.topics[xb].lng+datas.topics[xb].lng_xz),(datas.topics[xb].lat+datas.topics[xb].lat_xz)),
				point,
				{icon:qidianIcon}
		);  // 创建标注
		baidMap.addOverlay(qidian);
		
		var zhongdianIcon = new BMap.Icon("gpsonline/image/map/marker_zhongdian.png", new BMap.Size(35,35));
		var zhongdian = new BMap.Marker(
				googleToBaidu((datas.topics[datas.topics.length-1].lng+datas.topics[datas.topics.length-1].lng_xz),(datas.topics[datas.topics.length-1].lat+datas.topics[datas.topics.length-1].lat_xz))
				,{icon:zhongdianIcon}
		);  // 创建标注
		baidMap.addOverlay(zhongdian);
		
	  
    //画线
    var rgb = "#00A";
	var i=xb-1;
	var flightPlanCoordinates = [];
	
	var start = "";
	var end ="";
	while(i<(datas.topics.length-1)){
		i++;
		if(wuxiaobool==false && datas.topics[i].av=="0"){
			
		}else{
			//flightPlanCoordinates.push(new BMap.Point((datas.topics[i].lng+datas.topics[i].lng_bi),(datas.topics[i].lat+datas.topics[i].lat_bi)));
			flightPlanCoordinates.push(googleToBaidu((datas.topics[i].lng+datas.topics[i].lng_xz),(datas.topics[i].lat+datas.topics[i].lat_xz)));
		}
	}
	var polyline = new BMap.Polyline(
        flightPlanCoordinates,
        {strokeColor:rgb,strokeWeight:3,strokeOpacity:1}
    );
	baidMap.addOverlay(polyline);
	
			var s=10;
			var condition=car.topics[xb].state;
		  	var sp = parseInt(car.topics[xb].veo);
		  	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;
		}
	  	var state = s;
	  	var pngicon = "gpsonline/image/pic/"+carIcon+"/red_0.gif";
		if(state == 0) pngicon = "gpsonline/image/pic/"+carIcon+"/green_";
		else if(state == 1) pngicon = "gpsonline/image/pic/"+carIcon+"/red_";
		else if(state == 2) pngicon = "gpsonline/image/pic/"+carIcon+"/gray_";
		else if(state == 3) pngicon = "gpsonline/image/pic/"+carIcon+"/yellow_";
		else if(state == 4) pngicon = "gpsonline/image/pic/"+carIcon+"/pink_";
		else if(state == 5) pngicon = "gpsonline/image/pic/"+carIcon+"/stopalarm";
		else pngicon = "gpsonline/image/pic/"+carIcon+"/red_";
	    var ti = parseInt(car.topics[xb].dir);
	  				if(ti>27 &&ti<=72){
				  		if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="45.gif";
				  		}
						direction="东北";
					}else if(ti>72 && ti<=117){
						if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="90.gif";
				  		}
						
						direction="东";
					}
					else if(ti>117 && ti<=162){
						if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="135.gif";
				  		}
						direction="东南";
					}
					else if(ti>162 && ti<=207){
						if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="180.gif";
				  		}
						direction="南";
					}
					else if(ti>207 && ti<=252){
						if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="225.gif";
				  		}
						direction="西南";
					}
					else if(ti>252 && ti<=297){
						if(state == 5){
				  			var image=".gif";
				  		}else{
				  			var image="270.gif";
				  		}
						direction="西";
					}
					else if(ti>297 && ti<=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 html = "<div class='guiji_ceng'>"
			    +"<div class='b d1'><b>"//设备名称：</b>"+strCarName+"</br>"
			    					//+"<b>车牌号码：</b>"+strCarName+"</br>"
									+"<b>接收时间：</b>"+car.topics[xb].recvt+"</br>"
									+"<b>速度：</b>"+car.topics[xb].veo.toFixed(1)+"km/h </br>"
									+"<b>方向：</b>"+direction+"</br>"
									+"<b>油量：</b>"+car.topics[xb].oil.toFixed(1)+" L </br>"
									+"<b>状态：</b>"+car.topics[xb].state+"</br>"
									//+"<b>当日里程1：</b>"+(car.topics[xb].totaldistance-car.topics[0].totaldistance).toFixed(2)+" km </br>"
									+"<b>总里程：</b>"+car.topics[xb].totaldistance.toFixed(2)+" km </br>"
									+"<b>位置：</b>"+car.topics[xb].posinfo+" </br>"
									+"</div>"
								    +"<div> <span class='guiji_sanjiao'></span>"
									+"<span class='guiji_sanjiao_2'></span></div>"
								+"</div>";
			var icon_size=real(carIcon);
			var myIcon = new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size));
 			var marker = new BMap.Marker(
 					point
 					,{icon:myIcon}
 			);  // 创建标注
 			baidMap.addOverlay(marker);
 			var opts = {
			  position :point,    // 指定文本标注所在的地理位置
			  offset   : new BMap.Size(-5, -135)    //设置文本偏移量
			 
			}
			label = new BMap.Label(html,opts);  // 创建文本标注对象
			label.setStyle({
				 color : "#000000",
				 background:"none",
				 border:"none",
				 fontSize : "12px"
			 });
			if(labelOpenOrNo){
				baidMap.addOverlay(label);
			}
			var markerManage = new Object();
 			markerManage.marker = marker;
 			markerManage.label = label;
				
 			markers.push(markerManage);
 			baidMap.openInfoWindow(markers[0].infowindow,new BMap.Point((datas.topics[xb].lng+datas.topics[xb].lng_xz),(datas.topics[xb].lat+datas.topics[xb].lat_xz)));						
			$("#startplay").val("暂停回放");
			 playkg = true;
			 curveb = true;
			 $( "#slider" ).slider( "option","disabled",false);
			 closeMask();
			 curve();
			 clearTimeout(setT);
	}
}

function updateBaiduMap(){
	if(playkg == true){
	    if(tnum<car.topics.length){
	    				switchb = false;
	    				$( "#slider" ).slider( "option", "value", tnum );
	    				if(wuxiaobool==false &&car.topics[tnum].av=="0") return;
						var s=10;
						var condition=car.topics[tnum].state;
					  	var sp = parseInt(car.topics[tnum].veo);
					  	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;
					}
				  	var state =s;
				  	var pngicon = "gpsonline/image/pic/"+carIcon+"/red_0.gif";
					if(state == 0) pngicon = "gpsonline/image/pic/"+carIcon+"/green_";
					else if(state == 1) pngicon = "gpsonline/image/pic/"+carIcon+"/red_";
					else if(state == 2) pngicon = "gpsonline/image/pic/"+carIcon+"/gray_";
					else if(state == 3) pngicon = "gpsonline/image/pic/"+carIcon+"/yellow_";
					else if(state == 4) pngicon = "gpsonline/image/pic/"+carIcon+"/pink_";
					else if(state == 5) pngicon = "gpsonline/image/pic/"+carIcon+"/stopalarm";
					else pngicon = "gpsonline/image/pic/"+carIcon+"/red_";
				 
				  var ti = parseInt(car.topics[tnum].dir);
				  //alert(ti);
				  				if(ti>27 &&ti<=72){
							  		if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="45.gif";
							  		}
									direction="东北";
								}else if(ti>72 && ti<=117){
									if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="90.gif";
							  		}
									direction="东";
								}
								else if(ti>117 && ti<=162){
									if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="135.gif";
							  		}
									direction="东南";
								}
								else if(ti>162 && ti<=207){
									if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="180.gif";
							  		}
									direction="南";
								}
								else if(ti>207 && ti<=252){
									if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="225.gif";
							  		}
									direction="西南";
								}
								else if(ti>252 && ti<=297){
									if(state == 5){
							  			var image=".gif";
							  		}else{
							  			var image="270.gif";
							  		}
									direction="西";
								}
								else if(ti>297 && ti<=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 b = new Base64();  
				        // var str =b.decode(carname);
				  		 var tempdis = car.topics[tnum].totaldistance-car.topics[0].totaldistance;
				  		 if(tempdis > dqdis){
				  			dqdis = tempdis;
				  		 }
						 var html = "<div class='guiji_ceng'>"
							    +"<div class='b d1'>"//<b>设备名称：</b>"+strCarName+"</br>"
											    //+"<b>车牌号码：</b>"+strCarName+"</br>"
												+"<b>接收时间：</b>"+car.topics[tnum].recvt+"</br>"
												+"<b>速度：</b>"+car.topics[tnum].veo.toFixed(1)+"km/h </br>"
												+"<b>方向：</b>"+direction+"</br>"
												+"<b>油量：</b>"+car.topics[tnum].oil.toFixed(1)+" L </br>"
												+"<b>状态：</b>"+car.topics[tnum].state+"</br>"
												//+"<b>回放里程：</b>"+playDis.toFixed(2)+" km </br>"
												+"<b>回放里程：</b>"+(car.topics[tnum].totaldistance-car.topics[0].totaldistance).toFixed(2)+" km </br>"
												//+"<b>总里程：</b>"+car.topics[tnum].totaldistance.toFixed(2)+" km </br>"
												+"<b>位置：</b>"+car.topics[tnum].posinfo+" </br>"
												+"</div>"
											    +"<div> <span class='guiji_sanjiao'></span>"
		    									+"<span class='guiji_sanjiao_2'></span></div>"
											+"</div>";
						//markers[0].marker.setPosition(new BMap.Point((car.topics[tnum].lng+car.topics[tnum].lng_bi),(car.topics[tnum].lat+car.topics[tnum].lat_bi)));		 
						markers[0].marker.setPosition(googleToBaidu((car.topics[tnum].lng+car.topics[tnum].lng_xz),(car.topics[tnum].lat+car.topics[tnum].lat_xz)));		 
						
						var icon_size=real(carIcon);
						markers[0].marker.setIcon(new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size)));
						markers[0].label.setContent(html);
						markers[0].label.setPosition(googleToBaidu((car.topics[tnum].lng+car.topics[tnum].lng_xz),(car.topics[tnum].lat+car.topics[tnum].lat_xz)));		 
						
						//markers[0].label.setPosition(new BMap.Point((car.topics[tnum].lng+car.topics[tnum].lng_bi),(car.topics[tnum].lat+car.topics[tnum].lat_bi)));		 
						if(labelOpenOrNo){
							baidMap.addOverlay(markers[0].label);
						}else{
							baidMap.removeOverlay(markers[0].label);
						}
						if(photobool==true  && car.topics[tnum].photo !="" && car.topics[tnum].photo !=null){
							for(var i = tnum;i < tnum+1; i++){
					        	(function(n){
					        		
					        		 var icon2 = new BMap.Icon("gpsonline/image/map/photo.png", new BMap.Size(35,35));
					        		 var markerPhoto =  new BMap.Marker(
					        				 googleToBaidu((car.topics[tnum].lng+car.topics[tnum].lng_xz),(car.topics[tnum].lat+car.topics[tnum].lat_xz))
					        			,{icon:icon2}
					        		 );  // 创建标注
							         baidMap.addOverlay(markerPhoto);
							         
								       	var infoWin = new BMap.InfoWindow("<div> <img  id='imgDemo' src='"+photourl+car.topics[tnum].photo+"' width='320' height='240'/></div>"
												);
								       	markerPhoto.addEventListener("click", function(){
								       		this.openInfoWindow(infoWin);
								       		document.getElementById('imgDemo').onload = function (){
								       			infoWin.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
								     	   }
								       	
								       	});
										
										var markerPhotoManager = new  Object();
										markerPhotoManager.markerPhoto = markerPhoto;
										markerPhotoManager.infoWin = infoWin;
										
										markerPhotos.push(markerPhotoManager);
							          
							        })(i);
						    }
						}
						var p = new Object();
				    	p.leftLat = baidMap.getBounds().getSouthWest().lat;
						p.leftLng = baidMap.getBounds().getSouthWest().lng;
						p.rightLat = baidMap.getBounds().getNorthEast().lat;
						p.rightLng = baidMap.getBounds().getNorthEast().lng;
						if((car.topics[tnum].lat+car.topics[tnum].lat_bi) < p.leftLat || (car.topics[tnum].lng+car.topics[tnum].lng_bi) < p.leftLng || (car.topics[tnum].lat+car.topics[tnum].lat_bi) > p.rightLat || (car.topics[tnum].lng+car.topics[tnum].lng_bi) > p.rightLng
						){
							baidMap.setCenter(new BMap.Point((car.topics[tnum].lng+car.topics[tnum].lng_bi),(car.topics[tnum].lat+car.topics[tnum].lat_bi)));
						}
						
						
						if(sp==0){
							stopCar= new Object();
							stopCar.time = car.topics[tnum].recvt;
							stopCar.latlng = new BMap.Point((car.topics[tnum].lng+car.topics[tnum].lng_xz),(car.topics[tnum].lat+car.topics[tnum].lat_xz));
							stopCarList.push(stopCar);
					  	}else{
					  		if(stopCarList.length>0){
					  			var stopTime = stopCarList[0].time.replace("-","/");
								stopTime=stopTime.replace("-","/");
								stopTime=stopTime.replace("T"," ");
								
								var startTime =car.topics[tnum].recvt.replace("-","/");
								startTime=startTime.replace("-","/");
								startTime=startTime.replace("T"," ");
								
								var timeStr = new Date(startTime).getTime()- new Date(stopTime).getTime();
								if(timeStr>stopCarTime){
									var days=Math.floor(timeStr/(24*3600*1000));
									//计算出小时数
									var leave1=timeStr%(24*3600*1000);    //计算天数后剩余的毫秒数
									var hours=Math.floor(leave1/(3600*1000));
									//计算相差分钟数
									var leave2=leave1%(3600*1000) ;       //计算小时数后剩余的毫秒数
									var minutes=Math.floor(leave2/(60*1000));
									//计算相差秒数
									var leave3=leave2%(60*1000);     //计算分钟数后剩余的毫秒数
									var seconds=Math.round(leave3/1000);
									var timeMsg = "";
									if(days==0){
										timeMsg=""+hours+" 小时  "+minutes+"  分钟   "+seconds+" 秒";
									}else{
										timeMsg="停车时间："+days+" 天  "+hours+" 小时  "+minutes+"  分钟   "+seconds+" 秒";
									}
								    for(var i = tnum;i < tnum+1; i++) {
							        	(function(n){
							        		   var picon = new BMap.Icon("gpsonline/image/map/marker_stop1.png",new BMap.Size(40,60));
							        		   //picon.setImageOffset(new BMap.Size(-20,-20));
									           var markerStop = new BMap.Marker(
									        		   //stopCarList[0].latlng,
									        		   googleToBaidu((car.topics[tnum].lng+car.topics[tnum].lng_xz),(car.topics[tnum].lat+car.topics[tnum].lat_xz)),
								    				   {icon:picon}
								    			);  // 创建标注
								    			baidMap.addOverlay(markerStop);
								    			var infoWin = new BMap.InfoWindow("<b>停车时间：</b>"+timeMsg+"</br>"
														+"<b>开始时间：</b>"+stopTime+"</br>"
														+"<b>结束时间：</b>"+startTime+"</br>"
								    					+"<b>位置：</b>"+car.topics[tnum].posinfo+"</br>");
								    			markerStop.addEventListener("click", function(){this.openInfoWindow(infoWin);});
												
												var markerStopManager = new  Object();
												markerStopManager.markerStop = markerStop;
												markerStopManager.infoWin = infoWin;
												markerStops.push(markerStopManager);
									        })(i);
								    }
								}else{
								
								}
							    stopCarList.length=0;
					  		}
					  	}
						/*var container = $('#mingxi_tab'),
						scrollTo = $('#row'+(row_count-1));
						container.scrollTop(
						 	 scrollTo.offset().top - container.offset().top-20 + container.scrollTop()
						);*/
						$("#mingxi_main").scrollTop($("#mingxi_main")[0].scrollHeight);
						
		}else{
		   playkg = false;
		   $("#startplay").val("开始回放");
	   	   tnum=0;
		}
		switchb = true;
	}
}
function real(id){
	if(id == "0"){
		return 24;
	}
	if(id == "1"){
		return 24;
	}
	if(id == "2"){
		return 24;
	}
	if(id == "3"){
		return 24;
	}
	if(id == "4"){
		return 24;
	}
	if(id == "5"){
		return 24;
	}
	if(id == "6"){
		return 24;
	}
	if(id == "7"){
		return 24;
	}
	if(id == "8"){
		return 24;
	}
	if(id == "9"){
		return 32;
	}
	if(id == "10"){
		return 24;
	}
	if(id == "12"){
		return 29;
	}
    };
