`

myMapTag

阅读更多
var tagpoint = {};
var tagline = {};
var magtype = "";
function mapTagCallBack(geo,type){
	magtype = type;
	if(type == "point"){
		tagpoint = geo;
	}else{
		tagline = geo;
	}
	markDlg();
}

/**
 * 地图标记dialog 
 */
function markDlg(lon,lat){
	art.dialog({id:'mark'}).close();
	art.dialog({
		id: "mark",
		title:"<span style='background:no-repeat;padding-left:20px;'>地图标记</span>",
		padding: '5px',
		content: $('#markDiv')[0],
		drag:true,
		close:function(){
			$("#markName").val("");
			$("#nullAlam").text(" ");
		}
	});
}

/**
 * 地图标记列表dialog
 */
function markListDialog(){
	$("#markBtn").addClass("focus");
	art.dialog({id:'markListDiv'}).close();
	art.dialog({
		id: "markListDiv",
		title:"<span style='background:no-repeat;padding-left:20px;'>地图标记</span>",
		padding: '5px',
		content: $('#markListDiv')[0],
		follow:$("#fullsc")[0],
		drag:true,
		close:function(){
			$(".quickSearch .focus").removeClass("focus");
			removeAllMapTag();
		}
	});
	/*var This = this;
    var $dialog = $("<div id='maptagDiag' style='color:#838383;display:none;position:absolute;left:1170px;top:105px;border: 1px solid #ccc;padding: 10px;box-shadow: #aaa 1px 1px 5px;background: #eee;width: 250px; height: 300px;'>" +
            "<h3 style='margin-bottom: 5px;margin-left: 215px;'><a onclick='closeDiag();' style='cursor:pointer'>关闭</a></h3>" +
            "<h3 style='margin-bottom: 5px;'>地图标记:</h3>" +
			"<div style='width: 250px;'>"+
			"<p align='center' style='margin-top: 5px;height: 25px;'>"+	
			"<span>名&nbsp;&nbsp;称:</span>"+		
			"<input type='text' id='mapTagSear' placeholder='&nbsp;请输入名称' class='searchTip inputC'/>"+		
			"<input type='button' class='btn_search' id='btnMarkSearch' value='查询' onclick='getMark();' style='width: 40px;height: 25px;'/>"+		
			"<span id ='markSearchCount' style='float:right;color:orange;height: 24px;line-height: 24px;'>"+
			"</span>"+		
			"</p>"+
			"</div>"+
			"<div class='result' style='width:240px;height:260px;'>"+
	        "<table id='maptagtable' class='yfTable'>"+
			"</table>"+
			"</div>"+	
            "</div>");
    $dialog.appendTo("body");
    $("#maptagDiag").show();*/

}

function closeDiag(){
	$("#maptagDiag").hide();
	removeAllMapTag();
}
/**
 * 添加标记
 */
function addMark(){
    if($("#markName").val() == ""){
       $("#nullAlam").text("请输入标记名称");
        return; 
        }
    var name = $("#markName").val();
    if(magtype == "point"){
    	var paths = tagpoint.x + ',' + tagpoint.y;
        var geometry = 1;
    }else{
    	var paths = tagline.paths.toString();
    	var geometry = 2;
    }
    Sk.Net.postJson("command",{cmd:"gueryMapTagList"},function(data){
    	json = data.datas.mapTagList;
    	var flag = false;
    	for(var i in json){
    		if(json[i].paths==paths){
    			flag=true;
    			break;
    		}
    	}
    	if(flag==true){
    		diagMapTag();
		art.dialog({id:'mark'}).close();
	}else{
		Sk.Net.postJson("command",{cmd:"addMapTag",name:name,paths:paths,geometry:geometry},function(data){
 	});
 		art.dialog({id:'mark'}).close();
 		markListDialog();
 		getMark();
	}
   });
}
/**
 * 提醒重复标记dialog
 */
function diagMapTag(){
	artDialog({   
        content:'此处已被标记!',
        lock:true,
        ok:function(){
        	close:true;
        }
    });
}

/**
 * 查询标记
 */
function getMark(val){
	var name = $("#mapTagSear").val();
	if(isNaN(name)){
		$.extend(condition,{name:name});
	}
	condition = {name:name,geometry:val} ;
	var opts = $.extend({cmd :"gueryMapTagList"}, condition);
	Sk.Net.postJson("command",opts, function(data){	
		json = data.datas.mapTagList;
		layerControl.clear("maptag");
		for(var i in json){
			var point;
			mapManager.map.infoWindow.show();
			layerControl.show("maptag");
			if(json[i].geometry==1){
			  json[i].longitude = json[i].path[0].longitude;
			  json[i].latitude = json[i].path[0].latitude;
			  json[i].geometry = json[i].geometry;
			}else if(json[i].geometry==2){
			  var linePoints = {
					pointArray:[], 
					spatialReference:4326
			  };
			  linePoints.pointArray.push([]);
			  if (json[i].path != null) {
				for (var count = 0; count < json[i].path.length; count++) {
					var lonlat = json[i].path[count];
					if (lonlat != null ) {
						linePoints.pointArray[0].push([lonlat.longitude, lonlat.latitude]);
					}
				}
			  }
			  json[i].linePoints = linePoints;
			}
		}
		layerControl.setDatas("maptag",json);
		$("#maptagtable").yfTable("setDatas",data.datas.mapTagList);
		return;
	});	
}

/**
 * 表格行点击
 */
function rowClick(event){
};

/**
 * 删除标记
 */
function deleteMapTag(val){
	artDialog({   
        content:'确定删除该条标记?',
        lock:true,
        ok:function(){
        	Sk.Net.postJson("command",{cmd:"delMapTag",id:val},function(data){
        		getMark();
        	});
        }
    });
}

/**
 * 隐藏地图标记
 */
function removeAllMapTag(){
	mapManager.map.infoWindow.hide();
	layerControl.hide("maptag");
	$(".event_infor").fadeOut("slow");
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics