var mapType=1;
var baidMap;
var idsData;
var markers =[];
var bzMarkers =[];
var namekg = true;
var newdata;
var mapOptions;
var yanchiAl;
var baidubool = false;
var markersArray = [];
function cutoverMap() {
		var checkbox1 = document.getElementsByName("checkboxcarname");
		if(checkbox1[0].checked){
			 checkbox1[0].checked = "";
	    }
		var bzcheckbox = document.getElementsByName("bzcheckbox");
		if(bzcheckbox[0].checked){
			 bzcheckbox[0].checked = "";
	    }
	 

	 memoryStatus(true);
 
	 //alert(getUserStatus().lat+","+getUserStatus().lng+","+getUserStatus().zoom);
	 var  myselect=document.getElementById("select");
	 var index=myselect.selectedIndex ;
	 mapType=myselect.options[index].value;
	
	 initTool();//切换地图时初始化工具
	 if(isLargeData==true){
		 idsData="thresholds";
	 }
	 if(1==mapType){
		 	 markers.length=0;
		 	 bzMarkers.length=0;
			 baiduMap(idsData,false);
			 showMarkerBaidu(markerObject.markerJson);
			 addMenu();
			 shieldFence();
	 }else{
		 	 vehicles.length=0;
			 googleMap();
			 //点击地图时关闭已经打开的弹出框
			 mapclickEvent();
			  //添加标注菜单
			 addMarkerMenu();
			  //添加所有标注  
			 addAllMarker();
			 
			 electronicFence.tree.init();
			 
			 openFence();

	 }
	 
	 initMarkerisShow();
	 
	 /*
	 var checkbox1 = document.getElementsByName("checkbox1");
	 if(checkbox1[0].checked){
		 checkbox1[0].checked = "";
     }*/
     /*
	 var bzcheckbox = document.getElementsByName("bzcheckbox");
	 if(bzcheckbox[0].checked){
		 bzcheckbox[0].checked = "";
     }*/
	 //al();
	 if(namekg == false){
		 namekg = true;
	 }
	 //namekg = false;
	 //showCarName();
}
var oldPolygon = new BMap.Polygon();
function addMarkerBaidu(pStart,pEnd){
	oldPolygon.setPath([new BMap.Point(pStart.lng,pStart.lat),new BMap.Point(pEnd.lng,pStart.lat), new BMap.Point(pEnd.lng,pEnd.lat),new BMap.Point(pStart.lng,pEnd.lat)]);
	
	oldPolygon.setStrokeColor("blue");
	oldPolygon.setFillColor("blue");
	oldPolygon.setStrokeWeight(2);
	oldPolygon.setStrokeOpacity(0.5);
	baidMap.addOverlay(oldPolygon);
	
}
function updateMarkerBaidu(id,pStart,pEnd){
	
	for(i=0;i<bzMarkers.length;i++){
		if(bzMarkers[i].id==id){
			
			bzMarkers[i].polygon.setPath([new BMap.Point(pStart.lng,pStart.lat),new BMap.Point(pEnd.lng,pStart.lat), new BMap.Point(pEnd.lng,pEnd.lat),new BMap.Point(pStart.lng,pEnd.lat)]);
			
			break;
		}
	}
}
function updateBzMarkers(markersJson){
	for(var i=0;i<bzMarkers.length;i++){
			if(bzMarkers[i].id==markersJson.data[0].id){
				var blat;
				var blng;
				if(markersJson.data[0].blat>0 && markersJson.data[0].blng>0){
					blat=markersJson.data[0].blat;
					blng=markersJson.data[0].blng;
				}else{
					blat=markersJson.data[0].lat2;
					blng=markersJson.data[0].lng2;
				}
				var myIcon = new BMap.Icon(markersJson.data[0].icon, new BMap.Size(35,35));
				var html="<div style='font-weight:normal;'><b>名称：</b>"+markersJson.data[0].title+"</br>"
				+"<b>描述：</b>"+markersJson.data[0].text+"</br>"
				+"<b>经度：</b>"+blat+"</br>"
				+"<b>纬度：</b>"+blng+"</br>";
				var htm="<a href='javascript:openUpdateMarkerWin("+markersJson.data[0].id+");'><font color='#0000FF'>修改</font> | </a><a href='javascript:deleteMarker("+markersJson.data[0].id+");'><font color='#0000FF'>删除</font></a> </div>";
				if(markersJson.data[0].competence==1){
					html=html+htm;
				}else{
					html=html+"</div>";
				}
				bzMarkers[i].marker.setIcon(myIcon);
				bzMarkers[i].label.setContent(markersJson.data[0].title);
				bzMarkers[i].infowindow.setContent(html);
				//var pStart = new BMap.Point(markersJson.data[0].userMarkerArea.leftLon,markersJson.data[0].userMarkerArea.leftLat);
				//var pEnd = new BMap.Point(markersJson.data[0].userMarkerArea.rightLon,markersJson.data[0].userMarkerArea.rightLat);
				//bzMarkers[i].polygon.setPath([new BMap.Point(pStart.lng,pStart.lat),new BMap.Point(pEnd.lng,pStart.lat), new BMap.Point(pEnd.lng,pEnd.lat),new BMap.Point(pStart.lng,pEnd.lat)]);
				
				break;
			}
		}
}
function delMarkerBaidu(id){
    for(i=0;i<bzMarkers.length;i++){
		if(bzMarkers[i].id==id){
			baidMap.removeOverlay(bzMarkers[i].label);
			baidMap.removeOverlay(bzMarkers[i].marker);
			baidMap.removeOverlay(bzMarkers[i].infowindow);
			baidMap.removeOverlay(bzMarkers[i].polygon);
			bzMarkers.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;
	
	
}
function openMarkerBaidu(id){
	for(i=0;i<bzMarkers.length;i++){
		if(bzMarkers[i].id==id){
			bzMarkers[i].marker.openInfoWindow(bzMarkers[i].infowindow);
			baidMap.centerAndZoom(bzMarkers[i].latlng, 15);
			break;
		}
	}
}
function updateMarkerIsShow(id,isShow,isAll){
	if(isAll){
		for(i=0;i<bzMarkers.length;i++){
				bzMarkers[i].isShow = isShow;
		}
	}else{
		for(i=0;i<bzMarkers.length;i++){
			if(bzMarkers[i].id==id){
				bzMarkers[i].isShow = isShow;
				break;
			}
		}
	}
	
}
function showMarkersBaidu(id,bool){
	var bzcheckbox = document.getElementsByName("bzcheckbox");
	if(bool){
		for(i=0;i<bzMarkers.length;i++){
				baidMap.addOverlay(bzMarkers[i].marker);
				baidMap.addOverlay(bzMarkers[i].polygon);
				 if(bzcheckbox[0].checked){
					 baidMap.addOverlay(bzMarkers[i].label);
			     }
		}
	}else{
		for(i=0;i<bzMarkers.length;i++){
			if(bzMarkers[i].id==id){
				
				baidMap.addOverlay(bzMarkers[i].marker);
				baidMap.addOverlay(bzMarkers[i].polygon);
				if(bzcheckbox[0].checked){
					 baidMap.addOverlay(bzMarkers[i].label);
			     }
			}
		}
	}
	
}
function hideMarkersBaidu(id,bool){
	if(bool){
		for(i=0;i<bzMarkers.length;i++){
				baidMap.removeOverlay(bzMarkers[i].marker);
				baidMap.removeOverlay(bzMarkers[i].polygon);
				baidMap.removeOverlay(bzMarkers[i].label); 
		}
	}else{
		for(i=0;i<bzMarkers.length;i++){
			if(bzMarkers[i].id==id){
				baidMap.removeOverlay(bzMarkers[i].marker);
				baidMap.removeOverlay(bzMarkers[i].polygon);
				baidMap.removeOverlay(bzMarkers[i].label); 
			}
		}
	}
	
}
function showMarkerBaidu(markersJson){
	if(markersJson == ""){
		return;
	}
	for(var i=0;i<markersJson.data.length;i++){
		(function(x){
			var blat;
			var blng;
			if(markersJson.data[i].blat>0 && markersJson.data[i].blng>0){
				blat=markersJson.data[i].blat;
				blng=markersJson.data[i].blng;
			}else{
				blat=markersJson.data[i].lat2;
				blng=markersJson.data[i].lng2;
			}
			var myLatlng = new BMap.Point(blat,blng);
			var myIcon = new BMap.Icon(markersJson.data[i].icon, new BMap.Size(35,35));
			var marker = new BMap.Marker(
					myLatlng
					,{icon:myIcon}
			);  // 创建标注
			//baidMap.addOverlay(marker);
			var opts = {
			  position : myLatlng,    // 指定文本标注所在的地理位置
			  offset   : new BMap.Size(15, -10)    //设置文本偏移量
			 
			}
			var label = new BMap.Label(markersJson.data[i].title, opts);  // 创建文本标注对象
			label.setStyle({
				 color : "#000000",
				 backgroundColor : "#f5fcb8",
				 borderColor : "#000000",
				 fontSize : "12px",
				 height : "16px",
				 lineHeight : "16px",
				 fontWeight:"bold",
				 fontFamily:""
			});
			//baidMap.addOverlay(label); 
			//创建信息窗口
			var html="<div style='font-weight:normal;'><b>名称：</b>"+markersJson.data[i].title+"</br>"
			+"<b>描述：</b>"+markersJson.data[i].text+"</br>"
			+"<b>经度：</b>"+blat+"</br>"
			+"<b>纬度：</b>"+blng+"</br>";
			
			var htm="<a href='javascript:openUpdateMarkerWin("+markersJson.data[i].id+");'><font color='#0000FF'>修改</font> | </a><a href='javascript:deleteMarker("+markersJson.data[i].id+");' ><font color='#0000FF'>删除</font></a> </div>";
			if(markersJson.data[i].competence==1){
				html=html+htm;
			}else{
				html=html+"</div>";
			}
			var infoWindow = new BMap.InfoWindow(html);
			marker.addEventListener("click", function(){this.openInfoWindow(infoWindow);});
			var pStart;
			var pEnd;
			if(markersJson.data[i].userMarkerArea == null || markersJson.data[i].userMarkerArea ==""){
				var pStart = new BMap.Point(0,0);
				var pEnd = new BMap.Point(0,0);
			}else{
				if(markersJson.data[i].userMarkerArea.b_leftLon == 0 || markersJson.data[i].userMarkerArea.b_leftLat == 0){
					var pStart = new BMap.Point(markersJson.data[i].userMarkerArea.leftLon,markersJson.data[i].userMarkerArea.leftLat);
					var pEnd = new BMap.Point(markersJson.data[i].userMarkerArea.rightLon,markersJson.data[i].userMarkerArea.rightLat);
					
				}else{
					var pStart = new BMap.Point(markersJson.data[i].userMarkerArea.b_leftLon,markersJson.data[i].userMarkerArea.b_leftLat);
					var pEnd = new BMap.Point(markersJson.data[i].userMarkerArea.b_rightLon,markersJson.data[i].userMarkerArea.b_rightLat);
					
				}
				
			}
			var polygon = new BMap.Polygon([
	              new BMap.Point(pStart.lng,pStart.lat),
				  new BMap.Point(pEnd.lng,pStart.lat),
				  new BMap.Point(pEnd.lng,pEnd.lat),
				  new BMap.Point(pStart.lng,pEnd.lat)
	          ], {strokeColor:"blue",fillColor:"blue", strokeWeight:2, strokeOpacity:0.5});
			//baidMap.addOverlay(polygon);
			
			markerManage = new Object();
			markerManage.id = markersJson.data[i].id;
			markerManage.title = markersJson.data[i].title;
			markerManage.label = label;
			markerManage.marker = marker;
			markerManage.polygon = polygon;
			markerManage.icon = markersJson.data[i].icon;
			markerManage.infowindow = infoWindow;
			markerManage.latlng = myLatlng;
			markerManage.isShow = false;
			bzMarkers.push(markerManage);
			
		})(i);
    }	
}
var strNum =0;
function addMarkers(iNum,j){
	
	for(var i=iNum;i<j;i++){
		(function(x){
			if(carList.data[i] != "" && carList.data[i] !=null){
			
					
					var myLatlng = new BMap.Point(carList.data[i].positionLast.blng,carList.data[i].positionLast.blat);
						
					
					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 b = new Base64();  
	      		//	var carname = b.encode(carList.data[i].vhcCode); 
	      			var carname = encodeURI(encodeURI(carList.data[i].vhcCode)); 
				    var html =	"<div id='app_"+carList.data[i].id+"' style='font-weight:normal;'>"
				    +"<div id='app1_"+carList.data[i].id+"'><b>设备名称：</b>"+carList.data[i].vhcCode+"</br></div>"
				    +"<div id='app11_"+carList.data[i].id+"'><b>SIM卡号：</b>"+carList.data[i].simCode+"</br></div>"
					+"<div id='app2_"+carList.data[i].id+"'><b>接收时间：</b>"+carList.data[i].positionLast.recvtime+"</br></div>"
					+"<div id='app3_"+carList.data[i].id+"'><b>速度：</b>"+carList.data[i].positionLast.speed.toFixed(1)+"km/h </br></div>"
					+"<div id='app4_"+carList.data[i].id+"'><b>方向：</b>"+direction+"</br></div>"
					+"<div id='app5_"+carList.data[i].id+"'><b>温度：</b>"+carList.data[i].positionLast.temperature+" ℃</br></div>"
					+"<div id='app6_"+carList.data[i].id+"'><b>油耗：</b>"+carList.data[i].positionLast.oilMN1+" L</br></div>"
					+"<div id='app7_"+carList.data[i].id+"'><b>当日里程：</b>"+carList.data[i].positionLast.distance+" km</br></div>"
					+"<div id='app8_"+carList.data[i].id+"'><b>总里程：</b>"+carList.data[i].positionLast.totalDistance+" km</br></div>"
					+"<div id='app9_"+carList.data[i].id+"'><b>状态：</b>"+carList.data[i].positionLast.state2+"</br></div>"
					+"<div id='app10_"+carList.data[i].id+"'><b>位置：</b>"+carList.data[i].positionLast.memo+"</br></div>"
					+"<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 id='more_"+carList.data[i].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
					//alert(html);
				    
				    var icon_size=real(carList.data[i].icon);
				    var myIcon = new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size));
	    			var marker = new BMap.Marker(
	    					myLatlng
	    					,{icon:myIcon}
	    			);  // 创建标注
	    			//baidMap.addOverlay(marker);
	    			
	    			
	    			/*var opts = {
					  position : myLatlng,    // 指定文本标注所在的地理位置
					  offset   : new BMap.Size(10, -10)    //设置文本偏移量
					 
					}
					var label = new BMap.Label(carList.data[i].vhcCode, opts);  // 创建文本标注对象
					label.setStyle({
						 color : "#000000",
						 backgroundColor : "#f5fcb8",
						 borderColor : "#000000",
						 fontSize : "12px",
						 height : "16px",
						 lineHeight : "16px",
						 fontWeight:"bold",
						 fontFamily:""
					});
					
					if( namekg == false ){
						baidMap.addOverlay(label);
					}*/
					//baidMap.addOverlay(label); 
	    			//创建信息窗口
	    			var infoWindow = new BMap.InfoWindow(html);
	    			marker.addEventListener("click", function(){
	    				this.openInfoWindow(infoWindow);
	    				document.getElementById('weizhi').innerHTML = carList.data[x].vhcCode+"： " + carList.data[x].positionLast.memo;
						document.getElementById('weizhi').title = carList.data[x].vhcCode+"： " + carList.data[x].positionLast.memo;
						msgid= carList.data[x].id;
						msgname= carList.data[x].vhcCode;
						
						var WinShowParms = getCurUserWinShowParms();
						if(WinShowParms!=null){
							
							var app1_ = document.getElementById("app1_"+carList.data[x].id);
							if(app1_ != null){
								app1_.style.display ="none";
								var app2_ = document.getElementById("app2_"+carList.data[x].id);
								app2_.style.display ="none";
								var app3_ = document.getElementById("app3_"+carList.data[x].id);
								app3_.style.display ="none";
								var app4_ = document.getElementById("app4_"+carList.data[x].id);
								app4_.style.display ="none";
								var app5_ = document.getElementById("app5_"+carList.data[x].id);
								app5_.style.display ="none";
								var app6_ = document.getElementById("app6_"+carList.data[x].id);
								app6_.style.display ="none";
								var app7_ = document.getElementById("app7_"+carList.data[x].id);
								app7_.style.display ="none";
								var app8_ = document.getElementById("app8_"+carList.data[x].id);
								app8_.style.display ="none";
								var app9_ = document.getElementById("app9_"+carList.data[x].id);
								app9_.style.display ="none";
								var app10_ = document.getElementById("app10_"+carList.data[x].id);
								app10_.style.display ="none";
								var app11_ = document.getElementById("app11_"+carList.data[x].id);
								app11_.style.display ="none";
								
								for(var ws=0;ws<WinShowParms.length;ws++){
						      		if(WinShowParms[ws]==1){
						      			app1_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==2){
						      			app2_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==3){
						      			app3_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==4){
						      			app4_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==5){
						      			app5_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==6){
						      			app6_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==7){
						      			app7_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==8){
						      			app8_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==9){
						      			app9_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==10){
						      			app10_.style.display ="block";
						      		}
						      		if(WinShowParms[ws]==11){
						      			app11_.style.display ="block";
						      		}
						      	}
						      	var app_ = document.getElementById("app_"+carList.data[x].id).innerHTML;
						      	app_="<div id='app_"+carList.data[x].id+"' style='font-weight:normal;'>"+app_+"</div>"
						      	infoWindow.setContent(app_);
								
							}
							
						}
	    			});
	    			
	    			var markerManage = new Object();
	    			markerManage.id = carList.data[i].id;
	    			markerManage.vhcCode = carList.data[i].vhcCode;
	    			markerManage.label = label;
	    			markerManage.marker = marker;
	    			markerManage.icon = carList.data[i].icon;
	    			markerManage.infowindow = infoWindow;
	    			markerManage.latlng = myLatlng;
	    			markers.push(markerManage);
	    			
	    			markersArray.push(marker);
	    		
				//}
			}
		})(i);
    }
	var markerClusterer = new BMapLib.MarkerClusterer(baidMap, {markers:markersArray});

	markerClusterer.setMaxZoom(10);
	if(strNum+3000<=carList.data.length){
		    
			strNum=j+3000;
			setTimeout("addMarkers("+(strNum-3000)+","+strNum+")",100);
			
	}else{
			strNum=j;
			if(strNum<carList.data.length){
				var tNum = strNum;
				strNum=carList.data.length;
				setTimeout("addMarkers("+tNum+","+(carList.data.length)+")",100);
				
			}else{
				if(alSwitch == false){
		  			countDown();    //每隔15秒执行函数al
		  			alSwitch = true;
		  			strNum=0;
		  		}
			}
	}
	
}
function baiduMap(ids,bool){
	//setT=setTimeout("MapData()",100);
  
	if(ids == ""){
		 setTimeout("baiduMap(ids)",5000);
	}else if(ids == "-1"){
		 baidMap = new BMap.Map("map_canvas");      // 创建地图实例    
		 var point = new BMap.Point(116.404, 39.915);  // 创建点坐标
		 baidMap.centerAndZoom(point, 15);
	}else if(ids == "thresholds"){
		 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 frequency = 0;
		//alert(frequency+10+"   "+carList.data.length)
		if(carList !="null" && carList!="" && carList!= null){
			if(frequency+3000<=carList.data.length){
					strNum=0;
					setTimeout("addMarkers("+frequency+","+(frequency+3000)+")",500);
			}else{
					setTimeout("addMarkers("+frequency+","+(carList.data.length)+")",500);
				//addMarkers(i,carList.data.length);
			}
		}
	}else{
		var obj = getUserStatus();
		
  		if(obj==null){
  			var lat=0,lng=0;
  			for(i=0;i<carList.data.length;i++){
  	  			if(carList.data[i].positionLast.blat != 0 &&carList.data[i].positionLast.blng != 0){
  	  				lat = carList.data[i].positionLast.blat;
  	  				lng = carList.data[i].positionLast.blng;
  	  				break;
  	  			}
  	  		}
  			baidMap = new BMap.Map("map_canvas");      // 创建地图实例    
  			var point = new BMap.Point(lng,lat);
  			if(lat==0 && lng==0){
  				baidMap.centerAndZoom(new BMap.Point(116.404, 39.915), 15);
  			}else{
  				baidMap.centerAndZoom(point, 15);
  			}
  		}else{
  			var zoom;
  			if(bool == true){
  				if(obj.bzoom == "" || obj.bzoom==null){
      				zoom=6;
      			}else{
      				zoom=obj.bzoom;
      			}
  			}else{
  				if(obj.gzoom == "" || obj.gzoom==null){
      				zoom=6;
      			}else{
      				zoom=obj.gzoom+1;
      			}
  			}
  			baidMap = new BMap.Map("map_canvas");      // 创建地图实例    
  			var point = new BMap.Point(obj.lng,obj.lat);
  			baidMap.centerAndZoom(point,zoom);
  			if(bool == true){
  				addMenu();
  			}
  		}
		
	    idsData=ids;
		closeMask();
		  // 创建点坐标
		// 初始化地图，设置中心点坐标和地图级别
		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 frequency = 0;
		//alert(frequency+10+"   "+carList.data.length)
		
		if(frequency+3000<=carList.data.length){
				strNum=0;
				setTimeout("addMarkers("+frequency+","+(frequency+3000)+")",500);
		}else{
				setTimeout("addMarkers("+frequency+","+(carList.data.length)+")",500);
			//addMarkers(i,carList.data.length);
		}
		/*
		for(var i=0;i<carList.data.length;i++){
			frequency++;
			if(i+10<=carList.data.length){
				if(i==0){
					setTimeout("addMarkers("+i+","+(i+10)+")",500);
				}else{
					setTimeout("addMarkers("+i+","+(i+10)+")",500+frequency*100);
				}
			}else{
					setTimeout("addMarkers("+i+","+(carList.data.length)+")",500+frequency*100);
				//addMarkers(i,carList.data.length);
			}
			i=i+10;
			alert(frequency);
		}
		if(alSwitch == false){
  			//countDown();    //每隔15秒执行函数al
  			alSwitch = true;
  		}else{
  			//alSwitch = false;
  		}	*/
		
		//showCarName();
	}
	var yanchiAl;
	baidMap.addEventListener("dragend", function showInfo(){
		clearTimeout(yanchiAl);
    	yanchiAl=setTimeout("al()",500);
	});
	if(baidubool == false){
		addMenu();
	}
}
function updateBaiduMap(){
	for(var i=0;i<newdata.data.length;i++){
		for(var k=0;k<markers.length;k++){
			if(newdata.data[i].vehicleId == markers[k].id){
				if(msgid== newdata.data[i].vehicleId){
					document.getElementById('weizhi').innerHTML = msgname+"： " + newdata.data[i].memo;
					document.getElementById('weizhi').title = msgname+"： " + newdata.data[i].memo;
				}
				var myLatlng = new BMap.Point(newdata.data[i].blng,newdata.data[i].blat);
				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();
			//alert(newtime-oldtime);
			if(newtime-oldtime > 600000){
				s=2;
			}
		  	
		  	
		  
		  	var state =s;  
		  	
			
		  	var pngicon = "gpsonline/image/pic/"+markers[k].icon+"/red_0.gif";
			if(state == 0) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/green_";
			else if(state == 1) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/red_";
			else if(state == 2) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/gray_";
			else if(state == 3) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/yellow_";
			else if(state == 4) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/pink_";
			else if(state == 5) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/stopalarm";
			else if(state == 7) pngicon = "gpsonline/image/pic/"+markers[k].icon+"/blue_";
			else pngicon = "gpsonline/image/pic/"+markers[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 b = new Base64();  
					//	var carname = b.encode(markers[k].vhcCode);  
						var carname = encodeURI(encodeURI(markers[k].vhcCode)); 
						/*var html = "<div style='font-weight:normal;'><b>设备名称：</b>"+markers[k].vhcCode+"</br>"
											+"<b>接收时间：</b>"+newdata.data[i].recvtime+"</br>"
											+"<b>速度：</b>"+newdata.data[i].speed.toFixed(1)+"km/h </br>"
											+"<b>方向：</b>"+direction+"</br>"
											+"<b>温度：</b>"+newdata.data[i].temperature+" ℃</br>"
											+"<b>油耗：</b>"+newdata.data[i].oilMN1+" L</br>"
											+"<b>状态：</b>"+newdata.data[i].state2+"</br>"
											+"<b>位置：</b>"+newdata.data[i].memo+"</br>"
											+"<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="+markers[k].id+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+markers[k].id+"&carname="+carname+"&icon="+markers[k].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font>  |</a>  <a id='more_"+markers[k].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼ </font></a></div>";   
						*/ var html =	"<div id='app_"+newdata.data[i].vehicleId+"' style='font-weight:normal;'>"
							    +"<div id='app1_"+newdata.data[i].vehicleId+"'><b>设备名称：</b>"+markers[k].vhcCode+"</br></div>"
							    +"<div id='app11_"+newdata.data[i].vehicleId+"'><b>SIM卡号：</b>"+markers[k].simCode+"</br></div>"
								+"<div id='app2_"+newdata.data[i].vehicleId+"'><b>接收时间：</b>"+newdata.data[i].recvtime+"</br></div>"
								+"<div id='app3_"+newdata.data[i].vehicleId+"'><b>速度：</b>"+newdata.data[i].speed.toFixed(1)+"km/h </br></div>"
								+"<div id='app4_"+newdata.data[i].vehicleId+"'><b>方向：</b>"+direction+"</br></div>"
								+"<div id='app5_"+newdata.data[i].vehicleId+"'><b>温度：</b>"+newdata.data[i].temperature+" ℃</br></div>"
								+"<div id='app6_"+newdata.data[i].vehicleId+"'><b>油耗：</b>"+newdata.data[i].oilMN1+" L</br></div>"
								+"<div id='app7_"+newdata.data[i].vehicleId+"'><b>当前里程：</b>"+newdata.data[i].distance+" km</br></div>"
								+"<div id='app8_"+newdata.data[i].vehicleId+"'><b>总里程：</b>"+newdata.data[i].totalDistance+" km</br></div>"
								+"<div id='app9_"+newdata.data[i].vehicleId+"'><b>状态：</b>"+newdata.data[i].state2+"</br></div>"
								+"<div id='app10_"+newdata.data[i].vehicleId+"'><b>位置：</b>"+newdata.data[i].memo+"</br></div>"
								+"<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="+markers[k].id+"&mapType=1' target='_blank'><font color='#0000FF'>跟踪</font> | </a><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+markers[k].id+"&carname="+carname+"&icon="+markers[k].icon+"&mapType=1' target='_blank'><font color='#0000FF'>回放</font>  |</a>  <a id='more_"+markers[k].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼ </font></a></div>";   
								
						markers[k].latlng=myLatlng;
						
						var icon_size=real(markers[k].icon);
						markers[k].marker.setIcon(new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size)));
						
						markers[k].infowindow.setContent(html);
						
						var WinShowParms = getCurUserWinShowParms();
						
						if(WinShowParms!=null){
							
							var app1_ = document.getElementById("app1_"+newdata.data[i].vehicleId);
								if(app1_ != null){
									app1_.style.display ="none";
									var app2_ = document.getElementById("app2_"+newdata.data[i].vehicleId);
									app2_.style.display ="none";
									var app3_ = document.getElementById("app3_"+newdata.data[i].vehicleId);
									app3_.style.display ="none";
									var app4_ = document.getElementById("app4_"+newdata.data[i].vehicleId);
									app4_.style.display ="none";
									var app5_ = document.getElementById("app5_"+newdata.data[i].vehicleId);
									app5_.style.display ="none";
									var app6_ = document.getElementById("app6_"+newdata.data[i].vehicleId);
									app6_.style.display ="none";
									var app7_ = document.getElementById("app7_"+newdata.data[i].vehicleId);
									app7_.style.display ="none";
									var app8_ = document.getElementById("app8_"+newdata.data[i].vehicleId);
									app8_.style.display ="none";
									var app9_ = document.getElementById("app9_"+newdata.data[i].vehicleId);
									app9_.style.display ="none";
									var app10_ = document.getElementById("app10_"+newdata.data[i].vehicleId);
									app10_.style.display ="none";
									var app11_ = document.getElementById("app11_"+newdata.data[i].vehicleId);
									app11_.style.display ="none";
									
									for(var ws=0;ws<WinShowParms.length;ws++){
							      		if(WinShowParms[ws]==1){
							      			app1_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==2){
							      			app2_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==3){
							      			app3_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==4){
							      			app4_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==5){
							      			app5_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==6){
							      			app6_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==7){
							      			app7_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==8){
							      			app8_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==9){
							      			app9_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==10){
							      			app10_.style.display ="block";
							      		}
							      		if(WinShowParms[ws]==11){
							      			app11_.style.display ="block";
							      		}
							      	}
							      	var app_ = document.getElementById("app_"+newdata.data[i].vehicleId).innerHTML;;
							      	app_="<div id='app_"+newdata.data[i].vehicleId+"' style='font-weight:normal;'>"+app_+"</div>"
							      	markers[k].infowindow.setContent(app_);
								}
							
			    			}
					
						markers[k].label.setContent(markers[k].vhcCode);
						if( newdata.data[i].blat != 0 && newdata.data[i].blng !=0){
							
							markers[k].marker.setPosition(myLatlng);	
							markers[k].infowindow.setPosition(myLatlng);
							markers[k].label.setPosition(myLatlng);
							
						}
						if(namekg == true){
							baidMap.removeOverlay(markers[k].label);
						}	
			}
		}
	}
	
}
function centerBaiduMap(data,db) {
	/*for(var j=0;j<markers.length;j++){
		markers[j].infowindow.close();
	}*/
	msgid=data.data[0].id;
	msgname= data.data[0].vhcCode;
	if(isLargeData==true){
		if(markers.length>0){
			for(var k=0;k<markers.length;k++){
				if(data.data[0].id == markers[k].id){
					msgid= data.data[0].id;
					
					isUpdate = true;
					var myLatlng = new BMap.Point(data.data[0].positionLast.blng,data.data[0].positionLast.blat);
					
					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 b = new Base64();  
		  		//	var carname = b.encode(data.data[0].vhcCode); 
		  			var carname = encodeURI(encodeURI(data.data[0].vhcCode)); 
				  /*  var html =	"<div style='font-weight:normal;'><b>设备名称：</b>"+data.data[0].vhcCode+"</br>"
					+"<b>接收时间：</b>"+data.data[0].positionLast.recvtime+"</br>"
					+"<b>速度：</b>"+data.data[0].positionLast.speed.toFixed(1)+"km/h </br>"
					+"<b>方向：</b>"+direction+"</br>"
					+"<b>温度：</b>"+data.data[0].positionLast.temperature+" ℃</br>"
					+"<b>油耗：</b>"+data.data[0].positionLast.oilMN1+" L</br>"
					+"<b>状态：</b>"+data.data[0].positionLast.state2+"</br>"
					+"<b>位置：</b>"+data.data[0].positionLast.memo+"</br>"
					+"<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><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[0].id+"&carname="+carname+"&icon="+data.data[0].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[0].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
				  */
				    var html =	"<div id='app_"+data.data[0].id+"' style='font-weight:normal;'>"
					    +"<div id='app1_"+data.data[0].id+"'><b>设备名称：</b>"+data.data[0].vhcCode+"</br></div>"
					    +"<div id='app11_"+data.data[0].id+"'><b>SIM卡号：</b>"+data.data[0].simCode+"</br></div>"
						+"<div id='app2_"+data.data[0].id+"'><b>接收时间：</b>"+data.data[0].positionLast.recvtime+"</br></div>"
						+"<div id='app3_"+data.data[0].id+"'><b>速度：</b>"+data.data[0].positionLast.speed.toFixed(1)+"km/h </br></div>"
						+"<div id='app4_"+data.data[0].id+"'><b>方向：</b>"+direction+"</br></div>"
						+"<div id='app5_"+data.data[0].id+"'><b>温度：</b>"+data.data[0].positionLast.temperature+" ℃</br></div>"
						+"<div id='app6_"+data.data[0].id+"'><b>油耗：</b>"+data.data[0].positionLast.oilMN1+" L</br></div>"
						+"<div id='app7_"+data.data[0].id+"'><b>当日里程：</b>"+data.data[0].positionLast.distance+" km</br></div>"
						+"<div id='app8_"+data.data[0].id+"'><b>总里程：</b>"+data.data[0].positionLast.totalDistance+" km</br></div>"
						+"<div id='app9_"+data.data[0].id+"'><b>状态：</b>"+data.data[0].positionLast.state2+"</br></div>"
						+"<div id='app10_"+data.data[0].id+"'><b>位置：</b>"+data.data[0].positionLast.memo+"</br></div>"
						+"<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><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[0].id+"&carname="+carname+"&icon="+data.data[0].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[0].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
						
				    var icon_size=real(data.data[0].icon);
					markers[k].marker.setIcon(new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size)));
					markers[k].infowindow.setContent(html);
					
					markers[k].label.setContent(markers[k].vhcCode);
					if(namekg == true){
						baidMap.removeOverlay(markers[k].label);
					}
					
					if(data.data[0].positionLast.blng != 0 && data.data[0].positionLast.blat != 0){
						markers[k].latlng=myLatlng;
						markers[k].marker.setPosition(myLatlng);	
						markers[k].infowindow.setPosition(myLatlng);
						markers[k].label.setPosition(myLatlng);
					}
					markers[k].marker.openInfoWindow(markers[k].infowindow);
					var WinShowParms = getCurUserWinShowParms();
					if(WinShowParms!=null){
						var app1_ = document.getElementById("app1_"+data.data[0].id);
						app1_.style.display ="none";
						var app2_ = document.getElementById("app2_"+data.data[0].id);
						app2_.style.display ="none";
						var app3_ = document.getElementById("app3_"+data.data[0].id);
						app3_.style.display ="none";
						var app4_ = document.getElementById("app4_"+data.data[0].id);
						app4_.style.display ="none";
						var app5_ = document.getElementById("app5_"+data.data[0].id);
						app5_.style.display ="none";
						var app6_ = document.getElementById("app6_"+data.data[0].id);
						app6_.style.display ="none";
						var app7_ = document.getElementById("app7_"+data.data[0].id);
						app7_.style.display ="none";
						var app8_ = document.getElementById("app8_"+data.data[0].id);
						app8_.style.display ="none";
						var app9_ = document.getElementById("app9_"+data.data[0].id);
						app9_.style.display ="none";
						var app10_ = document.getElementById("app10_"+data.data[0].id);
						app10_.style.display ="none";
						var app11_ = document.getElementById("app11_"+data.data[0].id);
						app11_.style.display ="none";
						
						for(var ws=0;ws<WinShowParms.length;ws++){
				      		if(WinShowParms[ws]==1){
				      			app1_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==2){
				      			app2_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==3){
				      			app3_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==4){
				      			app4_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==5){
				      			app5_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==6){
				      			app6_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==7){
				      			app7_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==8){
				      			app8_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==9){
				      			app9_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==10){
				      			app10_.style.display ="block";
				      		}
				      		if(WinShowParms[ws]==11){
				      			app11_.style.display ="block";
				      		}
				      	}
				      	var app_ = document.getElementById("app_"+data.data[0].id).innerHTML;
				    	app_="<div id='app_"+data.data[0].id+"' style='font-weight:normal;'>"+app_+"</div>"
				      	markers[k].infowindow.setContent(app_);
				      	//infoWindow.setContent(app_);
					}
					
					document.getElementById('weizhi').innerHTML = data.data[0].vhcCode+"： " + data.data[0].positionLast.memo;
					document.getElementById('weizhi').title = data.data[0].vhcCode+"： " + data.data[0].positionLast.memo;
					msgid= data.data[0].id;
					msgname=data.data[0].vhcCode;
					baidMap.setZoom(13);
							if(db==1){
								baidMap.setCenter(myLatlng);
							}
					
				}
			}
		}
		if(isUpdate==false || markers.length ==0){
			var frequency = 0;
			//carList=data;
			if(frequency+3000<=data.data.length){
					strNum=0;
					setTimeout("addMarkers("+frequency+","+(frequency+3000)+")",0);
			}else{
					addMarkers(carList.data.length-1,carList.data.length);
				
			}
			
			markers[markers.length-1].marker.openInfoWindow(markers[markers.length-1].infowindow);
			document.getElementById('weizhi').innerHTML = carList.data[carList.data.length-1].vhcCode+"： " + carList.data[carList.data.length-1].positionLast.memo;
			document.getElementById('weizhi').title = carList.data[carList.data.length-1].vhcCode+"： " + carList.data[carList.data.length-1].positionLast.memo;
			baidMap.setZoom(13);
					if(db==1){
						baidMap.setCenter(myLatlng);
					}
			
		}
	}else{
		for(var k=0;k<markers.length;k++){
			if(data.data[0].id == markers[k].id){
				var myLatlng = new BMap.Point(data.data[0].positionLast.blng,data.data[0].positionLast.blat);
				
				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 b = new Base64();  
	  		//	var carname = b.encode(data.data[0].vhcCode); 
	  			var carname = encodeURI(encodeURI(data.data[0].vhcCode)); 
			   /* var html =	"<div style='font-weight:normal;'><b>设备名称：</b>"+data.data[0].vhcCode+"</br>"
				+"<b>接收时间：</b>"+data.data[0].positionLast.recvtime+"</br>"
				+"<b>速度：</b>"+data.data[0].positionLast.speed.toFixed(1)+"km/h </br>"
				+"<b>方向：</b>"+direction+"</br>"
				+"<b>温度：</b>"+data.data[0].positionLast.temperature+" ℃</br>"
				+"<b>油耗：</b>"+data.data[0].positionLast.oilMN1+" L</br>"
				+"<b>状态：</b>"+data.data[0].positionLast.state2+"</br>"
				+"<b>位置：</b>"+data.data[0].positionLast.memo+"</br>"
				+"<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><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[0].id+"&carname="+carname+"&icon="+data.data[0].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[0].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
			   */
	  			var html =	"<div id='app_"+data.data[0].id+"' style='font-weight:normal;'>"
				    +"<div id='app1_"+data.data[0].id+"'><b>设备名称：</b>"+data.data[0].vhcCode+"</br></div>"
				    +"<div id='app11_"+data.data[0].id+"'><b>SIM卡号：</b>"+data.data[0].simCode+"</br></div>"
					+"<div id='app2_"+data.data[0].id+"'><b>接收时间：</b>"+data.data[0].positionLast.recvtime+"</br></div>"
					+"<div id='app3_"+data.data[0].id+"'><b>速度：</b>"+data.data[0].positionLast.speed.toFixed(1)+"km/h </br></div>"
					+"<div id='app4_"+data.data[0].id+"'><b>方向：</b>"+direction+"</br></div>"
					+"<div id='app5_"+data.data[0].id+"'><b>温度：</b>"+data.data[0].positionLast.temperature+" ℃</br></div>"
					+"<div id='app6_"+data.data[0].id+"'><b>油耗：</b>"+data.data[0].positionLast.oilMN1+" L</br></div>"
					+"<div id='app7_"+data.data[0].id+"'><b>当日里程：</b>"+data.data[0].positionLast.distance+" km</br></div>"
					+"<div id='app8_"+data.data[0].id+"'><b>总里程：</b>"+data.data[0].positionLast.totalDistance+" km</br></div>"
					+"<div id='app9_"+data.data[0].id+"'><b>状态：</b>"+data.data[0].positionLast.state2+"</br></div>"
					+"<div id='app10_"+data.data[0].id+"'><b>位置：</b>"+data.data[0].positionLast.memo+"</br></div>"
					+"<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><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[0].id+"&carname="+carname+"&icon="+data.data[0].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[0].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></div>";
					 
	  			var icon_size=real(data.data[0].icon);
				markers[k].marker.setIcon(new BMap.Icon(pngicon+image, new BMap.Size(icon_size,icon_size)));
				markers[k].infowindow.setContent(html);
			
				markers[k].label.setContent(markers[k].vhcCode);
				if(namekg == true){
					baidMap.removeOverlay(markers[k].label);
				}
				markers[k].marker.openInfoWindow(markers[k].infowindow);
				
				markers[k].marker.openInfoWindow(markers[k].infowindow);
				var WinShowParms = getCurUserWinShowParms();
				if(WinShowParms!=null){
					var app1_ = document.getElementById("app1_"+data.data[0].id);
					app1_.style.display ="none";
					var app2_ = document.getElementById("app2_"+data.data[0].id);
					app2_.style.display ="none";
					var app3_ = document.getElementById("app3_"+data.data[0].id);
					app3_.style.display ="none";
					var app4_ = document.getElementById("app4_"+data.data[0].id);
					app4_.style.display ="none";
					var app5_ = document.getElementById("app5_"+data.data[0].id);
					app5_.style.display ="none";
					var app6_ = document.getElementById("app6_"+data.data[0].id);
					app6_.style.display ="none";
					var app7_ = document.getElementById("app7_"+data.data[0].id);
					app7_.style.display ="none";
					var app8_ = document.getElementById("app8_"+data.data[0].id);
					app8_.style.display ="none";
					var app9_ = document.getElementById("app9_"+data.data[0].id);
					app9_.style.display ="none";
					var app10_ = document.getElementById("app10_"+data.data[0].id);
					app10_.style.display ="none";
					var app11_ = document.getElementById("app11_"+data.data[0].id);
					app11_.style.display ="none";
					
					for(var ws=0;ws<WinShowParms.length;ws++){
			      		if(WinShowParms[ws]==1){
			      			app1_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==2){
			      			app2_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==3){
			      			app3_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==4){
			      			app4_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==5){
			      			app5_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==6){
			      			app6_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==7){
			      			app7_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==8){
			      			app8_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==9){
			      			app9_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==10){
			      			app10_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==11){
			      			app11_.style.display ="block";
			      		}
			      	}
					var app_ = document.getElementById("app_"+data.data[0].id).innerHTML;
			    	app_="<div id='app_"+data.data[0].id+"' style='font-weight:normal;'>"+app_+"</div>"
			      	markers[k].infowindow.setContent(app_);
			      	//infoWindow.setContent(app_);
				}
				
				document.getElementById('weizhi').innerHTML = data.data[0].vhcCode+"： " + data.data[0].positionLast.memo;
				document.getElementById('weizhi').title = data.data[0].vhcCode+"： " + data.data[0].positionLast.memo;
				baidMap.setZoom(13);
				if(data.data[0].positionLast.blng != 0 && data.data[0].positionLast.blat != 0){
					 markers[k].latlng=myLatlng;
						markers[k].marker.setPosition(myLatlng);		
						markers[k].infowindow.setPosition(myLatlng);
						markers[k].label.setPosition(myLatlng);
				}
						if(db==1){
							baidMap.setCenter(myLatlng);
						}
				
			}
		}
	}
}
function googleMap(){
		var data =carList;
		var lat = 0;
		var lng = 0;
		if(carList != "null" && carList!="" && carList!= null){
			if(data.flag==true){
	      		for(i=0;i<data.data.length;i++){
	      			if(data.data[i].positionLast.lat != 0 &&data.data[i].positionLast.lng != 0){
	      				lat = data.data[i].positionLast.lat;
	      				lng = data.data[i].positionLast.lng;
	      				break;
	      			}
	      		}
	      		if(lat==null && lng ==null){
		      		var mapOptions = {
				          center: new google.maps.LatLng(31.23, 121.47),
				          zoom: 4,
				          mapTypeId: google.maps.MapTypeId.ROADMAP,
				          mapTypeControlOptions: {
									                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, "MAPabc"]
									                }
						     };
				        	 map = new google.maps.Map(document.getElementById("map_canvas"),
				                mapOptions);
				             addMAPabc(map);
				             var geocoder = new google.maps.Geocoder(); 
						    geocoder.geocode( { 'address': remote_ip_info.city}, function(results, status) { 
						      if (status == google.maps.GeocoderStatus.OK) { 
						      	 map.setCenter(results[0].geometry.location);
						      	 map.setZoom(8);
						      } else { 
						        //alert("Geocode was not successful for the following reason: " + status); 
						      } 
		    				}); 
	      		}else{
		      		if(alSwitch == false){
		      			countDown();    //每隔15秒执行函数al
		      			alSwitch = true;
		      		}
	      		var obj = getUserStatus();
	      		if(obj==null){
	      			mapOptions = {
			          center: new google.maps.LatLng(lat,lng),
			          zoom: 10,
			          mapTypeId: google.maps.MapTypeId.ROADMAP,
				          mapTypeControlOptions: {
									                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, "MAPabc"]
									                }
		       		};
	      		}else{
	      			var zoom;
	      			
	      			if(obj.bzoom == "" || obj.bzoom==null){
	          				zoom=6;
	          		}else{
	          				zoom=obj.bzoom-1;
	          		}
	      			
	      			mapOptions = {
			          center: new google.maps.LatLng(obj.lat,obj.lng),
			          zoom: zoom,
			          mapTypeId: google.maps.MapTypeId.ROADMAP,
				          mapTypeControlOptions: {
									                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, "MAPabc"]
									                }
		       		};
	      		}
	      		
		        map = new google.maps.Map(document.getElementById("map_canvas"),
		            mapOptions);
		            addMAPabc(map);
		         
		        for(i=0;i<data.data.length;i++){
		    		(function(x){
		    		var myLatlng = new google.maps.LatLng(data.data[x].positionLast.lat,data.data[x].positionLast.lng);
						
					var s=10;
					var condition=data.data[x].positionLast.state2;
				  	var sp = parseInt(data.data[x].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[i].positionLast.av == 0 ){
						s=7;
					}
				var newtime = new Date().getTime();
							var ttime =data.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/"+data.data[x].icon+"/red_0.gif";
				if(state == 0) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/green_";
				else if(state == 1) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/red_";
				else if(state == 2) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/gray_";
				else if(state == 3) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/yellow_";
				else if(state == 4) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/pink_";
				else if(state == 5) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/stopalarm";
				else if(state == 7) pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/blue_";
				else pngicon = "gpsonline/image/pic/"+data.data[x].icon+"/red_";
						 var direction="";
						 var t = parseInt(data.data[x].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 icon_size=real(data.data[x].icon);
					    var marker = new google.maps.Marker({
						      position: myLatlng,
						      map: map,
						      icon: new google.maps.MarkerImage(pngicon+image, new google.maps.Size(icon_size, icon_size),new google.maps.Point(0,0),new google.maps.Point(10, 10)),
						      title:data.data[x].vhcCode
						});
						//var b = new Base64();  
	    			//	var carname = b.encode(data.data[x].vhcCode);  
	    				var carname = encodeURI(encodeURI(data.data[x].vhcCode)); 
						markersArray.push(marker);
						/*var boxText = document.createElement("div");
						//var carname = encodeURI(URIstring);
						boxText.className = "map_tanchu_wrap";
						boxText.innerHTML = "<b class='xtop'>" +
										    	"<b class='xb1'></b>" +
										        "<b class='xb2'></b>" +
										        "<b class='xb3'></b>" +
										        "<b class='xb4'></b>" +
										    "</b>" +
										    "<div class='xboxcontent'><p>" +
											"<b>设备名称：</b>"+data.data[x].vhcCode+"</br>"
											+"<b>接收时间：</b>"+data.data[x].positionLast.recvtime+"</br>"
											+"<b>速度：</b>"+data.data[x].positionLast.speed+"km/h </br>"
											+"<b>方向：</b>"+direction+"</br>"
											+"<b>温度：</b>"+data.data[x].positionLast.temperature+" ℃</br>"
											+"<b>油耗：</b>"+data.data[x].positionLast.oilMN1+" L</br>"
											+"<b>状态：</b>"+data.data[x].positionLast.state2+"</br>"
											+"<b>位置：</b>"+data.data[x].positionLast.memo+"</br>"
											+"<a href='javascript:streeViewObject.open("+data.data[x].id+","+data.data[x].positionLast.lat+","+data.data[x].positionLast.lng+","+t+","+5+");'><font color='#0000FF'>街景</font> | </a><a href='gpsonline/jsp/TrackMap.jsp?carid="+data.data[x].id+"&mapType=2' target='_blank'><font color='#0000FF'>跟踪</font> | </a><a href='gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[x].id+"&carname="+carname+"&icon="+data.data[x].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[x].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></p></div><b class='xbottom'><b class='xb4'></b><b class='xb3'></b><b class='xb2'></b><b class='xb1'></b></b><span class='arrow_bg'></span><span class='arrow'></span>";
						
						var myOptions = {
							 content: boxText
							,disableAutoPan: false
							,maxWidth: 0
							,pixelOffset: new google.maps.Size(-163, -220)
							,zIndex: null
							,boxStyle: { 
							  // background: "url('tipbox.gif') no-repeat"
							  // background: " no-repeat"
							  //,opacity: 0.75
							  //
							   background: "no-repeat"								  
							   ,width: "430px"
							 }
							,closeBoxMargin: "10px 35px 0px -20px"
							,closeBoxURL: "gpsonline/image/monitor/close.gif"
							,infoBoxClearance: new google.maps.Size(1, 1)
							,isHidden: false
							,pane: "floatPane"
							,enableEventPropagation: false
						};								
						var infowindow = new InfoBox(myOptions);
						google.maps.event.addListener(marker, "click", function (e) {
						 	//alert($(boxText).css("height"));
						 	
						 	markerObject.closeInfowindow();//关闭打开的标注弹出框
					    	if(menu!=null){
					        	menu.hide();
					        }
						 	
						    for(var i=0;i<vehicles.length;i++){
						          vehicles[i].infowindow.close();
						    }					    
							infowindow.open(map, this);
							infowindow.show();
							document.getElementById('weizhi').innerHTML = data.data[x].vhcCode+"： " + data.data[x].positionLast.memo;
							
						});*/
						 var contentString = "<div id='app_"+data.data[x].id+"'><p>"+
							"<div id='app1_"+data.data[x].id+"' style='display:block'><b>设备名称：</b>"+data.data[x].vhcCode+"</br></div>"
							+"<div id='app11_"+data.data[x].id+"' style='display:block'><b>SIM卡号：</b>"+data.data[x].simCode+"</br></div>"
							+"<div id='app2_"+data.data[x].id+"' style='display:block'><b>接收时间：</b>"+data.data[x].positionLast.recvtime+"</br></div>"
							+"<div id='app3_"+data.data[x].id+"' style='display:block'><b>速度：</b>"+data.data[x].positionLast.speed+" km/h </br></div>"
							+"<div id='app4_"+data.data[x].id+"' style='display:block'><b>方向：</b>"+direction+"</br></div>"
							+"<div id='app5_"+data.data[x].id+"' style='display:block'><b>温度：</b>"+data.data[x].positionLast.temperature+" ℃</br></div>"
							+"<div id='app6_"+data.data[x].id+"' style='display:block'><b>油耗：</b>"+data.data[x].positionLast.oilMN1+" L</br></div>"
							+"<div id='app7_"+data.data[x].id+"' style='display:block'><b>当日里程：</b>"+data.data[x].positionLast.distance+" km</br></div>"
							+"<div id='app8_"+data.data[x].id+"' style='display:block'><b>总里程：</b>"+data.data[x].positionLast.totalDistance+" km</br></div>"
							+"<div id='app9_"+data.data[x].id+"' style='display:block'><b>状态：</b>"+data.data[x].positionLast.state2+"</br></div>"
							+"<div id='app10_"+data.data[x].id+"' style='display:block'><b>位置：</b>"+data.data[x].positionLast.memo+"</br></div>"
							+"<a href='javascript:streeViewObject.open("+data.data[x].id+","+data.data[x].positionLast.lat+","+data.data[x].positionLast.lng+","+t+","+5+");'><font color='#0000FF'>街景</font> | </a><a href='"+url+"gpsonline/jsp/TrackMap.jsp?carid="+data.data[x].id+"&mapType=2' target='_blank'><font color='#0000FF'>跟踪</font> | </a><a href='"+url+"gpsonline/jsp/monitor/playBack.jsp?carid="+data.data[x].id+"&carname="+carname+"&icon="+data.data[x].icon+"' target='_blank'><font color='#0000FF'>回放</font> | </a>  <a id='more_"+data.data[x].id+"' href='javascript:;' onclick=\"showSecondMenu(this,event);\"><font color='#0000FF'>更多▼</font></a></p></div>";
		  
	     
		  
		 	//infowindow.setContent(contentString);
		  var infowindow = new google.maps.InfoWindow({
		      content: contentString
		      //,zIndex:10
		  });
		 /* google.maps.event.addListener(marker, 'click', function() {
		    infowindow.open(map,marker);
		  });*/

		  
					
		//var infowindow = new InfoBox(myOptions);
		google.maps.event.addListener(marker, "click", function (e) {
		 	//alert($(boxText).css("height"));
		  //	$("#1_"+data.data[x].id).hide();
		  
		 	markerObject.closeInfowindow();//关闭打开的标注弹出框
	    	
	    	if(menu!=null){
	        	menu.hide();
	        }
		 	
		    for(var i=0;i<vehicles.length;i++){
		          vehicles[i].infowindow.close();
		    }		
		    			    
			infowindow.open(map, this);
			var WinShowParms = getCurUserWinShowParms();
				
			if(WinShowParms!=null){
				var app1_ = document.getElementById("app1_"+data.data[x].id);
				if(app1_ != null){
					app1_.style.display ="none";
					var app2_ = document.getElementById("app2_"+data.data[x].id);
					app2_.style.display ="none";
					var app3_ = document.getElementById("app3_"+data.data[x].id);
					app3_.style.display ="none";
					var app4_ = document.getElementById("app4_"+data.data[x].id);
					app4_.style.display ="none";
					var app5_ = document.getElementById("app5_"+data.data[x].id);
					app5_.style.display ="none";
					var app6_ = document.getElementById("app6_"+data.data[x].id);
					app6_.style.display ="none";
					var app7_ = document.getElementById("app7_"+data.data[x].id);
					app7_.style.display ="none";
					var app8_ = document.getElementById("app8_"+data.data[x].id);
					app8_.style.display ="none";
					var app9_ = document.getElementById("app9_"+data.data[x].id);
					app9_.style.display ="none";
					var app10_ = document.getElementById("app10_"+data.data[x].id);
					app10_.style.display ="none";
					var app11_ = document.getElementById("app11_"+data.data[x].id);
					app11_.style.display ="none";
					
					for(var ws=0;ws<WinShowParms.length;ws++){
			      		if(WinShowParms[ws]==1){
			      			app1_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==2){
			      			app2_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==3){
			      			app3_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==4){
			      			app4_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==5){
			      			app5_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==6){
			      			app6_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==7){
			      			app7_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==8){
			      			app8_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==9){
			      			app9_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==10){
			      			app10_.style.display ="block";
			      		}
			      		if(WinShowParms[ws]==11){
			      			app11_.style.display ="block";
			      		}
			      	}
			      	var app_ = document.getElementById("app_"+data.data[x].id);
					infowindow.setContent(app_);
				}
				
			}
			
			
			
			document.getElementById('weizhi').innerHTML = data.data[x].vhcCode+"： " + data.data[x].positionLast.memo;
			document.getElementById('weizhi').title = data.data[x].vhcCode+"： " + data.data[x].positionLast.memo;
			
			msgid= data.data[x].id;
			msgname= data.data[x].vhcCode;
			
		});
						var vehicle = new Object();
					    vehicle.id = data.data[x].id;
					    vehicle.vhcCode = data.data[x].vhcCode;
						vehicle.label = new LableMarker(map,data.data[x].vhcCode,myLatlng);
						vehicle.label.setMap(null);
						vehicle.marker = marker;
						vehicle.icon = data.data[x].icon;
						vehicle.infowindow = infowindow;
						vehicle.latlng = myLatlng;
						if(data.data[x].positionLast.lat == 0 &&data.data[x].positionLast.lng == 0){
							//vehicle.marker.setMap(null);
							//vehicle.label.setMap(null);
						}
						vehicles.push(vehicle);
		    		})(i);
		         }	
		         }
			 }
		}else{
			var obj = getUserStatus();
		
      		if(obj==null){
      			var mapOptions = {
  			          center: new google.maps.LatLng(31.23, 121.47),
  			          zoom: 4,
  			          mapTypeId: google.maps.MapTypeId.ROADMAP,
  			          mapTypeControlOptions: {
  	                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, "MAPabc"]
  	                }
  			     };
  	        	 map = new google.maps.Map(document.getElementById("map_canvas"),
  	                mapOptions);
  	             addMAPabc(map);
  	             var geocoder = new google.maps.Geocoder(); 
  					    geocoder.geocode( { 'address': remote_ip_info.city}, function(results, status) { 
  					      if (status == google.maps.GeocoderStatus.OK) { 
  					      	 map.setCenter(results[0].geometry.location);
  					      	 map.setZoom(8);
  					      } else { 
  					      
  					      } 
  	    				}); 
      		}else{
      			var zoom;
      			
      			if(obj.bzoom == "" || obj.bzoom==null){
          				zoom=6;
          		}else{
          				zoom=obj.bzoom-1;
          		}
      			
      			var mapOptions = {
		          center: new google.maps.LatLng(obj.lat,obj.lng),
		          zoom: zoom,
		          mapTypeId: google.maps.MapTypeId.ROADMAP,
			          mapTypeControlOptions: {
								                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, "MAPabc"]
								                }
	       		};
      			map = new google.maps.Map(document.getElementById("map_canvas"),
    		            mapOptions);
    		            addMAPabc(map);
      		}	
			
  		}
		 google.maps.event.addListener(map, 'drag', function(){
	        	clearTimeout(yanchiAl);
	        	yanchiAl=setTimeout("al()",500);
	     });
 }
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;
	}
    };
 
 