var currentTaxiPage=1;//当前页数
var totalPage;//总页数

var currentBibyclePage=1;//当前页数
var BibycletotalPage;//总页数
var taxiGPSInfoForLayer;
var taxiGPSInfoForLayerPointer = new Array();
var heatmapOverlay;
var transit;
var driving;
var walking;
var mcircle;
var TempMyPoint;
var TempMyAddress;
var pointcenter;
var lng=120.180335;
var lat=33.38817;
var clickFlag=0;
var add,adds;
var mytilte;
var busline_name;
// 定时刷新出租车图层
function refreashTaxiLayer(){
	if(taxiGPSInfoForLayerPointer.length==0){
		return;
	} else {
		searchTaxi();
	}
}

function isSupportCanvas(){
	var elem = document.createElement('canvas');
	return !!(elem.getContext && elem.getContext('2d'));
}

isCanCanvas=isSupportCanvas();
if(!isCanCanvas){
	$.messager.alert('提示','热力图目前只支持有canvas支持的浏览器,您所使用的浏览器不能使用热力图功能','info');

	
}

// 清除图层及出租车信息
function clearAllLayer() {
	  // 清空数组元素
	  taxiGPSInfoForLayerPointer.splice(0,taxiGPSInfoForLayerPointer.length);
	  map2.clearOverlays();
//	  addMarkerLoc();
}

// 地图比例缩放函数
function findTaxi(e) {
	if(taxiGPSInfoForLayerPointer.length==0){
		return;
	}
	// 绘制车租车图层
	initTaxiLayer(taxiGPSInfoForLayer,taxiGPSInfoForLayerPointer);
}

// 绘制车租车图层
function initTaxiLayer(taxiGPSInfoForLayer, taxiGPSInfoForLayerPointer) {
	//图层上出租车标记移除
	var markers = map2.getOverlays();
	for (var i = 0; i < markers.length; i++) {
		if (markers[i].toString() == "[object Marker]") {
			if (markers[i].markertype == 'taxi') {
				markers[i].remove();
				haveTaxiLayer = true;
			}
		}
	}
	
	//热力图移除
	if(heatmapOverlay){
		heatmapOverlay.remove();
		heatmapOverlay=null;
	}
	
	// 重新创建标记或热力图
	if(map2.getZoom()>=16){
		for(var i=0;i<taxiGPSInfoForLayer.length;i++){
			taxiGPSInfo = taxiGPSInfoForLayer[i];
			var size = new BMap.Size(40,40);
		    var icon1 = new BMap.Icon('assets/images/czc2.png', size);
		    var icon2 = new BMap.Icon('assets/images/czc3.png',size);
		    
		    // 添加图层内各个标记
		    //判断出租车的状态是否空闲
		    if(taxiGPSInfo['sfkx'] == 1){
		    	//使用状态-灰色
		    	var marker2 =new BMap.Marker(new BMap.Point(taxiGPSInfo['jd'], taxiGPSInfo['wd']),{icon:icon2});
		    }else if(taxiGPSInfo['sfkx'] == 0){
		    	//空闲状态-黄色
		    	var marker2 =new BMap.Marker(new BMap.Point(taxiGPSInfo['jd'], taxiGPSInfo['wd']),{icon:icon1});
		    }
		    	
		    marker2.id=taxiGPSInfo['xm'];
		    marker2.markertype='taxi';
		    map2.addOverlay(marker2);
		  	
		  	//组织需要嵌入的HTML字符串表达
		    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
		    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>车牌号："+taxiGPSInfo['xm'];
		    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
		    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
		    contentHTML += "联系电话："+taxiGPSInfo['dh']+"</p>";
		    contentHTML += "</div>";
		    
		    showinfoWindow(marker2,contentHTML);
			
		}
		//显示出租车图例
		$("#taxi_legend").css('display','block');
		
	}else if(isCanCanvas){
		heatmapOverlay = new BMapLib.HeatmapOverlay({"radius":40});
		map2.addOverlay(heatmapOverlay);
		heatmapOverlay.setDataSet({data:taxiGPSInfoForLayerPointer,max:2});
		//隐藏出租车图例
		$("#taxi_legend").css('display','none');
	}
}

function searchTaxi(){
	//从后台获取数据
	$.ajax({
		   type: "POST",
		   url: "getTaxiGPSList.do",
		   dataType : "json",
		   success: function(data){
				  var taxiGPSInfos = data['result'];
				  if(taxiGPSInfos == null || taxiGPSInfos.length == 0){
					  $.messager.alert('提示','没有出租车信息！','info');
					  return;
				  } else {
					  taxiGPSInfoForLayer = taxiGPSInfos;
					  // 清空数组元素
					  taxiGPSInfoForLayerPointer.splice(0,taxiGPSInfoForLayerPointer.length);
				  }
				  $("#menu_taxi").css('display' ,'block');
				  $("#page_22").css('display' ,'block');
				  $("#menu_bicycle").css('display' ,'none');	
				  $("#page_pb").css('display' ,'none');	
				  $("#menu_22").empty();
				  $("#page_22 p").empty();
				  clearAllLayer();
				// 使用标记图层展现出租车的实时位置
				for(var k=0;k<taxiGPSInfos.length;k++){
					var taxiGPSInfo = taxiGPSInfos[k];
					taxiGPSInfoForLayerPointer[k] = new BMap.Point(taxiGPSInfo['jd'],taxiGPSInfo['wd']);
					
				}
				// 绘制车租车图层
				initTaxiLayer(taxiGPSInfoForLayer, taxiGPSInfoForLayerPointer);
				
			 }
		});
}


/*************公共自行车页面的定时刷新功能***2016.12.27**zhangyn*add******************************************************/
//定时刷新公共自行车图层
function refreashBibycleLayer(){
		searchBibycle();
}

//公共自行车的list页面
function searchBibycle(currentBibyclePage){
	$.ajax({
		   type: "POST",
		   url: "table/getBibycleList.do",
		   dataType : "json",
		   success: function(data){
				  var bibycleInfos = data['result'];
				  console.log(bibycleInfos)
				  if(bibycleInfos == null || bibycleInfos.length == 0){
					  $.messager.alert('提示','没有公共自行车信息！','info');
					  return;
				  }
				// 使用标记图层展现公共自行车的实时位置
				  $("#menu_pb").empty();
				  $("#page_pb p").empty();
				  $("#menu_bicycle").css('display' ,'block');
				  $("#page_pb").css('display' ,'block');
				  $("#menu_22").css('display' ,'none');	
				  $("#menu_taxi").css('display' ,'none');	
				  clearAllLayer();
				for(var k=0;k<bibycleInfos.length;k++){
					var bibycleInfo = bibycleInfos[k];
					addDataBycle(bibycleInfo);
				}
			 }
		});
}

function addDataBycle(bibycleInfo)
{  
    var size = new BMap.Size(40,40);
    var icon = new BMap.Icon('assets/images/ggzxc.png', size);
    // 添加图层内各个标记
   var  marker =new BMap.Marker(new BMap.Point(bibycleInfo['longitude'], bibycleInfo['latitude']),{icon:icon}) ;
   marker.id=bibycleInfo['stationName'];
   map2.addOverlay(marker);
  	
  	//组织需要嵌入的HTML字符串表达
    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>"+bibycleInfo['stationName'];
    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "地址："+bibycleInfo['location']+"</p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "最大自行车数："+'<font style="color:#cc5522">'+bibycleInfo['capacity']+'</font>'+" 可借数："+'<font style="color:#cc5522">'+bibycleInfo['availbleBike']+'</font>'+" 可还数："+'<font style="color:#cc5522">'+(bibycleInfo['capacity']-bibycleInfo['availbleBike'])+'</font>'+"</p>";
    contentHTML += "</div>";
    showinfoWindow(marker,contentHTML);
	        
}

/***********指定搜索固定区域内的公共自行车******************************/
function searchBibycleAround(){
	$.ajax({
		   type: "POST",
		   url: "table/getBibycleList.do",
		   dataType : "json",
		   success: function(data){
				  var bibycleInfos = data['result'];
				  if(bibycleInfos == null || bibycleInfos.length == 0){
					  $.messager.alert('提示','没有公共自行车信息！','info');
					  return;
				  }
				  // 使用标记图层展现公共自行车的实时位置
				  $("#menu_pb").empty();
				  $("#page_pb p").empty();
				  $("#menu_bicycle").css('display' ,'block');
				  $("#page_pb").css('display' ,'block');
				  $("#menu_22").css('display' ,'none');	
				  $("#menu_taxi").css('display' ,'none');	
				  clearAllLayer();
				  var index = 0;
				  var myGeo = new BMap.Geocoder();
	  
				  if(typeof(TempMyAddress)!="undefined"){
					  if(add.indexOf("206路")>-1){
							add=TempMyAddress;
						}else{
							TempMyAddress=add;
						}
				  }else{
						TempMyAddress=add;
				  }
				  var mPoint;
				  myGeo.getPoint(add, function(point){
					if (point) {
						mPoint = new BMap.Point(point.lng, point.lat);
						map2.centerAndZoom(mPoint,15);
						
						
						if(typeof(mPoint)!="undefined"){
							TempMyPoint=mPoint;
						}else{
							mPoint=TempMyPoint;
						}
						mcircle=null;
						mcircle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
						 map2.addOverlay(mcircle);
						
						 for(var k=0;k<bibycleInfos.length;k++){
							
							var bibycleInfo = bibycleInfos[k];
							var size = new BMap.Size(40,40);
						    var icon = new BMap.Icon('assets/images/ggzxc.png', size);
						    var lon = bibycleInfo['longitude'];
							var lat = bibycleInfo['latitude'];
							var point = new BMap.Point(lon,lat)
						    var result = BMapLib.GeoUtils.isPointInCircle(point, mcircle);
							
							var marker1;
						    if(result == true){
						     // 添加图层内各个标记
						      marker1 =new BMap.Marker(new BMap.Point(bibycleInfo['longitude'], bibycleInfo['latitude']),{icon:icon}) ;
						      marker1.id=bibycleInfo['stationName'];
						      map2.addOverlay(marker1);
						    //组织需要嵌入的HTML字符串表达
						    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
						    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>"+bibycleInfo['stationName'];
						    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
						    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
						    contentHTML += "地址："+bibycleInfo['location']+"</p>";
						    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
						    contentHTML += "最大自行车数："+'<font style="color:#cc5522">'+bibycleInfo['capacity']+'</font>'+" 可借数："+'<font style="color:#cc5522">'+bibycleInfo['availbleBike']+'</font>'+" 可还数："+'<font style="color:#cc5522">'+(bibycleInfo['capacity']-bibycleInfo['availbleBike'])+'</font>'+"</p>";
						    contentHTML += "</div>";
						    showinfoWindow(marker1,contentHTML);
							    
						    }
							
							}
								 
					}else{ 
						/***************解析不到地址时，用标题和地址一起解析********************/
						var mytilte = $(".BMap_bubble_title p").attr("title");
						add=mytilte+add;
						myGeo.getPoint(add, function(point){
							if (point) {
								mPoint = new BMap.Point(point.lng, point.lat);
								map2.centerAndZoom(mPoint,15);
							}else{ 
							 }  
							if(typeof(mPoint)!="undefined"){
								TempMyPoint=mPoint;
							}else{
								mPoint=TempMyPoint;
							}
							mcircle=null;
							mcircle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
							 map2.addOverlay(mcircle);
							 for(var k=0;k<bibycleInfos.length;k++){
								
								var bibycleInfo = bibycleInfos[k];
								var size = new BMap.Size(40,40);
							    var icon = new BMap.Icon('assets/images/ggzxc.png', size);
							    var lon = bibycleInfo['longitude'];
								var lat = bibycleInfo['latitude'];
								var point = new BMap.Point(lon,lat)
							    var result = BMapLib.GeoUtils.isPointInCircle(point, mcircle);
								var marker1;
							    if(result == true){
							     // 添加图层内各个标记
							      marker1 =new BMap.Marker(new BMap.Point(bibycleInfo['longitude'], bibycleInfo['latitude']),{icon:icon}) ;
							      marker1.id=bibycleInfo['stationName'];
							      map2.addOverlay(marker1);
							    //组织需要嵌入的HTML字符串表达
							    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
							    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>"+bibycleInfo['stationName'];
							    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
							    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
							    contentHTML += "地址："+bibycleInfo['location']+"</p>";
							    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
							    contentHTML += "最大自行车数："+'<font style="color:#cc5522">'+bibycleInfo['capacity']+'</font>'+" 可借数："+'<font style="color:#cc5522">'+bibycleInfo['availbleBike']+'</font>'+" 可还数："+'<font style="color:#cc5522">'+(bibycleInfo['capacity']-bibycleInfo['availbleBike'])+'</font>'+"</p>";
							    contentHTML += "</div>";
							    showinfoWindow(marker1,contentHTML);
								    
							    }
								
							  	
								}
									 
									 
								}, "盐城市");
						/***********************************/
                    }  
					
							 
				 }, "盐城市");
						
			 }
		});

}

/***********************结束*************************************************************/

/**************************************城市公路事件*************************************************/
function searchCityEvent(){
	$.ajax({
		type:"POST",
		url:"getCityEventList.do",
		dataType:"json",
		success:function(data){
			  var cityEventInfos = data['result'];
			  if(cityEventInfos == null || cityEventInfos.length == 0){
				  $.messager.alert('提示','没有城市公路事件信息！','info');
				  return;
			  }
			// 使用标记图层展示城市公路事件的实时位置
			  $("#menu_pb").empty();
			  $("#page_pb p").empty();
			  $("#menu_bicycle").css('display' ,'block');
			  $("#page_pb").css('display' ,'none');
			  $("#menu_22").css('display' ,'none');	
			  $("#menu_taxi").css('display' ,'none');	
			  clearAllLayer();
			for(var k=0;k<cityEventInfos.length;k++){
				var cityEventInfo = cityEventInfos[k];
				addDataCityEvent(cityEventInfo);
			}
		}
	})
}
function addDataCityEvent(cityEventInfo)
{  
    var size = new BMap.Size(40,40);
    var icon = new BMap.Icon('assets/images/cssj.png', size);
    // 添加图层内各个标记
   var  marker =new BMap.Marker(new BMap.Point(cityEventInfo['longitude'], cityEventInfo['latitude']),{icon:icon}) ;
   marker.id=cityEventInfo['id'];
   map2.addOverlay(marker);
  	
  	//组织需要嵌入的HTML字符串表达
    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>"+cityEventInfo['position'];
    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "事件描述："+cityEventInfo['describe']+"</p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "发生时间："+'<font style="color:#cc5522">'+cityEventInfo['time']+'</font>'+"</p>";
    contentHTML += "</div>";
    showinfoWindow(marker,contentHTML);
	        
}

/**************************************高速公路事件*************************************************/
function searchighWay(){
	$.ajax({
		type:"POST",
		url:"getHighWayList.do",
		dataType:"json",
		success:function(data){
			  var highWayInfos = data['result'];
			  if(highWayInfos == null || highWayInfos.length == 0){
				  $.messager.alert('提示','没有高速公路事件信息！','info');
				  return;
			  }
			// 使用标记图层展示城市公路事件的实时位置
			  $("#menu_pb").empty();
			  $("#page_pb p").empty();
			  $("#menu_bicycle").css('display' ,'block');
			  $("#page_pb").css('display' ,'none');
			  $("#menu_22").css('display' ,'none');	
			  $("#menu_taxi").css('display' ,'none');	
			  clearAllLayer();
			for(var k=0;k<highWayInfos.length;k++){
				var highWayInfo = highWayInfos[k];
				addDataHighWay(highWayInfo);
			}
		}
	})
}
function addDataHighWay(highWayInfo)
{  
    var size = new BMap.Size(40,40);
    var icon = new BMap.Icon('assets/images/sj.png', size);
    // 添加图层内各个标记
   var  marker =new BMap.Marker(new BMap.Point(highWayInfo['longitude'], highWayInfo['latitude']),{icon:icon}) ;
   marker.id=highWayInfo['id'];
   map2.addOverlay(marker);
  	
  	//组织需要嵌入的HTML字符串表达
    var contentHTML = "<div style='overflow: hidden; height: auto; line-height: 24px; white-space: nowrap; width: auto;'>";
    contentHTML += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'>"+highWayInfo['position'];
    contentHTML += "<a target='_blank' style='margin-left:5px;font-size:12px;color:#3d6dcc;font-weight:normal;text-decoration:none;'></a></p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "事件描述："+highWayInfo['describe']+"</p>";
    contentHTML += "<p style='margin:0;line-height:1.5;font-size:13px;width: auto; height: auto;'>";
    contentHTML += "发生时间："+'<font style="color:#cc5522">'+highWayInfo['time']+'</font>'+"</p>";
    contentHTML += "</div>";
    showinfoWindow(marker,contentHTML);
	        
}


function searchBus(){
	//获得输入框指定的路线名称，过滤正常的“路字”
	var roadId1= $("#sole-input").val();
	var roadId= roadId1.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'');
	$.ajax({
		type:"POST",
		url:"getSswzList.do",
		dataType:"json",
		data:{"roadId":roadId},
		success:function(data){
			  var busInfos = data['busList'];
			  if(busInfos == null || busInfos.length == 0){
				  return;
			  }
//			  clearAllLayer();必须去掉，因为存在的话会影响公交路线的展示
			for(var k=0;k<busInfos.length;k++){
				var busInfo = busInfos[k];
				addDataBus(busInfo);
			}
			
		}
	})
	
	
	
}

//公交实时位置
function addDataBus(busInfo)
{  
    var size = new BMap.Size(40,40);
    var icon = new BMap.Icon('assets/images/gjsswz.png', size);
    // 添加图层内各个标记
    var marker = new BMap.Marker(new BMap.Point(busInfo['longitude'],busInfo['latitude']),{icon:icon});
   map2.addOverlay(marker);
	        
}

//更换定位图标
//function addMarkerLoc(){  // 创建图标对象     
//	
//	var pointC = new BMap.Point(lng,lat);
//	
//    var myIcon = new BMap.Icon("assets/images/iconLoc.png", new BMap.Size(15, 15), {offset: new BMap.Size(10, 25)});  
//    // 创建标注对象并添加到地图     
//    var marker = new BMap.Marker(pointC, {icon: myIcon});      
//    map2.addOverlay(marker);  
//}


/***************************************/
$(document).ready(function(){
	
	$.messager.singleton={};
	$.messager.singleton.alert=function(m){
		if(m){
			var divObj=$("div[class='panel window messager-window']");
			if(divObj.length){
				$(".messager-body").window('close');
			}
			$.messager.alert('提示',m,'info');
		}
	}	
	$.extend($.messager.defaults,{
        ok:"确定",
        cancel:"取消"
    });
	
	var url = location.search;
	var strs = url.split("?sign=");
	if(strs[1]!=null&&strs[1].length>0)
	{  $('#main').load(strs[1]);  }
	else{
	var $gjzd=$("#gjzd");
	var $csglw=$("#csglw");
	var $cssj=$("#cssj");
	var $gjsswz=$("#gjsswz");
	var $ggtcc=$("#ggtcc");
	var $gjxl=$("#gjxl");
	var $gsglw=$("#gsglw")
	var $gssj=$("#gssj");
	var $ctkyz=$("#ctkyz");
	var $ychcz=$("#ychcz");
	var $nyjc=$("#nyjc");
	var $ldmt=$("#ldmt");
	var $ggzxc=$("#ggzxc");
	var $fwzx=$("#fwzx");
	var $czc=$("#czc");
	var $czzt=$("#czzt");
	var $ggss=$("#ggss");
	var $jqz=$("#jqz");
	var $xlc=$("#xlc");
	var $baidumap2=$("#baidumap2");
	var clicknum="gj";
	var busName;
	var pointA;
	var taxiLayer;

	//公交车实时位置
	var markerArr_gjsswz=[{x:120.239244,y:33.305298,type:'gjsswz'},{x:120.197428,y:33.349815,type:'gjsswz'},{x:120.15916,y:33.392147,type:'gjsswz'}]
	
//	//更换定位图标
//	function addMarkerLoc(){  // 创建图标对象     
//		
//		
//		var pointC = new BMap.Point(lng,lat);
//		
//        var myIcon = new BMap.Icon("assets/images/iconLoc.png", new BMap.Size(15, 15), {offset: new BMap.Size(10, 25)});  
//        // 创建标注对象并添加到地图     
//        var marker = new BMap.Marker(pointC, {icon: myIcon});      
//        map2.addOverlay(marker);  
//    }
//	

	//点击事件弹出需要的图标
	$(".checkbox").click(function(){})
	//公交站点
	$gjzd.click(function(){
	clearAllLayer();
	//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	 var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	 enableAutoPan: false;     //自动平移 
	local.setPageCapacity(10);
	$("#sole-input").val("公交站点");
	var val=$("#sole-input").val().split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		console.log(11111111)
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){
            			
            			
//            			map2.centerAndZoom(new BMap.Point(120.17893,33.390014),14);
            			
            			
            			$(".BMap_pop > div").eq(8).css('top','20')
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			titlenew=title;
            			
            			
            		});
            		
            	})(title);
            }
        }
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  if(spanEle.length>=2){
			if(spanEle.eq(0).text().indexOf("-公交车站")>=0){
				$(this).find("div div b").text("公交:");
			}
		  }
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
		
	});
	local.search(val);
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	//左侧存放panel结果的面板zhangyn 2017.5.26注释
	$("#menu_l1").css('display','block');
	
	
	});
	
//	function setCenter() {
//		map2.centerAndZoom(new BMap.Point(lng,lat),14);
//	}
	
	
	$("#gjzd_detail").click(function(){
		$("#info_gjzd").css('visibility','visible');
	});
	//城市公路事件
	$cssj.click(function(){
	clearAllLayer();
	//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	 var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("城市公路事件");
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
//	$("#menu_l1").css('display','block');
	$("#menu_detail").css('display','block');
	$(".menu_22").css('display','none');
	
	//点击弹出详情页面
	//ajax后台取数据
	searchCityEvent();

	
	});
	//公共停车场
	$ggtcc.click(function(){
	clearAllLayer();
	//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	 var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("停车场");
	var val=$("#sole-input").val().split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){//infowindowopen
            			
            			var index = 0;
            			var myGeo = new BMap.Geocoder();
            			//地址的解析
            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
            			var add = adds[index];
            			//console.log(add)
            			
            			
            			var center_Point;
            			myGeo.getPoint(add, function(point){
            				if (point) {
            					center_Point = new BMap.Point(point.lng, point.lat);
            					
            					if(typeof(center_Point)!="undefined"){
            						TempMyPoint=center_Point;
            					}else{
            						center_Point=TempMyPoint;
            					}
            					
            					//console.log(center_Point)
            					
            					//对地图中心点进行修改
//            					map2.centerAndZoom(center_Point,15);
            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            				    
            				    
            				    
            				}else{
            					var title = [$(".BMap_bubble_title p").text()];
            					add=title[0]+add;
            					myGeo.getPoint(add, function(point){
            						if (point) {
            							center_Point = new BMap.Point(point.lng, point.lat);
            							if(typeof(center_Point)!="undefined"){
            								TempMyPoint=center_Point;
            							}else{
            								center_Point=TempMyPoint;
            							}
            							//对周边进行搜索
            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            						}
            						
            					}, "盐城市");
            				}
            				
            			}, "盐城市");
            			
            			
            			
            			
            			$(".BMap_pop > div").eq(8).css('top','10')
            			var heightCount=25;
            			if($(".BMap_pop > div").eq(8).children()){
            				$(".BMap_pop > div").eq(8).children().each(function(){
            				    heightCount=heightCount+$(this).outerHeight();
            				});
            			}
            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
            			
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2'>最大泊位数:120&nbsp;&nbsp;&nbsp;&nbsp;剩余泊位数:88</td></tr><tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			titlenew=title;
            		});
            		
            		
            	})(title);
            }
        }
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
		
	});
	local.search(val);
	$(".BMap_pop").css('display','none')
	
	
	
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	
	$("#menu_l1").css('display','block');
	$("#ggtcc_detail").click(function(){
		$("#info_ggtcc").css('visibility','visible');
	});
	
	
	});
	//公交线路
	$gjxl.click(function(){});
	//公共交通基础设施
	//加油站
	$ggss.click(function(){
	clearAllLayer();
	//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("加油站");
	var val="加油站".split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){
            			
            			/******************点击标记点或者左侧的列表，以图标为中心点start*****************************/
            			var index = 0;
            			var myGeo = new BMap.Geocoder();
            			//地址的解析
            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
            			var add = adds[index];
            			console.log(add)
            			
            			
            			var center_Point;
            			myGeo.getPoint(add, function(point){
            				if (point) {
            					center_Point = new BMap.Point(point.lng, point.lat);
            					
            					if(typeof(center_Point)!="undefined"){
            						TempMyPoint=center_Point;
            					}else{
            						center_Point=TempMyPoint;
            					}
            					
            					console.log(center_Point)
            					
            					//对地图中心点进行修改
//            					map2.centerAndZoom(center_Point,15);
            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            				    
            				}else{
            					var title = [$(".BMap_bubble_title p").text()];
            					add=title[0]+add;
            					myGeo.getPoint(add, function(point){
            						if (point) {
            							center_Point = new BMap.Point(point.lng, point.lat);
            							if(typeof(center_Point)!="undefined"){
            								TempMyPoint=center_Point;
            							}else{
            								center_Point=TempMyPoint;
            							}
            							//对周边进行搜索
            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            						}
            						
            					}, "盐城市");
            				}
            				
            			}, "盐城市");
            			/******************点击标记点或者左侧的列表，以图标为中心点end*****************************/
            			
            			$(".BMap_pop > div").eq(8).css('top','10')
            			var heightCount=25;
            			if($(".BMap_pop > div").eq(8).children()){
            				$(".BMap_pop > div").eq(8).children().each(function(){
            				    heightCount=heightCount+$(this).outerHeight();
            				});
            			}
            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
            			
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			titlenew=title;
            		});
            		
            	})(title);
            }
        }
		
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
			
	});
	local.search(val);
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','block');
	
	
	
	$("#ggss_detail").click(function(){
		$("#info_ggss").css('visibility','visible');
	});
	
	});
	
	
	
	//加气站
	$jqz.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
		var local = new BMap.LocalSearch(map2, {
			  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
			});
		local.setPageCapacity(10);
		$("#sole-input").val("加气站");
		var val="加气站".split(/[ |,]/);
		local.setMarkersSetCallback(function(result){
			var markers = map2.getOverlays();
			for (var i = 0; i < markers.length; i++) {
	            if (markers[i].toString() == "[object Marker]") {
	            	var title=markers[i].getTitle();
	            	(function(title){
	            		markers[i].addEventListener('infowindowopen', function(){
	            			/******************点击标记点或者左侧的列表，以图标为中心点start*****************************/
	            			var index = 0;
	            			var myGeo = new BMap.Geocoder();
	            			//地址的解析
	            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
	            			var add = adds[index];
	            			console.log(add)
	            			
	            			
	            			var center_Point;
	            			myGeo.getPoint(add, function(point){
	            				if (point) {
	            					center_Point = new BMap.Point(point.lng, point.lat);
	            					
	            					if(typeof(center_Point)!="undefined"){
	            						TempMyPoint=center_Point;
	            					}else{
	            						center_Point=TempMyPoint;
	            					}
	            					
	            					console.log(center_Point)
	            					
	            					//对地图中心点进行修改
//	            					map2.centerAndZoom(center_Point,15);
	            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
	            				    
	            				}else{
	            					var title = [$(".BMap_bubble_title p").text()];
	            					add=title[0]+add;
	            					myGeo.getPoint(add, function(point){
	            						if (point) {
	            							center_Point = new BMap.Point(point.lng, point.lat);
	            							if(typeof(center_Point)!="undefined"){
	            								TempMyPoint=center_Point;
	            							}else{
	            								center_Point=TempMyPoint;
	            							}
	            							//对周边进行搜索
	            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
	            						}
	            						
	            					}, "盐城市");
	            				}
	            				
	            			}, "盐城市");
	            			/******************点击标记点或者左侧的列表，以图标为中心点end*****************************/
	            			$(".BMap_pop > div").eq(8).css('top','10')
	            			var heightCount=25;
	            			if($(".BMap_pop > div").eq(8).children()){
	            				$(".BMap_pop > div").eq(8).children().each(function(){
	            				    heightCount=heightCount+$(this).outerHeight();
	            				});
	            			}
	            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
	            			
	            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
	            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
	            			titlenew=title;
            			});
	            		
	            	})(title);
	            }
	            
	        }
			
			// 修改地图的标注物图标 带A-J序号
			var count = 0;
			$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
				var title = $(this).attr("title");
				  if(title!="") {
					  var weightNew = 0-(index - count)*25;
					  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
					  $(this).css("background",resWeight);
				  } else {
					  count = count + 1;
				  }
			});
		});
		local.setResultsHtmlSetCallback(function(result){
			$.each($("ol li"),function (index,domEle){
			  var  spanEle = $(this).find("div div span");
			  
			  // 修改检索结果列表的标注物图标 带A-J序号
			  var spanEleMk = $(this).find("span");
			  var weightNew = 0-index*25;
			  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
			  spanEleMk.eq(0).css("background",resWeight);
			 
			});
				
		});
		local.search(val);
		$(".menu_r").css('display','none');
		$("#startroutebutton").css('display' ,'none');
		$("#endroutebutton1").css('display','block');
		$("#menu_l1").css('display','block');
		
	
		
		$("#ggss_detail").click(function(){
			$("#info_ggss").css('visibility','visible');
		});
		
		
		});
	//修理厂
	$xlc.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
		var local = new BMap.LocalSearch(map2, {
			  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
			});
		local.setPageCapacity(10);
		$("#sole-input").val("修理厂");
		var val="汽车维修".split(/[ |,]/);
		local.setMarkersSetCallback(function(result){
			var markers = map2.getOverlays();
			for (var i = 0; i < markers.length; i++) {
	            if (markers[i].toString() == "[object Marker]") {
	            	var title=markers[i].getTitle();
	            	(function(title){
	            		markers[i].addEventListener('infowindowopen', function(){
	            			
	            			/******************点击标记点或者左侧的列表，以图标为中心点start*****************************/
	            			var index = 0;
	            			var myGeo = new BMap.Geocoder();
	            			//地址的解析
	            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
	            			var add = adds[index];
	            			console.log(add)
	            			
	            			
	            			var center_Point;
	            			myGeo.getPoint(add, function(point){
	            				if (point) {
	            					center_Point = new BMap.Point(point.lng, point.lat);
	            					
	            					if(typeof(center_Point)!="undefined"){
	            						TempMyPoint=center_Point;
	            					}else{
	            						center_Point=TempMyPoint;
	            					}
	            					
	            					console.log(center_Point)
	            					
	            					//对地图中心点进行修改
//	            					map2.centerAndZoom(center_Point,15);
	            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
	            				    
	            				}else{
	            					var title = [$(".BMap_bubble_title p").text()];
	            					add=title[0]+add;
	            					myGeo.getPoint(add, function(point){
	            						if (point) {
	            							center_Point = new BMap.Point(point.lng, point.lat);
	            							if(typeof(center_Point)!="undefined"){
	            								TempMyPoint=center_Point;
	            							}else{
	            								center_Point=TempMyPoint;
	            							}
	            							//对周边进行搜索
	            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
	            						}
	            						
	            					}, "盐城市");
	            				}
	            				
	            			}, "盐城市");
	            			/******************点击标记点或者左侧的列表，以图标为中心点end*****************************/
	            			
	            			$(".BMap_pop > div").eq(8).css('top','10')
	            			var heightCount=25;
	            			if($(".BMap_pop > div").eq(8).children()){
	            				$(".BMap_pop > div").eq(8).children().each(function(){
	            				    heightCount=heightCount+$(this).outerHeight();
	            				});
	            			}
	            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
	            			
	            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
	            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
	            			titlenew=title;
	            		});
	            		
	            	})(title);
	            }
	        }
			// 修改地图的标注物图标 带A-J序号
			var count = 0;
			$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
				var title = $(this).attr("title");
				  if(title!="") {
					  var weightNew = 0-(index - count)*25;
					  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
					  $(this).css("background",resWeight);
				  } else {
					  count = count + 1;
				  }
			});
		});
		local.setResultsHtmlSetCallback(function(result){
			$.each($("ol li"),function (index,domEle){
			  var  spanEle = $(this).find("div div span");
			  
			  // 修改检索结果列表的标注物图标 带A-J序号
			  var spanEleMk = $(this).find("span");
			  var weightNew = 0-index*25;
			  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
			  spanEleMk.eq(0).css("background",resWeight);
			 
			});
				
		});
		local.search(val);
		$(".menu_r").css('display','none');
		$("#startroutebutton").css('display' ,'none');
		$("#endroutebutton1").css('display','block');
		$("#menu_l1").css('display','block');

		
		$("#ggss_detail").click(function(){
			$("#info_ggss").css('visibility','visible');
		});
		
		
		
		});
	//出租车站台
	$czzt.click(function(){
	clearAllLayer();
	//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("出租车上下客站");
	var val=$("#sole-input").val().split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){
            			
            			/******************点击标记点或者左侧的列表，以图标为中心点start*****************************/
            			var index = 0;
            			var myGeo = new BMap.Geocoder();
            			//地址的解析
            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
            			var add = adds[index];
            			console.log(add)
            			
            			
            			var center_Point;
            			myGeo.getPoint(add, function(point){
            				if (point) {
            					center_Point = new BMap.Point(point.lng, point.lat);
            					
            					if(typeof(center_Point)!="undefined"){
            						TempMyPoint=center_Point;
            					}else{
            						center_Point=TempMyPoint;
            					}
            					
            					console.log(center_Point)
            					
            					//对地图中心点进行修改
//            					map2.centerAndZoom(center_Point,15);
            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            				    
            				}else{
            					var title = [$(".BMap_bubble_title p").text()];
            					add=title[0]+add;
            					myGeo.getPoint(add, function(point){
            						if (point) {
            							center_Point = new BMap.Point(point.lng, point.lat);
            							if(typeof(center_Point)!="undefined"){
            								TempMyPoint=center_Point;
            							}else{
            								center_Point=TempMyPoint;
            							}
            							//对周边进行搜索
            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            						}
            						
            					}, "盐城市");
            				}
            				
            			}, "盐城市");
            			/******************点击标记点或者左侧的列表，以图标为中心点end*****************************/
            			
            			$(".BMap_pop > div").eq(8).css('top','10')
            			var heightCount=25;
            			if($(".BMap_pop > div").eq(8).children()){
            				$(".BMap_pop > div").eq(8).children().each(function(){
            				    heightCount=heightCount+$(this).outerHeight();
            				});
            			}
            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
            			
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			titlenew=title;
            		});
            		
            	})(title);
            }
        }
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
			
	});
	local.search(val);
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','block');
	
	
	$("#czczt_detail").click(function(){
		$("#info_czczt").css('visibility','visible');
	});
	
	
	
	
	});
	//服务中心
	$fwzx.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});

	local.setPageCapacity(10);
	$("#sole-input").val("自行车服务中心");
	var val=$("#sole-input").val().split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){
            			
            			/******************点击标记点或者左侧的列表，以图标为中心点start*****************************/
            			var index = 0;
            			var myGeo = new BMap.Geocoder();
            			//地址的解析
            			var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
            			var add = adds[index];
            			console.log(add)
            			
            			
            			var center_Point;
            			myGeo.getPoint(add, function(point){
            				if (point) {
            					center_Point = new BMap.Point(point.lng, point.lat);
            					
            					if(typeof(center_Point)!="undefined"){
            						TempMyPoint=center_Point;
            					}else{
            						center_Point=TempMyPoint;
            					}
            					
            					console.log(center_Point)
            					
            					//对地图中心点进行修改
//            					map2.centerAndZoom(center_Point,15);
            					map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            				    
            				}else{
            					var title = [$(".BMap_bubble_title p").text()];
            					add=title[0]+add;
            					myGeo.getPoint(add, function(point){
            						if (point) {
            							center_Point = new BMap.Point(point.lng, point.lat);
            							if(typeof(center_Point)!="undefined"){
            								TempMyPoint=center_Point;
            							}else{
            								center_Point=TempMyPoint;
            							}
            							//对周边进行搜索
            							map2.centerAndZoom(new BMap.Point(point.lng, point.lat),14);
            						}
            						
            					}, "盐城市");
            				}
            				
            			}, "盐城市");
            			/******************点击标记点或者左侧的列表，以图标为中心点end*****************************/
            			
            			
            			$(".BMap_pop > div").eq(8).css('top','10')
            			var heightCount=25;
            			if($(".BMap_pop > div").eq(8).children()){
            				$(".BMap_pop > div").eq(8).children().each(function(){
            				    heightCount=heightCount+$(this).outerHeight();
            				});
            			}
            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
            			
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			
            			titlenew=title;
            		});
            		
            	})(title);
            }
        }
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
			
	});
	local.search(val);
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','block');
	
	
	$("#fwzx_detail").click(function(){
		$("#info_fwzx").css('visibility','visible');
	});
	
	
	
	
	});
	//公共自行车
	$ggzxc.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("公共自行车");
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_detail").css('display','none');
	$(".notfound").css('display','none');
	$("#menu_bicycle").css('display','block');
	$(".menu_pb").css('display','block');
	///点击弹出详情页面
	//从后台获取数据
	
	searchBibycle('1');
	
	});
	
	//到这去和从这里出发的弹出页面与功能
	window.tohere=(function(title){
		clearAllLayer();
		$("#menu_r").css('display','none');
		$(".menu_l").css('display','none');
		$("#left-panel #sole-searchbox-content").css('display','none'); 
		$("#left-panel #route-searchbox-content").css('display','block'); 
		$(".search-around").css('display','none');
		$("#plane_panel").css('display','none');
		$("#train_panel").css('display','none');
		$("#bus_panel").css('display','none');	
		
		$("#B_PointName1").val(titlenew);
	});
	window.fromhere=(function(title){
		clearAllLayer();
		$("#menu_r").css('display','none');
		$(".menu_l").css('display','none');
		$("#left-panel #sole-searchbox-content").css('display','none'); 
		$("#left-panel #route-searchbox-content").css('display','block'); 
		$(".search-around").css('display','none');
		$("#plane_panel").css('display','none');
		$("#train_panel").css('display','none');
		$("#bus_panel").css('display','none');
		$("#inputstart").val(titlenew);
	});
	
	
	window.tohereBus=(function(title){
		clearAllLayer();
		$("#menu_r").css('display','none');
		$(".menu_l").css('display','none');
		$("#left-panel #sole-searchbox-content").css('display','none'); 
		$("#left-panel #route-searchbox-content").css('display','block'); 
		$(".search-around").css('display','none');
		$("#plane_panel").css('display','none');
		$("#train_panel").css('display','none');
		$("#bus_panel").css('display','none');
		$("#B_PointName1").val(title);
	});
	window.fromhereBus=(function(title){
		clearAllLayer();
		$("#menu_r").css('display','none');
		$(".menu_l").css('display','none');
		$("#left-panel #sole-searchbox-content").css('display','none'); 
		$("#left-panel #route-searchbox-content").css('display','block'); 
		$(".search-around").css('display','none');
		$("#plane_panel").css('display','none');
		$("#train_panel").css('display','none');
		$("#bus_panel").css('display','none');
		$("#inputstart").val(title);
	});

	/***************************搜周边功能的实现zhangyn  2017.03.02添加*************************/
	window.searcharound=(function(title){
		titlenew=title;
//		clearAllLayer();
		$(".BMap_pop").css('display','none');
		$(".BMap_shadow").css('display','none');
		$("#menu_r").css('display','none');
		$(".menu_l").css('display','none');
		$(".search-around").css('display','block'); 
		
		mytilte = $(".BMap_bubble_title p").text();
		var strs= new Array(); 
		strs=mytilte.split("详情»");
		if(strs.length>0){
		 mytilte=strs[0];
		}
		$(".search-around #mytitleid").text(mytilte);
		
		
		// 附近搜：名称
		
		// 附近搜：地址
		var index = 0;
		adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
		 add = adds[index];
	});
	
	
	var div="<div class='around1'>"+
			"<p id='mytitleid' style='color: #fff;position: absolute;top: 19px;left: 15px;font-weight: 100;'></p>"+
			"<img src='assets/images/p1.png' style='position:absolute;top:12px;right:16px;' class='fromhere' onclick='window.fromhere(title)'/>"+
			"<img src='assets/images/p2.png' style='position:absolute;top:51px;right:16px;' class='tohere' onclick='window.tohere(title)'/>"+
			"</div><div class='around2'>"+
			"<img src='assets/images/soufj2.png' style='padding-right: 10px;'/>"+
			"<img src='assets/images/gjzd11.png' class='titlespan' style='padding-right: 14px;padding-left:5px;'/>"+
			"<img src='assets/images/ggzxc11.png' class='titlespan1'/>"+
			"</div>";
	$(".search-around").append(div);
	
	
	//公交车搜附近
	$(".titlespan").click(function(){
		clickFlag = 1;
		
		clearAllLayer();
//		var index = 0;
		var myGeo = new BMap.Geocoder();
		//地址的解析
//		var adds = [$(".BMap_bubble_content div table tr").children("td:eq(1)").text()];
//		var add = adds[index];
		
		
		
		if(typeof(TempMyAddress)!="undefined"){
			if(add.indexOf("206路")>-1){
				add=TempMyAddress;
			}else{
				TempMyAddress=add;
			}
		}else{
			TempMyAddress=add;
		}
		var mPoint;
		myGeo.getPoint(add, function(point){
			if (point) {
				mPoint = new BMap.Point(point.lng, point.lat);
				
				if(typeof(mPoint)!="undefined"){
					TempMyPoint=mPoint;
				}else{
					mPoint=TempMyPoint;
				}
				console.log(add)
				console.log(mPoint);
				//对周边进行搜索
				var mtitle="公交站点";
				map2.centerAndZoom(mPoint,15);
				var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
			    map2.addOverlay(circle);
			    var local =  new BMap.LocalSearch(map2, {renderOptions: {map: map2,selectFirstResult: false,autoViewport: false}});  
			    local.searchNearby(mtitle,mPoint,1000);
			    
			    
			    
			    
			}else{
				var title = [$(".BMap_bubble_title p").text()];
				add=title[0]+add;
				myGeo.getPoint(add, function(point){
					if (point) {
						mPoint = new BMap.Point(point.lng, point.lat);
						if(typeof(mPoint)!="undefined"){
							TempMyPoint=mPoint;
						}else{
							mPoint=TempMyPoint;
						}
						//对周边进行搜索
						var mtitle="公交站点";
						map2.centerAndZoom(mPoint,15);
						var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
					    map2.addOverlay(circle);
					    var local =  new BMap.LocalSearch(map2, {renderOptions: {map: map2,selectFirstResult: false,autoViewport:false}});  
					    local.searchNearby(mtitle,mPoint,1000);
					    
					}
					
				}, "盐城市");
			}
			
		}, "盐城市");
		
		/************************************2017.3.24新添加zhangyn************************************************************/
		//查询出公交站点后再进行点击事件(查找公交站点周围的公交站)
//		map2.addEventListener("click", function(e){   
//		clearAllLayer();
//        if(e.overlay){ 
//        	var name=$(".BMap_bubble_title p").attr("title");
//    		var mPoint;
//        	var add=name;
//    		myGeo.getPoint(add, function(point){
//    			if (point) {
//    				mPoint = new BMap.Point(point.lng, point.lat);
//    				if(typeof(mPoint)!="undefined"){
//    					TempMyPoint=mPoint;
//    				}else{
//    					mPoint=TempMyPoint;
//    				}
//    				//对周边进行搜索
//    				var mtitle="公交站点";
//    				map2.centerAndZoom(mPoint,15);
//    				var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
//    			    map2.addOverlay(circle);
//    			    var local =  new BMap.LocalSearch(map2, {renderOptions: {map: map2, autoViewport: false}});  
//    			    local.searchNearby(mtitle,mPoint,5000);
//    			    
//    			}
//    			
//    		}, "盐城市");
//        	
//        	
//           }  
//       });
		
		
	})
	
	
	//对于搜索周边的公共自行车
	$(".titlespan1").click(function(){
		
		clearAllLayer(); 
		
		
		searchBibycleAround();
		
	})
	
	
	
	
	/***************************搜周边功能的实现zhangyn  2017.03.02添加*结束************************/	

	
	//长途客运站
	$ctkyz.click(function(){
		clearAllLayer();
		$("#sole-input").val("汽车站");
		//更换定位图标
		var point_new1 = new BMap.Point(120.179575,33.383679);
        var myIcon_new1 = new BMap.Icon("assets/images/markersA.png", new BMap.Size(50,50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker = new BMap.Marker(point_new1, {icon: myIcon_new1});      
        map2.addOverlay(marker);  
        var sContent1="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐城市汽车客运站</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：江苏省盐城市亭湖区青年路22号（近火车站）</p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐城市汽车客运站\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐城市汽车客运站\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow1 = new BMap.InfoWindow(sContent1);  // 创建信息窗口对象 
		marker.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow1,point_new1); //开启信息窗口
		});
		//更换定位图标
		var point_new2 = new BMap.Point(120.1363,33.373774);
        var myIcon_new2 = new BMap.Icon("assets/images/markersB.png", new BMap.Size(50,50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker2 = new BMap.Marker(point_new2, {icon: myIcon_new2});      
        map2.addOverlay(marker2);  
        var sContent2="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐都汽车客运站</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：：盐马路116号</p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐都汽车客运站\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐都汽车客运站\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow2 = new BMap.InfoWindow(sContent2);  // 创建信息窗口对象 
		marker2.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow2,point_new2); //开启信息窗口
		});
		//更换定位图标
		var point_new3 = new BMap.Point(120.120175,33.438906);
        var myIcon_new3 = new BMap.Icon("assets/images/markersC.png", new BMap.Size(50,50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker3 = new BMap.Marker(point_new3, {icon: myIcon_new3});      
        map2.addOverlay(marker3);  
        var sContent3="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐城汽车客运北站</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：开放大道359号 </p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐城汽车客运北站\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐城汽车客运北站\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow3 = new BMap.InfoWindow(sContent3);  // 创建信息窗口对象 
		marker3.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow3,point_new3); //开启信息窗口
		});
		//更换定位图标
		var point_new4 = new BMap.Point(120.116968,33.319667);
        var myIcon_new4 = new BMap.Icon("assets/images/markersD.png", new BMap.Size(50,50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker4 = new BMap.Marker(point_new4, {icon: myIcon_new4});      
        map2.addOverlay(marker4);  
        var sContent4="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐城汽车客运西站</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：一沟南路与争进路交叉口东150米</p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐城汽车客运西站\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐城汽车客运西站\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow4 = new BMap.InfoWindow(sContent4);  // 创建信息窗口对象 
		marker4.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow4,point_new4); //开启信息窗口
		});
	
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','none');
	$("#bus_panel").css('display','block');
	
	$("#bus_detail1").click(function(){
		map2.centerAndZoom(new BMap.Point(120.179575,33.383679), 14);
		map2.openInfoWindow(infoWindow1,point_new1); //开启信息窗口
	});
	$("#bus_detail2").click(function(){
		map2.centerAndZoom(new BMap.Point(120.1363,33.373774), 14);
		map2.openInfoWindow(infoWindow2,point_new2); //开启信息窗口
	});
	$("#bus_detail3").click(function(){
		map2.centerAndZoom(new BMap.Point(120.120175,33.438906), 14);
		map2.openInfoWindow(infoWindow3,point_new3); //开启信息窗口
	});
	$("#bus_detail4").click(function(){
		map2.centerAndZoom(new BMap.Point(120.143097,33.340655), 14);
		map2.openInfoWindow(infoWindow4,point_new4); //开启信息窗口
	});
	
	});
	
	//盐城火车站
	$ychcz.click(function(){
		clearAllLayer();
		$("#sole-input").val("盐城火车站");
		//更换定位图标
		var point_new = new BMap.Point(120.180683,33.388185);
        var myIcon_new = new BMap.Icon("assets/images/markersA.png", new BMap.Size(50, 50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker = new BMap.Marker(point_new, {icon: myIcon_new});      
        map2.addOverlay(marker);  
        var sContent="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐城火车站</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：范公路69号<br>电话：0515-95105105</p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐城火车站\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐城火车站\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象 
		marker.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow,point_new); //开启信息窗口
		});
		
		$(".menu_r").css('display','none');
		$("#startroutebutton").css('display' ,'none');
		$("#endroutebutton1").css('display','block');
		$("#menu_l1").css('display','none');
		$(".train_panel").css('display','block');
		
		//左侧的菜单点击弹出信息框
		$("#train_detail").click(function(){
			map2.centerAndZoom(new BMap.Point(120.180683,33.388185), 14);
			map2.openInfoWindow(infoWindow,point_new); //开启信息窗口
		});
	
	
	
	});
	//南洋机场
	$nyjc.click(function(){
		clearAllLayer();
		$("#sole-input").val("南洋机场");
		//更换定位图标
		var point_new = new BMap.Point(120.214347,33.431524);
        var myIcon_new = new BMap.Icon("assets/images/markersA.png", new BMap.Size(50, 50), {offset: new BMap.Size(10, 10)});  
        // 创建标注对象并添加到地图     
        var marker = new BMap.Marker(point_new, {icon: myIcon_new});      
        map2.addOverlay(marker);  
        var sContent="<div style='height:auto;width:200px;'>" +
        		"<p style='font: bold 14px/16px arial,sans-serif; color:#cc5522;'>盐城南洋国际机场</p>" +
        		"<p style='font: 12px arial,sans-serif; line-height: 16px;word-wrap: break-word;'>地址：盐城市亭湖区机场路<br>电话：(0515)88215020</p>" +
        		"<table><tr><td colSpan='2' style='white-space:nowrap;height:25px;'>" +
        		"<img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhereBus(\"盐城南洋国际机场\")'/>" +
        		"<img src='assets/images/button_2.png' class='tohere' onclick='window.tohereBus(\"盐城南洋国际机场\")'/>" +
        		"</td></tr></table>" +
        		"</div>";
		var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象 
		marker.addEventListener("click", function(){          
		map2.openInfoWindow(infoWindow,point_new); //开启信息窗口
		});

	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','none');
	$("#plane_panel").css('display','block');
	
	$("#plane_detail").click(function(){
	    map2.centerAndZoom(new BMap.Point(120.214347,33.431524), 14);
		map2.openInfoWindow(infoWindow,point_new); //开启信息窗口
	});
	});
	//轮渡码头
	$ldmt.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("轮渡码头");
	var val="码头".split(/[ |,]/);
	local.setMarkersSetCallback(function(result){
		var markers = map2.getOverlays();
		for (var i = 0; i < markers.length; i++) {
            if (markers[i].toString() == "[object Marker]") {
            	var title=markers[i].getTitle();
            	(function(title){
            		markers[i].addEventListener('infowindowopen', function(){
            			
            			$(".BMap_pop > div").eq(8).css('top','10')
            			var heightCount=25;
            			if($(".BMap_pop > div").eq(8).children()){
            				$(".BMap_pop > div").eq(8).children().each(function(){
            				    heightCount=heightCount+$(this).outerHeight();
            				});
            			}
            			$(".BMap_pop > div").eq(8).css('height',Math.max($(".BMap_pop > div").eq(8).outerHeight(),heightCount))
            			
            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;height:25px;'><img src='assets/images/button_1.png' style='padding-right:9px;' class='fromhere' onclick='window.fromhere(\""+title+"\")'/><img src='assets/images/button_2.png' class='tohere' onclick='window.tohere(\""+title+"\")'/></td></tr>")
            			titlenew=title;
            		});
            		
            	})(title);
            }
        }
		// 修改地图的标注物图标 带A-J序号
		var count = 0;
		$.each($('.BMap_Marker').filter(".BMap_noprint"),function (index,domEle){
			var title = $(this).attr("title");
			  if(title!="") {
				  var weightNew = 0-(index - count)*25;
				  var resWeight ="url(http://api.map.baidu.com/images/markers.png) -0px "+ weightNew +"px no-repeat";
				  $(this).css("background",resWeight);
			  } else {
				  count = count + 1;
			  }
		});
	});
	local.setResultsHtmlSetCallback(function(result){
		$.each($("ol li"),function (index,domEle){
		  var  spanEle = $(this).find("div div span");
		  
		  // 修改检索结果列表的标注物图标 带A-J序号
		  var spanEleMk = $(this).find("span");
		  var weightNew = 0-index*25;
		  var resWeight = "url(http://api.map.baidu.com/images/markers.png) -23px "+ weightNew +"px no-repeat";
		  spanEleMk.eq(0).css("background",resWeight);
		 
		});
		
	});
	
	local.search(val);
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$("#menu_l1").css('display','block');
	
	
	$("#ldmt_detail").click(function(){
		$("#info_ldmt").css('visibility','visible');
	});
	});
	//高速公路事件
	$gssj.click(function(){
		clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
		 var local = new BMap.LocalSearch(map2, {
			  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
			});
		local.setPageCapacity(10);
		$("#sole-input").val("高速公路事件");
		$(".menu_r").css('display','none');
		$("#startroutebutton").css('display' ,'none');
		$("#endroutebutton1").css('display','block');
		$("#menu_detail").css('display','block');
		$(".menu_22").css('display','none');
		
		//点击弹出详情页面
		//ajax后台取数据
		searchighWay();

	});
	$("#menu_22").css('display','none');

	/**
	 * 出租车实时GPS
	 * 2016.12.7
	 * by  zhangyn
	 * **/
	//出租车
	$czc.click(function(){
	//	clearAllLayer();
		//map2.centerAndZoom(new BMap.Point(lng,lat),14);
	var local = new BMap.LocalSearch(map2, {
		  renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		});
	local.setPageCapacity(10);
	$("#sole-input").val("出租车");
	$(".menu_r").css('display','none');
	$("#startroutebutton").css('display' ,'none');
	$("#endroutebutton1").css('display','block');
	$(".notfound").css('display','none');
	$("#d1").click(function(){
		show2();
	})
	searchTaxi();
	
	});
	

/**2016-11-21 zss add****************************/	
	 $("#menu_ll #RouteAddress_DIV1 #RADiv_ResItem1 #RA_ResItem_1 table tbody tr .selBtn ").live("click",function(){
		 $(this).off("click");
		  var addess= $(this).parent('td').prev().text();
		  var strs= new Array(); 
		   strs=addess.split("地址"); 
		   $("#B_PointName1").val(strs[0]);
		   $(".menu_ll").css('display','block');
		   $(".button-print").css('display','block');  
		  
	 });
	 $("#menu_ll #RouteAddress_DIV0 #RADiv_ResItem0 #RA_ResItem_0 table tbody tr .selBtn ").live("click",function(){
		$(this).off("click");
		  var addess= $(this).parent('td').prev().text();
		   var strs= new Array(); 
		   strs=addess.split("地址"); 
		   $("#inputstart").val(strs[0]);
		   $(".menu_ll").css('display','block');
		   
		   $(".button-print").css('display','block');   
		   
	 });
	 
	 
	 
/**2016-11-21 zss add end***************************/	
/**************************2016-11-17 zss add ************************************/
	 
	 
/*************************2017.01.13  zhangyn*add****模糊查询的一些改进***************************************/	 

	 function clicksearch(){
		 /*公交*/
		 transit = new BMap.TransitRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"}   });
			transit.setSearchCompleteCallback(function(results){ 
				if (transit.getStatus() == BMAP_STATUS_SUCCESS){ 
					$("#left-panel #cards-level1").css('display','block');
					$("#left-panel #nav_container").css('display','none');
					$("#left-panel #nav_container0").css('display','block');
					$("#left-panel #shoufei_container").css('display','none');
					$("#menu_ll").css("top","200px");
				}else{
					if(start==""){
						$.messager.alert("提示","请输入起点位置！","info");
					}else if(end == ""){
						$.messager.alert('提示','请输入终点位置！','info');
					}else{
						$.messager.singleton.alert("暂无公交路线，请切换其他出行方式！");
					}
					
				}
			});
		 /*驾车*/
		driving = new BMap.DrivingRoute(map2, {renderOptions: {map: map2,panel:"menu_ll", autoViewport: true}});
		driving.setSearchCompleteCallback(function(results){   
			if (driving.getStatus() == BMAP_STATUS_SUCCESS){ 
				$("#left-panel #cards-level1").css('display','block');
				$("#left-panel #nav_container").css('display','block');
				$("#left-panel #nav_container0").css('display','none');
				$("#left-panel #shoufei_container").css('display','block');
				$("#menu_ll").css("top","220px");
			}else{
				if(start==""){
					$.messager.alert("提示","请输入起点位置！","info");
				}else if(end == ""){
					$.messager.alert('提示','请输入终点位置！','info');
				}else{
					$.messager.singleton.alert("暂无驾车路线，请切换其他出行方式！");
				}
				
			}
		});
		/*步行或驾车*/
		walking = new BMap.WalkingRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"}});
		walking.setSearchCompleteCallback(function(results){   
			if (walking.getStatus() == BMAP_STATUS_SUCCESS){ 
				$("#menu_ll").css("top","140px"); 
				$("#left-panel #shoufei_container").css('display','none');
			}else{
				if(start==""){
					$.messager.alert("提示","请输入起点位置！","info");
				}else if(end == ""){
					$.messager.alert('提示','请输入终点位置！','info');
				}else{
					$.messager.singleton.alert("暂无步行路线，请切换其他出行方式！");
				}
			}
		});
	
	 }
	 
/************************************************************************************/	 
	 
	$("#left-panel #search-button").click(function(){
		$("#menu_l1").css('display','none');
		$("#plane_panel").css('display','none');
		$("#train_panel").css('display','none');
		$("#bus_panel").css('display','none');
		$("#taxi_legend").css('display','none');
		searchContent();
//		addMarkerLoc();
	});
	/***********对输入框实现回车键搜索*zhangyn 2017.5.25 添加修改*****START****************/
	//删除清空
	$('#sole-input').bind('input propertychange', function() {   
		if($("#sole-input").val()==""){
			clearAllLayer();
//			addMarkerLoc();
			$("#menu_l1").css('display','none');
			$("#plane_panel").css('display','none');
			$("#train_panel").css('display','none');
			$("#bus_panel").css('display','none');
		}
	}); 
	
	//回车查询
	$("#sole-input").bind("keydown", function(){
		if (event.keyCode == 13) {
	    	searchContent();
	    }
	});
	
	$("#inputstart").bind('keydown',function(event){ 
		if (event.keyCode == 13) {
	    	searchContent();
	    }
    });
	$("#B_PointName1").bind('keydown',function(event){ 
		if (event.keyCode == 13) {
	    	searchContent();
	    }
    });
	
	function searchContent(){

		 /** 路线查询 */
		if($("#left-panel #route-searchbox-content").css("display")=='block'){ 
			$("#inputstart").val($.trim($("#inputstart").val()));
			$("#B_PointName1").val($.trim($("#B_PointName1").val()));
			var start=$.trim($("#inputstart").val());
			var end=$.trim($("#B_PointName1").val());
			clearAllLayer();
			if(start==""){
				$.messager.alert("提示","请输入起点位置！","info");
				return false;
			}else if(end == ""){
				$.messager.alert('提示','请输入终点位置！','info');
				return false;
			}else if(start == end){
				$.messager.alert('提示','起止点位置一样，请重新输入','info');
				return false;
			}else{
				if(clicknum=="gj"){
			    	//**公交 *//
			    	$(".menu_ll").css('display','block');
			    	$(".menu_ll").empty();
			    	$("#menu_ll").css("top","140px");
			    	$("#left-panel #cards-level1").css('display','none');
			    	$(".button-print").css('display','none');  
				map2.centerAndZoom(new BMap.Point(lng,lat),15);
					var transit = new BMap.TransitRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"}});
					
					transit.setSearchCompleteCallback(function(results){ 
						if (transit.getStatus() == BMAP_STATUS_SUCCESS){  
							
               	      $(".menu_ll").css('display','block');
               	      $("#menu_ll").css("top","200px");
               	      $(".button-print").css('display','block');  
                         $("#left-panel #cards-level1").css('display','block');
                         $("#left-panel #nav_container").css('display','none');
         				  $("#left-panel #nav_container0").css('display','block');
         				  $("#left-panel #shoufei_container").css('display','none');
	                     }else{
	                    	 $.messager.singleton.alert("暂无公交路线，请切换其他出行方式！");
	                	}
					});
					
					
				   transit.search(start, end);
				  
				}else if(clicknum=="jc"){   
					//**驾车 *//*
					$(".menu_ll").css('display','block');
					$(".menu_ll").empty();
			    	$("#menu_ll").css("top","140px");
			    	$("#left-panel #cards-level1").css('display','none');
			    	$(".button-print").css('display','none');  
			    	map2.centerAndZoom(new BMap.Point(lng,lat),15);					 
	                var driving = new BMap.DrivingRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"} });
	                
	                
	                
	                
	                driving.setSearchCompleteCallback(function(results){   
	                	if (driving.getStatus() == BMAP_STATUS_SUCCESS){    
                   		  $(".menu_ll").css('display','block');
                   	      $(".button-print").css('display','block');
                          $("#left-panel #cards-level1").css('display','block');
                          $("#left-panel #nav_container").css('display','block');
         			  	  $("#left-panel #nav_container0").css('display','none');
         				  $("#left-panel #shoufei_container").css('display','block');
         				  $("#menu_ll").css("top","211px");
                        } else{
						      $.messager.singleton.alert("暂无驾车路线，请切换其他出行方式！");
               	}
                   });
					driving.search(start, end);
				}else if(clicknum=="bx"){   
					//**步行 *//*
					$(".menu_ll").css('display','block');
					$(".menu_ll").empty();
			    	$("#menu_ll").css("top","140px");
			    	$("#left-panel #cards-level1").css('display','none');
			    	$(".button-print").css('display','none');  
			    	map2.centerAndZoom(new BMap.Point(lng,lat),15);
					var walking = new BMap.WalkingRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"}});
					
					walking.setSearchCompleteCallback(function(results){   
						if (walking.getStatus() == BMAP_STATUS_SUCCESS){    $(".button-print").css('display','block'); 
	                          $("#left-panel #cards-level1").css('display','none');
	                          $("#left-panel #nav_container").css('display','none');
	          				  $("#left-panel #nav_container0").css('display','none');
	          				  $("#left-panel #shoufei_container").css('display','block');
	          				  $("#menu_ll").css("top","140px");
	          				
	                     }else{
	 						$.messager.singleton.alert("暂无步行路线，请切换其他出行方式！");
		                	}
			         });
					walking.search(start, end);
					walking.setResultsHtmlSetCallback(function(result){
						var hEle = $("#menu_ll").find("h1");
						if(hEle.length){
							var  textval=hEle.eq(0).text();
							var textarr=textval.split("前往");
							if(textarr.length){
								textarr[0]="步行前往"
								hEle.eq(0).text(textarr.join(""))
							}
						}
					});
					
				}else if(clicknum=="qx"){
					   
					//**骑行 *//*
					$(".menu_ll").css('display','block');
					$(".menu_ll").empty();
			    	$("#menu_ll").css("top","140px");
			    	$("#left-panel #cards-level1").css('display','none');
			    	$(".button-print").css('display','none'); 
			    	map2.centerAndZoom(new BMap.Point(lng,lat),15);
					var walking = new BMap.WalkingRoute(map2, {renderOptions: {map: map2,autoViewport:true,panel:"menu_ll"}});
					
					walking.setSearchCompleteCallback(function(results){  
						if (walking.getStatus() == BMAP_STATUS_SUCCESS){    
							  $(".button-print").css('display','block'); 
	                          $("#left-panel #cards-level1").css('display','none');
	                          $("#left-panel #nav_container").css('display','none');
	          				  $("#left-panel #nav_container0").css('display','none');
	          				  $("#left-panel #shoufei_container").css('display','block');
	          				  $("#menu_ll").css("top","140px");
			             }else{
	 							$.messager.singleton.alert("暂无骑行路线，请切换其他出行方式！");
		                }
			   });
			walking.search(start, end);
			walking.setResultsHtmlSetCallback(function(result){
				var hEle = $("#menu_ll").find("h1");
				if(hEle.length){
					var  textval=hEle.eq(0).text();
					var textarr=textval.split("前往");
					if(textarr.length){
						textarr[0]="骑行前往"
						hEle.eq(0).text(textarr.join(""))
					}
				}
			});
			
					
		}
			/*******2017-02-07 zss add 用来防止百度地图返回的数据和本地不相同时使用 **********/
				if($("#menu_ll").css("display")=='block'){ 
					var start=$('#menu_ll #RouteAddress_DIV0 #B_PointName0');
					var end=$('#menu_ll #RouteAddress_DIV1 #B_PointName1');
					if(start!=null){
						var a=$('#inputstart').val();
						$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
					}
					if(end!=null){
						var b=$('#B_PointName1').val();
						$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
					}
					
					var searchpictime = setInterval(function(){
							showdata();
					 },500);
					function showdata(){
						if(start!=null){
							var a=$('#inputstart').val();
							$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
						}
						if(end!=null){
							var b=$('#B_PointName1').val();
							$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
						}
						if($('#inputstart').val()==$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text()
						  &&($('#B_PointName1').val()==$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text())){
							clearInterval(searchpictime);
							searchpictime=null;
						}
					};
								
				}		
			/*******2017-02-07 zss add end **********/
	}
	$(".menu_r").css('display','none');
	}else{
		
		$("#sole-input").val($.trim($("#sole-input").val()));
		if($("#sole-input").val()=='')
		{
			clearAllLayer();
		}
		else{    
			    clearAllLayer();
			    $("#menu_l1").css('display','none');
			    $("#menu_r").css('display','none');
			    busName=$("#sole-input").val();

			    
			    
			    var num="2";
			    for(var k=0;k<busName.length;k++){  
				     if (!isNaN(busName.charAt(k))){   
				    	num="1";
				    	break;
					 }   
			    }
			    
			    for(var k=0;k<busName.length;k++){  
				     if ((!/^[\u4e00-\u9fa5]+$/.test(busName.charAt(k)))&&(!busName.charAt(k).match(/\d+/g))&&(!/^[A-Za-z]+$/.test(busName.charAt(k)))){   
				    	 num="0";
				    	break;
					 }else if(busName.indexOf(" ") >= 0){//判断特殊字符里面含有空格时
						 busName=busName.replace(/\s/g, "");
				    	 num="2";
				    	 break;
					 }    
			    }
			    
			    if(num=="1"){//输入纯数字时，显示 公交车线路列表
			    	clearAllLayer();
			    	map2.centerAndZoom(new BMap.Point(lng,lat),14);
				    function busSearch(){
					    var busline = new BMap.BusLineSearch(map2,{renderOptions:{map:map2,autoViewport:false,panel:"menu_ll"},onGetBusListComplete: function(result){
						   if(result) {
							 var fstLine = result.getBusListItem(0);//获取第一个公交列表显示到map上
							 
							 
							 if(fstLine!=null){
							  busline.getBusLine(fstLine); 
							  $(".notfound").css('display','none');
							  $("#menu_ll").css("display","block");
							  $("#menu_ll").css("top","56px");
							  $("#menu_ll").css("height","75%");
							 }
							 else{  
								$(".menu_r").css('display','none');
								$(".menu_detail").css('display','none');
								$("#menu_bicycle").css('display','none');
								$("#menu_taxi").css('display','none');
								$(".notfound").css('display','block');
								$("#startroutebutton").css('display' ,'none');
								$("#endroutebutton1").css('display','block');
							}
							 
						  }
					}
				});
					busline.getBusList(busName);
					/**************公交线路的重写******************************/
					 busline.setMarkersSetCallback(function(result){
						  	var markers = map2.getOverlays();
						  		
								for (var i = 0; i < markers.length; i++) {
						            if (markers[i].toString() == "[object Marker]") {
						            	busline_name="";
						            	var title=markers[i].getTitle();
						            	(function(title,busline_name){
						            		markers[i].addEventListener('infowindowopen', function(){
						            			linename=title;
						            				//从后台重新获取查询结果
													$.ajax({
														   type: "POST",
														   url: "table/getBusLineName.do",
														   dataType : "json",
														   async: false,
														   data:{linename:linename},
														   success: function(data){
															   var busLineNameInfos = data['result'];
															   busline_name = "";
															   if(busLineNameInfos.length == 0){
																   busline_name = "无";  
															   }
															   for(var k=0;k<busLineNameInfos.length;k++){
																   
																   var busLineNameInfo = busLineNameInfos[k];
																   if (k == busLineNameInfos.length -1) {
																	   busline_name = busline_name+busLineNameInfo['LINE_NAME'] + "路";
																   } else {
																	   busline_name = busline_name + busLineNameInfo['LINE_NAME'] +  "路、";
																   }
															   }
															 }
														});
													var newHtml =
														"<tr style='font:12px arial,sans-serif;border-top:1px solid #ccc;'><td style='word-wrap: break-word;'><p style='margin-top:-19px;border-top: 1px solid hsla(0, 0%, 60%, 0.81);'><b style='color:#38f;'>途经线路：</b>"+busline_name+"</p></td></tr>";
							            			$(".BMap_bubble_content ").append(newHtml);
						            		});
						            		
						            	})(title);
						            }
						        }
						    
								
							});
						  
					
					
					/****************************************公交实时位置的部分注释***************************************************/
//					setTimeout(function(){
//						 //公交车实时位置
//						searchBus();
//						
//					},3000);
					
				}
					
			setTimeout(function(){
				busSearch();
				
			},0);
			 $("#startroutebutton").css('display' ,'none');
			 $("#endroutebutton1").css('display','block');
			 
			 
			 setTimeout(function(){
				 //调查王祥：公交线路结果list重写css
				 $('dl').each(function(i){
					 //给每个dl元素加蓝边线
					 $(this).css("background","#F4F4F4");
					 $(this).css("padding-top","12px");
					 $(this).css("padding-bottom","12px");
					 
//					 var spanEleMk = $(this).find("tr");
//					 spanEleMk.each(function(k){
//						$(this).css("background",clr);
//					 });
					 
					$('dt').css("font-size","15px");
					$('dt>a').css("color","#666f86");
					$('dd>table>tbody>tr>td').css("background","#F4F4F4");
				 });
			 },800);
			 
			 
		    
		 }else if(num=="0"){//输入无意义字符
			$(".menu_r").css('display','none');
			$(".menu_detail").css('display','none');
			$("#menu_bicycle").css('display','none');
			$("#menu_taxi").css('display','none');
			$(".notfound").css('display','block');
			$("#startroutebutton").css('display' ,'none');
			$("#endroutebutton1").css('display','block');
		 }else {//正常搜索时
			$("#menu_l1").css('display','block');
			var local = new BMap.LocalSearch(map2, {
			renderOptions:{map: map2,selectFirstResult: false,autoViewport:false,panel:"menu_l1"}
		    });
		    local.search(busName);
		    local.setResultsHtmlSetCallback(function(result){
		    	
		    	
		    	$(".menu_r").css('display','none');
				$(".menu_detail").css('display','none');
				$("#menu_bicycle").css('display','none');
				$("#menu_taxi").css('display','none');
				$(".notfound").css('display','none');
				$("#startroutebutton").css('display' ,'none');
				$("#endroutebutton1").css('display','block');
				
				
				
				
				
				
				
			});
		    $(".search-around").css('display','none');
		    /*****************搜周边功能添加   zhangyn 2017.03.02  add***********************/
		    local.setMarkersSetCallback(function(result){
			var markers = map2.getOverlays();
			for (var i = 0; i < markers.length; i++) {
	            if (markers[i].toString() == "[object Marker]") {
	            	var title=markers[i].getTitle();
	            		(function(title){
	            		markers[i].addEventListener('infowindowopen', function(){
	            			$(".BMap_pop > div").eq(8).css('top','20')
	            			$(".BMap_pop > div").eq(8).find(".BMap_bubble_content > div").css("margin-top","0");
	            			$(".BMap_bubble_content div table").append("<tr><td colSpan='2' style='white-space:nowrap;'><div style='height:26px;width:26px;background-color:#fff;'><img src='assets/images/souzb.png' style='height:26px;position:absolute;right:9px;' class='fromhere' onclick='window.searcharound(\""+title+"\")'/></td></tr>")
	                	});
	            		})(title);
	            	}
				}
		    });
		   /*****************搜周边功能添加   zhangyn 2017.03.02  end***********************/
		    
			$(".menu_r").css('display','none');
			$("#startroutebutton").css('display' ,'none');
			$("#endroutebutton1").css('display','block');
			$("#menu_l1").css('display','block');
			$(".notfound").css('display','none');
			$("#czc_detail").click(function(){
				$("#info_czc").css('visibility','visible');
			});
		}
		  }
		}
	
	}
	 /**控制搜索点击 */
	$("#left-panel #startroutebutton").click(function(){
	   $("#left-panel #sole-searchbox-content").css('display','none'); 
	   $("#left-panel #route-searchbox-content").css('display','block'); 
	   $("#menu_r").css('display','none');
	});
	
	$("#left-panel #endroutebutton").click(function(){
	  $("#left-panel #route-searchbox-content").css('display','none'); 
	  $("#left-panel #sole-searchbox-content").css('display','block'); 
	  $("#menu_ll").css('display','none'); 
	  $("#menu_l1").css('display','none');
	  $(".button-print").css('display','none');
	  $("#left-panel #cards-level1").css('display','none');
	  $("#left-panel .route-wrap").css('display','none');
	  $("#left-panel .jiacheroute-wrap").css('display','none');
	  $(".menu_r").css('display','block');
	  $("#inputstart").val("");
	  $("#B_PointName1").val("");
	  clearAllLayer();
	});
	
	
	/**Tab公交点击 */
	$("#left-panel #route-searchbox-content #bustab").click(function(){
		$("#bustab span").css("color","#3385ff");
		$("#bustab i").css("background-position","0 -51px");
		
		$("#drivetab span").css("color","#333");
		$("#drivetab i").css("background-position","0 -68px");
		
		$("#walktab i").css("background-position","0 -100px");
		$("#walktab span").css("color","#333");
		
		$("#biketab i").css("background-position","0 -138px");
		$("#biketab span").css("color","#333");
		
		$(".route-searchbox-content.bus .arrow-wrap").css("left","12.5%");
		$("#left-panel #cards-level1").css('display','none');
		clicknum="gj";
		/**2016-11-17 zss add*/
	   var startcontent=$("#inputstart").val();
		var endcontent=$("#B_PointName1").val();
		
		clearAllLayer();
		if(startcontent != ""){
			transit.search(startcontent, endcontent);	
		}else{
			return;
		}
	});
	/**Tab驾车点击 */
	$("#left-panel #route-searchbox-content #drivetab").click(function(){
		$("#bustab span").css("color","#333");
		$("#bustab i").css("background-position","0 -34px");
		
		$("#drivetab span").css("color","#3385ff");
		$("#drivetab i").css("background-position","0 -85px");
		
		$("#walktab i").css("background-position","0 -100px");
		$("#walktab span").css("color","#333");
		
		$("#biketab i").css("background-position","0 -138px");
		$("#biketab span").css("color","#333");
		
		$(".route-searchbox-content.bus .arrow-wrap").css("left","47.5%");
		clicknum="jc";
		var startcontent=$("#inputstart").val();
		var endcontent=$("#B_PointName1").val();

		clearAllLayer();
		if(startcontent != ""){
			driving.search(startcontent, endcontent);
		}else{
			return;
		}
		
	});
	/**Tab步行点击 */
	$("#left-panel #route-searchbox-content #walktab").click(function(){
		$("#bustab span").css("color","#333");
		$("#bustab i").css("background-position","0 -34px");
		
		$("#drivetab span").css("color","#333");
		$("#drivetab i").css("background-position","0 -68px");
		
		$("#walktab i").css("background-position","0 -119px");
		$("#walktab span").css("color","#3385ff");
		
		$("#biketab i").css("background-position","0 -138px");
		$("#biketab span").css("color","#333");
		$(".route-searchbox-content.bus .arrow-wrap").css("left","81.5%");
		clicknum="bx";
		$("#left-panel #cards-level1").css('display','none');
	 
	  var startcontent=$("#inputstart").val();
		var endcontent=$("#B_PointName1").val();
	    clearAllLayer();
	    if(startcontent != ""){
	    	walking.search(startcontent, endcontent);
	    	walking.setResultsHtmlSetCallback(function(result){
				var hEle = $("#menu_ll").find("h1");
				if(hEle.length){
					var  textval=hEle.eq(0).text();
					var textarr=textval.split("前往");
					if(textarr.length){
						textarr[0]="步行前往"
						hEle.eq(0).text(textarr.join(""))
					}
				}
			});
	    }else{
	    	return;
	    }		
	    
	    /*******2017-02-20 zss add 用来防止百度地图返回的数据和本地不相同时使用 **********/
		if($("#menu_ll").css("display")=='block'){ 
			var start=$('#menu_ll #RouteAddress_DIV0 #B_PointName0');
			var end=$('#menu_ll #RouteAddress_DIV1 #B_PointName1');
			if(start!=null){
				var a=$('#inputstart').val();
				$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
			}
			if(end!=null){
				var b=$('#B_PointName1').val();
				$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
			}
			
			var searchpictime = setInterval(function(){
					showdata();
			 },300);
			function showdata(){
				if(start!=null){
					var a=$('#inputstart').val();
					$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
				}
				if(end!=null){
					var b=$('#B_PointName1').val();
					$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
				}
				if($('#menu_ll #RouteAddress_DIV0 #B_PointName0').val()!=null&&
						$('#menu_ll #RouteAddress_DIV1 #B_PointName1').val()!=null){
					clearInterval(searchpictime);
					searchpictime=null;
				}
			};
						
		}		
	/*******2017-02-20 zss add end **********/
	});
	/**Tab骑行点击 */
	$("#left-panel #route-searchbox-content #biketab").click(function(){
		$("#bustab span").css("color","#333");
		$("#bustab i").css("background-position","0 -34px");
		
		$("#drivetab span").css("color","#333");
		$("#drivetab i").css("background-position","0 -68px");
		
		$("#walktab i").css("background-position","0 -100px");
		$("#walktab span").css("color","#333");
		
		$("#biketab i").css("background-position","0 -157px");
		$("#biketab span").css("color","#3385ff");
		$(".route-searchbox-content.bus .arrow-wrap").css("left","87.5%");
		clicknum="qx";
		$("#left-panel #cards-level1").css('display','none');
			 
	   var startcontent=$("#inputstart").val();
		var endcontent=$("#B_PointName1").val();
		clearAllLayer();
		if(startcontent != ""){
			walking.search(startcontent, endcontent);
			walking.setResultsHtmlSetCallback(function(result){
				var hEle = $("#menu_ll").find("h1");
				if(hEle.length){
					var  textval=hEle.eq(0).text();
					var textarr=textval.split("前往");
					if(textarr.length){
						textarr[0]="骑行前往"
						hEle.eq(0).text(textarr.join(""))
					}
				}
			});
		}else{
			return;
		}
		
		 /*******2017-02-20 zss add 用来防止百度地图返回的数据和本地不相同时使用 **********/
		if($("#menu_ll").css("display")=='block'){ 
			var start=$('#menu_ll #RouteAddress_DIV0 #B_PointName0');
			var end=$('#menu_ll #RouteAddress_DIV1 #B_PointName1');
			if(start!=null){
				var a=$('#inputstart').val();
				$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
			}
			if(end!=null){
				var b=$('#B_PointName1').val();
				$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
			}
			
			var searchpictime = setInterval(function(){
					showdata();
			 },300);
			function showdata(){
				if(start!=null){
					var a=$('#inputstart').val();
					$('#menu_ll #RouteAddress_DIV0 #B_PointName0').text(a);
				}
				if(end!=null){
					var b=$('#B_PointName1').val();
					$('#menu_ll #RouteAddress_DIV1 #B_PointName1').text(b);
				}
				if($('#menu_ll #RouteAddress_DIV0 #B_PointName0').val()!=null&&
						$('#menu_ll #RouteAddress_DIV1 #B_PointName1').val()!=null){
					clearInterval(searchpictime);
					searchpictime=null;
				}
			};
						
		}		
	/*******2017-02-20 zss add end **********/
	});
	/** 点击清空起点时*/
	$("#left-panel #inputclearstart").click(function(){
		document.getElementById("inputstart").value="";
		 $(".menu_ll").css('display','none');
		 $("#left-panel #cards-level1").css('display','none');
		 $(".button-print").css('display','none');  
		
		
	});
	/** 点击清空止点时*/
	$("#left-panel #inputclearend").click(function(){
		document.getElementById("B_PointName1").value="";
		 $(".menu_ll").css('display','none');
		 $("#left-panel #cards-level1").css('display','none');
		 $(".button-print").css('display','none');  
	});
	/** 点击切换时*/
	$("#left-panel #routeboxrevert").click(function(){
		var startcontent=$("#inputstart").val();
		var endcontent=$("#B_PointName1").val();
		$("#inputstart").val(endcontent);
		$("#B_PointName1").val(startcontent)
	});
	
	/**2016-11-17 zss add */
	
	/** 点击公交查询时，按钮点击 */
	/**推荐路线*/
	$("#cards-level1 #route_type #type0").click(function(){
		$("#type0").css("background"," #f5f7f7");
		$("#type5").css("background"," #fff");
		$("#type2").css("background"," #fff");
		$("#type3").css("background"," #fff");
		
		
	    clearAllLayer();
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		$("#menu_ll").css('display','block');
		var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
		var transit = new BMap.TransitRoute(map2, {
				renderOptions: {map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},
				policy: 0
			});
	   
		var i='0';
	   search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			transit.setPolicy(route);
			transit.search(start,end);
		}
	});
	/**时间短*/
	$("#cards-level1 #route_type #type5").click(function(){
		$("#type0").css("background"," #fff");
		$("#type5").css("background"," #f5f7f7");
		$("#type2").css("background"," #fff");
		$("#type3").css("background"," #fff");
		
		// 百度地图API功能
		
	    clearAllLayer();
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		$("#menu_ll").css('display','block');
		var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
		var transit = new BMap.TransitRoute(map2, {
				renderOptions: {map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},
				policy: 0
			});
	   
		var i='0';
	    search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			transit.setPolicy(route);
			transit.search(start,end);
		}
		
	});
	/**少换乘*/
	$("#cards-level1 #route_type #type2").click(function(){
		$("#type0").css("background"," #fff");
		$("#type5").css("background"," #fff");
		$("#type2").css("background"," #f5f7f7");
		$("#type3").css("background"," #fff");
		
		// 百度地图API功能
	    clearAllLayer();
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		 var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		$("#menu_ll").css('display','block');
		var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
		var transit = new BMap.TransitRoute(map2, {
				renderOptions: {map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},
				policy: 0
			});
	   
		var i='1';
		search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			transit.setPolicy(route);
			transit.search(start,end);
		}
			
			
	});
	/**少步行*/
	$("#cards-level1 #route_type #type3").click(function(){
		$("#type0").css("background"," #fff");
		$("#type5").css("background"," #fff");
		$("#type2").css("background"," #fff");
		$("#type3").css("background"," #f5f7f7");
		// 百度地图API功能
		
	    clearAllLayer();
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		 var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		$("#menu_ll").css('display','block');
		var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
		var transit = new BMap.TransitRoute(map2, {
				renderOptions: {map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},
				policy: 0
			});
	   
		var i='2';
		search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			transit.setPolicy(route);
			transit.search(start,end);
		}
			
	});
	/** 点击驾车查询时，按钮点击 */
	/**推荐路程*/
	$("#cards-level1 #nav_container #type1").click(function(){
		$("#type1").css("background"," #f5f7f7");
		$("#type4").css("background"," #fff");
		$("#type6").css("background"," #fff");
		
	    clearAllLayer(); 
	    $("#menu_ll").css('display','block');
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		 var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		//三种驾车策略：最少时间，最短距离，避开高速
		var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
		
		var i='0';
		search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			var driving = new BMap.DrivingRoute(map2, {renderOptions:{map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},policy: route});
			driving.search(start,end);
		}
		
	});
	/**最短路程*/
	$("#cards-level1 #nav_container #type4").click(function(){
		$("#type1").css("background"," #fff");
		$("#type4").css("background"," #f5f7f7");
		$("#type6").css("background"," #fff");
		
		// 百度地图API功能
	    clearAllLayer(); 
	    $("#menu_ll").css('display','block');
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		 var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		//三种驾车策略：最少时间，最短距离，避开高速
		var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
		var i='1';
		search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			var driving = new BMap.DrivingRoute(map2, {renderOptions:{map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},policy: route});
			driving.search(start,end);
		}
		
		
	});
	/**不走高速*/
	$("#cards-level1 #nav_container #type6").click(function(){
		$("#type1").css("background"," #fff");
		$("#type4").css("background"," #fff");
		$("#type6").css("background"," #f5f7f7");
		
		// 百度地图API功能
	    clearAllLayer(); 
	    $("#menu_ll").css('display','block');
	    map2.centerAndZoom(new BMap.Point(lng,lat),15);
		 var start=$("#inputstart").val();
		var end=$("#B_PointName1").val();
		//三种驾车策略：最少时间，最短距离，避开高速
		var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
		
		var i='2';
		search(start,end,routePolicy[i]); 
		function search(start,end,route){ 
			var driving = new BMap.DrivingRoute(map2, {renderOptions:{map: map2,panel:"menu_ll",onResultsHtmlSet : function(){$("#menu_ll").show()}},policy: route});
			driving.search(start,end);
		}
		
	});
	
/**2016-11-17 zss add end  */
	
/** *******************************************        */	
//	清除所有的图标
	$("#endroutebutton1").click(function(){
		clearAllLayer();
		$("#sole-input").val("");
		$("#startroutebutton").css('display' ,'block');
		$("#endroutebutton1").css('display','none');
		$("#menu_r").css('display','block');
		$(".menu_l").css('display','none');
		$("#menu_l1").css('display','none');
		$("#menu_detail").css('display','none');
		$(".search-around").css('display','none');
		$(".menu_ll").css('display','none');
		$("#plane_panel").css('display','none');
		$(".train_panel").css('display','none');
		$("#bus_panel").css('display','none');
		$("#taxi_legend").css('display','none');
	//	bibycleLayerNum = 0;
	});
	

	initMap2();
	
	function initMap2(){
	    createMap2();//创建地图
	    setMapEvent2();//设置地图事件
	    clicksearch();
	}
	//创建地图函数：
	function createMap2(){
	    map2 = new BMap.Map("baidumap2");//在百度地图容器中创建一个地图
	    var point2 = new BMap.Point(120.180335,33.38817);//定义一个中心点坐标120.162043,33.342439
	    map2.centerAndZoom(point2,14);//设定地图的中心点和坐标并将地图显示在地图容器中
	    
	    /*************************************/
//		var geolocation = new BMap.Geolocation();
//		geolocation.getCurrentPosition(function(r){
//			if(this.getStatus() == BMAP_STATUS_SUCCESS){
//				
//				var pointR = new BMap.Point(r.point.lng,r.point.lat);//定义一个中心点坐标
//			    map2.centerAndZoom(pointR,14);//设定地图的中心点和坐标并将地图显示在地图容器中
//			    //注释之后可以自己添加定位图标
//				map2.panTo(r.point);
//				addMarker2(r.point);  
//				lng=r.point.lng;
//				lat=r.point.lat;
//				console.log('您的位置：'+r.point.lng+','+r.point.lat);
//			}
//			else {
//				console.log('failed'+this.getStatus());
//			}        
//		},{enableHighAccuracy: true})
		
		
		
	    
	    // 添加百度地图监听事件
		map2.addEventListener('zoomend',findTaxi);
	    window.map2 = map2;//将map变量存储在全局
	}
	
	//更换定位图标
	function addMarker2(point){  // 创建图标对象     
		
        var myIcon = new BMap.Icon("assets/images/iconLoc.png", new BMap.Size(15, 15), {offset: new BMap.Size(10, 25)});  
        // 创建标注对象并添加到地图     
        var marker = new BMap.Marker(point, {icon: myIcon});      
        map2.addOverlay(marker);  
    }  
	
	
	//地图事件设置函数：
	function setMapEvent2(){
	    map2.enableScrollWheelZoom();//启用地图滚轮放大缩小
	    map2.enableKeyboard();//启用键盘上下左右键移动地图
		map2.addControl(new BMap.ScaleControl()); // 添加比例尺控件
		map2.addControl(new BMap.NavigationControl({
			// 靠左上角位置
		    anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
		    // LARGE类型
		    type: BMAP_NAVIGATION_CONTROL_SMALL,
		    // 启用显示定位
		    enableGeolocation: false, // 会多出一个点
		    offset:new BMap.Size(20,20)
		})); // 添加平移缩放控件
		rttCtrl=new BMapLib.TrafficControl();
		map2.addControl(rttCtrl); 
		
		
		
		
		
		
		/************2017.07.03祥叔要求添加定位***2017.7.26注释zhangyn***********************/
		 // 添加定位控件
//		  var geolocationControl = new BMap.GeolocationControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT,offset:new BMap.Size(15,50)});//, enableAutoLocation: true
//		  
//		  geolocationControl.addEventListener("locationSuccess", function(e){
//		    // 定位成功事件
//		    var address = '';
//		    address += e.addressComponent.province;
//		    address += e.addressComponent.city;
//		    address += e.addressComponent.district;
//		    address += e.addressComponent.street;
//		    address += e.addressComponent.streetNumber;
//		    console.log("当前定位地址为：" + address);
//		  });
//		  geolocationControl.addEventListener("locationError",function(e){
//		    // 定位失败事件
//			  console.log(e.message);
//		  });
//		  map2.addControl(geolocationControl);
		
		
		
		$("#tcBtn").click();
		
	}
	
	function test_check8(){/**原为test_check2 zss 更改为现值，如若更改请告知  */
		var busline = new BMap.BusLineSearch(map2,{
		    renderOptions:{map:map2},
		        onGetBusListComplete: function(result){
		           if(result) {
		             var fstLine = result.getBusListItem(0);//获取第一个公交列表显示到map上
		             busline.getBusLine(fstLine);
		           }
		        }
		});
		function busSearch(busName){
		   
		    busline.getBusList(busName);
		}

		var inter;
//		clearAllLayer();
		var availableTags=['1路','2路','3路','4路','5路','6路','7路','8路','9路','123路','456路','789路','10路','82路','91路','交通事故','车辆故障','施工养护','危化品事故处理'];
		$(".search_box_div").css("visibility","visible");
		$("#autocomplete").click(function(){
			$("#menu_r").show();
			
		});
		
		$("#autocomplete").autocomplete({source: availableTags});
		
	}
	//仿照百度地图的搜索框
	$("#sole-input").click(function(){
//		addMarkerLoc();
		$("#menu_r").show();
		$("#menu_l1").css('display','none');
		$("#menu_taxi").css('display','none');
		$("#menu_detail").css('display','none');
		$(".notfound").css('display','none');
		$(".search-around").css('display','none');
		$(".menu_ll").css('display','none');
		clearAllLayer();
		$("#plane_panel").css('display','none');
		$(".train_panel").css('display','none');
		$("#bus_panel").css('display','none');
//		addMarkerLoc();
		
		
		/*******************以上 zhangyn 2016.12.26修改**********/
	});
	}
	// 定时刷新出租车图层
	setInterval("refreashTaxiLayer()",60000);
	//定时刷新公共自行侧图层
//	setInterval("refreashBibycleLayer()",60000);

});


//点击地图上的图标显示出详细的信息列表
function show2(id){
	if(!id){
	  return;
	}
		var markers = map2.getOverlays();
            for (var i = 0; i < markers.length; i++) {
                if (markers[i].toString() == "[object Marker]") {
                    if (markers[i].id == id) {
                        markers[i].openInfoWindow(markers[i].infoWindow_contentHTML);
						break;
                    }
                }
            }
}

function showinfoWindow(markerNew,contentHTML){
var infoWindow = new BMap.InfoWindow(contentHTML);
markerNew.infoWindow_contentHTML=infoWindow;
markerNew.addEventListener("click",function(){
		this.openInfoWindow(infoWindow);
});

map2.addOverlay(markerNew);
}
