/**
 * ShowInMap 地图显示类
 * 
 * title------标题 默认值：''空字符串 contentUrl ------要显示的页面（页面的绝对路径）默认值：''空字符串
 * operationType-----业务类别，标识数据的类别，在地图上显示时确定图标， 默认值：''空字符串 sharpType -------图形类型，
 * 默认值：''空字符串 lonlatData -----------经纬度数据 [ {x:100,y:90} ]默认值：[] 空数组 isMaxed
 * --------是否能放大（是否有放大按钮，true/false，当为真时bigUrl，bigWidth，bigHeight必须有值） 默认值：false
 * isClosed------是否能关闭 默认值：true width------弹出框高度：width 默认值：300
 * heigth------弹出框宽度：heigth 默认值：400 bigUrl------放大后的URL （页面的绝对路径） 默认值：''空字符串
 * bigWidth------ Popup弹出框高度 默认值：400 bigHeigth------ Popup弹出框宽度 默认值：500
 * isPopup------是否显示Pouup 默认值：false style------图型样式 默认值：{}
 */
  

ShowInMap1 = function(obj) {
	// 读取配置参数
	config = obj || {};
	// 定义对象属性默认值
	this.title = '';
	this.operationType = '';
	this.sharpType = '';
	this.lonlatData = [];
	this.width = 200;
	this.heigth = 150;
	this.eventId = '';
	this.ContentHTML = '';
	this.airTemperature = '';
	this.windDirection='';
	this.windSpeed='';
	this.yuliang='';
	// 定义标题Title
	if (config.title) {
		this.title = config.title;
	}

	// 定义operationType
	if (config.operationType) {
		this.operationType = config.operationType;
	}
	// 定义sharpType
	if (config.sharpType) {
		this.sharpType = config.sharpType;
	}
	// 定义lonlatData
	if (config.lonlatData) {
		this.lonlatData = config.lonlatData;
	}
	// 定义width
	if (config.width) {
		this.width = config.width;
	}
	// 定义heigth
	if (config.heigth) {
		this.heigth = config.heigth;
	}
	// 定义事件ID
	if (config.eventId) {
	   this.eventId = config.eventId;
	}
	// 定义引入html
	if (config.ContentHTML) {
		this.ContentHTML = config.ContentHTML;
	}
	//定义气象温度
	if (config.airTemperature) {
		this.airTemperature = config.airTemperature;
	}
		//定义气象风向
	if (config.airTemperature) {
		this.windDirection = config.windDirection;
	}
		//定义气象风速
	if (config.airTemperature) {
		this.windSpeed = config.windSpeed;
	}
			//定义气象雨量
	if (config.yuliang) {
		this.yuliang = config.yuliang;
	}
	/**
	 * 在地图上显示
	 */
	this.show = function() {
		
		if (this.sharpType == 'point') {
			var ll = new MLngLat(this.lonlatData[0].x,this.lonlatData[0].y,1);
			var ih = this.heigth - 30;
			popupContentHTML = this.ContentHTML;
			var icon='';
			if (this.operationType) {
				var icon_config = OPERATIONTYPE[this.operationType];
				if (icon_config)
					icon =icon_config.src;
				else
					icon = '';
			}
				  
			var w = this.width;
			var h = this.heigth;
					
			var mark = "";
			if(this.operationType.indexOf("icon")>=0){
				mark = addMarker(ll, popupContentHTML, icon, w, h, this.title,this.eventId,this.airTemperature,this.windDirection,this.windSpeed,this.yuliang,this.operationType);	
			}else{
				mark = addMarker1(ll, popupContentHTML, icon, w, h, this.title,this.eventId,this.airTemperature,this.windDirection,this.windSpeed,this.yuliang,this.operationType);			
			}
			return mark;
		}

	}
}


// 添加mark
function addMarker(ll,popupContentHTML, icon,w, h, title,eventId,airTemperature,windDirection,windSpeed,yuliang,operationType) {
		
		var tipOption = new MTipOptions(); 
  		tipOption.title=title;   
  		var a = w - 40;
		var b = h-65;
		tipOption.content= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td>"
				+ "<hr style=\"padding-left:10px;\"  width=\"100%\" size=\"2\" noshade=\"noshade\" color=\"#509BCB\" />"
				+ "<\/td>"
				+ "<\/tr>"
				+ "<tr>"
				+ "<td style=\"align:center;padding-left:12px\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\""
				+ a 
				+ "px\" height=\""
				+ b
				+ "px\" align=\"center\"><div width=\"90%\" style=\"overflow:auto;overflow-x:hidden;\" id=\"popupContent\">"
				+ popupContentHTML // popup内的显示的具体内容
				+ "<\/div><\/td>"
				+ "<\/tr>"
				+ "<\/table><\/td>"
				+ "<\/tr>"
				+ "<tr>" + "<td height=\"2\">&nbsp;<\/td>" + "<\/tr>" + "<\/table>";
		//当属性值为FLASHTIP时，显示flash tip 
  		//tipOption.tipType=DIVTIP; 
  		tipOption.tipType=HTML_BUBBLE_TIP;
  		tipOption.tipAlign=TOP_LEFT;
	  	if (w && h) {
			tipOption.tipWidth=w;
			tipOption.tipHeight=h;
		} else {
			tipOption.tipHeight=160;
			tipOption.tipWidth=250;
		} 
		//tipOption.borderStyle.thickness=2;
		//tipOption.borderStyle.color= 0xff230b;
		//tipOption.borderStyle.alpha=1;
  		var labelOption = new MLabelOptions(); 
  		//labelOption.fontStyle.name="Arial";   
 		//labelOption.fontStyle.size=13;   
 		labelOption.fontStyle.color= 0x0033f0; 
  		//labelOption.fontStyle.bold=true; 
  		labelOption.alpha=1;
  		var aa=airTemperature+"℃\n"+windDirection+"风\n"+windSpeed+"级\n"+yuliang;
  		labelOption.content=aa;
  		var markerOption = new MMarkerOptions();
  		if(operationType.indexOf('weather')>=0){
  			markerOption.labelOption=labelOption; //标注 
  		}
  		markerOption.labelAlign=6;
  		markerOption.picAgent=false; 
		markerOption.imageUrl = icon;
        markerOption.isDraggable=false;//是否可以拖动       
  		markerOption.imageAlign=5;//设置图片锚点相对于图片的位置      
  		markerOption.tipOption = tipOption;      
  		markerOption.canShowTip= true;  
  		var Mmarker = new MMarker(ll,markerOption);   
  		Mmarker.id=eventId;   
  		//if(Mmarker.lnglat.lngX!=0&&Mmarker.lnglat.latY!=0)
  		mapObjSearch.addOverlay(Mmarker,false); 
  		if(operationType.indexOf('infoboard')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openInfoboardTip); 
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_CLOSE,closeInfoboardTip);
  			
  		}else if(operationType.indexOf('video')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openVideoTip); 
  			
  		}else if(operationType.indexOf('weather')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openWeatherTip);
  			
  		}else{

  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openEventTip); 
  			
  		}
		return Mmarker;
}

// 添加mark
function addMarker1(ll,popupContentHTML, icon,w, h, title,eventId,airTemperature,windDirection,windSpeed,yuliang,operationType) {

		var tipOption = new MTipOptions(); 
  		tipOption.title=title;   
  		var a = w - 40;
		var b = h-65;
		tipOption.content= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td>"
				+ "<hr style=\"padding-left:10px;\"  width=\"100%\" size=\"2\" noshade=\"noshade\" color=\"#509BCB\"/>"
				+ "<\/td>"
				+ "<\/tr>"
				+ "<tr>"
				+ "<td height=\""
				+ b
				+ "px\">" 
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\""
				+ a 
				+ "px\" height=\""
				+ b
				+ "px\"  style=\"padding-left:13px;\">" 
				+ "<div style=\"height:"
				+ b
				+ "px;overflow:auto; overflow-y:hidden;text-align:center; display: table-cell;\">"
				+ "<div style=\"text-align:center; display: table-cell;margin-top:expression((parentElement.offsetHeight-this.offsetHeight)/2);>"
				+ "<div style=\"margin-top:expression((parentElement.offsetHeight-this.offsetHeight)/2); width:"
				+ a
				+ "px; height:"
				+ b
				+ "px;\" id=\"popupContent\">"
				+ popupContentHTML // popup内的显示的具体内容
				+ "<\/div>" 
				+ "<\/div>" 
				+ "<\/div>" 
				+ "<\/td>"
				+ "<\/tr>"
				+ "<\/table>"
				+ "<\/td>"
				+ "<\/tr>"
				+ "<tr>" 
				+ "<td height=\"2\">&nbsp;<\/td>" + "<\/tr>" + "<\/table>";
		//当属性值为FLASHTIP时，显示flash tip
  		//tipOption.tipType=DIVTIP;  
  		tipOption.tipType=HTML_BUBBLE_TIP;
  		tipOption.tipAlign=TOP_LEFT;
	  	if (w && h) {
			tipOption.tipWidth=w;
			tipOption.tipHeight=h;
		} else {
			tipOption.tipHeight=160;
			tipOption.tipWidth=250;
		} 
		//tipOption.borderStyle.thickness=2;
		//tipOption.borderStyle.color= 0xff230b;
		//tipOption.borderStyle.alpha=1;
  		var labelOption = new MLabelOptions(); 
  		//labelOption.fontStyle.name="Arial";   
 		//labelOption.fontStyle.size=13;   
 		labelOption.fontStyle.color= 0x0033f0; 
  		//labelOption.fontStyle.bold=true; 
  		labelOption.alpha=1;
  		var aa=airTemperature+"℃\n"+windDirection+"风\n"+windSpeed+"级\n"+yuliang;
  		labelOption.content=aa;
  		var markerOption = new MMarkerOptions();
  		if(operationType.indexOf('weather')>=0){
  			//标注
  			markerOption.labelOption=labelOption;
  		}
  		markerOption.labelAlign=6;
  		markerOption.picAgent=false; 
		markerOption.imageUrl = icon;
		//是否可以拖动
        markerOption.isDraggable=false;
        //设置图片锚点相对于图片的位置
  		markerOption.imageAlign=5;      
  		markerOption.tipOption = tipOption;      
  		markerOption.canShowTip= true;            
  		var Mmarker = new MMarker(ll,markerOption);   
  		Mmarker.id=eventId;   		
  		mapObjSearch.addOverlay(Mmarker,false); 
  		if(operationType.indexOf('infoboard')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openInfoboardTip); 
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_CLOSE,closeInfoboardTip);
  			
  		}else if(operationType.indexOf('video')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openVideoTip);
  			
  		}else if(operationType.indexOf('weather')>=0){
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openWeatherTip);
  			
  		}else{
  			
  			mapObjSearch.addEventListener(Mmarker,TIP_OPEN,openEventTip); 
  			
  		}
		return Mmarker;
}

	function openEventTip(e){ 
		//显示事件图片
		showEventImg(e.overlayId);
		//模板统计
  		saveVisitModules(6);
	} 
	
	/**
	 * 打开情报板tip
	 */
	function openInfoboardTip(e){ 
		var infoBoardClass = new InfoBoardClass();
		infoBoardClass.getData(e.overlayId);
		//模板统计
  		saveVisitModules(3);
	} 
	
	/**
	 * 关闭情报板tip
	 */
	function closeInfoboardTip(e){ 
		var infoBoardClass = new InfoBoardClass();
		//停止监控
		infoBoardClass.stopMonitorData();
	} 
	
	/**
	 * 打开视频tip
	 */
	function openVideoTip(e){ 
		
		var video = new VideoClass(); 
		video.makeVideoPage(e.overlayId);
		//模板统计
  		saveVisitModules(4);
	} 
	
	/**
	 * 打开气象tip
	 */
	function openWeatherTip(e){ 
		//模板统计
  		saveVisitModules(1);
	}
	
