";
city_distacne_ctrl.append(tr_tmp)
//显示当前时间序列的台风信息
$.each(typhoon_Data, function (index, content) {
var detail_talbe = "
";
var intlid = content.intlid;
var tscname = content.tscname;
var tsename = content.tsename;
var showName = intlid + tscname + "(" + tsename + ")";
if ("****" == intlid) {
intlid = tscname = tsename = "TD";
showName = "TD";
}
detail_talbe += "
" + showName + "
";
var real_list = content.real;
//按指定字段指定顺序排序
real_list.sort(function (a, b) {
var columnIndex = $("#typhoon_info th[aria-sort!='none']").attr("data-column");//按个列排序(所以从0开始)
var sortDesc = $("#typhoon_info th[aria-sort!='none']").attr("aria-sort");//升序还是降序
var temp = a;
if (sortDesc != "descending") {
a = b;
b = temp
}
switch (columnIndex) {
case "0":
return new Date(b.time) - new Date(a.time);
break;
case "1":
if (b.lon == a.lon) {
return b.lat - a.lat;
} else {
return b.lon - a.lon;
}
break;
case "2":
return b.ws - a.ws;
break;
case "3":
return b.ps - a.ps;
break;
}
});
var changIndex = indexNum;
var json = real_list[changIndex];
var time = new Date(json.time.replace(/\-/g, "\/"))
time = SubHours(time, 8);
detail_talbe += "
";
$(".typhoon-path-point-detail-container").show();
$("#typhoon-path-detail .content .right").empty().append(detail_talbe);
return false;
})
})
}
/** 绘制折线
** points 经纬度数组
** color 线条颜色
** strokeStyle 实线或虚线,solid或dashed
**/
function draw(points, color, strokeStyle)
{
color = color == null ? "black" : color;
if (null == points || points == undefined)
return;
var polyline = new BMap.Polyline(points, { strokeColor: color, strokeWeight: 1.5, strokeOpacity: 1 });
polyline.setStrokeStyle(strokeStyle)
map.addOverlay(polyline);
}
/** 添加标注
** point 经纬度
** color 线条颜色
**/
function addMarker(point, myIcon, sContentjt)
{
var markerjt = new BMap.Marker(point, { icon: myIcon }); // 创建标注
map.addOverlay(markerjt); // 将标注添加到地图中
//创建信息窗口
var infoBoxjt01 = new BMapLib.InfoBox(map, sContentjt, {
offset: { width: 104, height: -2 },
boxStyle: {
width: "280px",
height: "auto"
},
boxClass: "infobox",
closeIconMargin: "30px 8px 0 0",
closeIconUrl: "images/iw_close1d3.gif",
//enableAutoPan: true,
align: INFOBOX_AT_TOP
});
markerjt.addEventListener("mouseover", function () {
//if (infoBoxs != null) infoBoxs.close(); //关闭之前窗口
//infoBoxjt01.open(markerjt);
//infoBoxs = infoBoxjt01; //获取当前对象
infoBoxjt01.open(markerjt)
})
markerjt.addEventListener("mouseout", function () {
infoBoxjt01.close(markerjt)
})
}
//台风信息
function InboBoxContent(tsname, tscode, content, type, fa_name, wf)
{
var sContentjt01 = "
";
sContentjt01 += "
" + tsname + "(" + tscode + ")
";
sContentjt01 += "";
sContentjt01 += "
";
var time = new Date(content.time.replace(/\-/g, "\/"));
time = SubHours(time, 8);
var timestr = time.format('yyyy-MM-dd hh:mm');
if (type == "fst") {
time = SubHours(time, content.leadtime);
timestr = time.format('yyyy-MM-dd hh:mm');
sContentjt01 += "
Forecasting agency:
" + fa_name + "
";
sContentjt01 += "
Arrival Time:
" + timestr + "
";
} else {
sContentjt01 += "
Time:
" + timestr + "
";
}
sContentjt01 += "
Position:
" + content.lon + "°E," + content.lat + "°N
";
if (content.ws != undefined) {
sContentjt01 += "
";
return sContentjt01;
}
//台风列表
var TyphonList = function () {
var minDate = new Date();
var year = minDate.getFullYear();
var t = new Date(year, 0, 1, 0, 0, 0, 0);
$("#typhoonList tr").remove();
$("#typhoonList_history tr").remove();
//$.getJSON(postUrl + "?action=yyphoonlist", function (json) {
$.getJSON("/typhoon/data/typhoonlist.js?t=" + Math.random(), function (json) {
$.each(json, function (index, content) {
var tscname = content.tscname;
var tsename = content.tsename;
var intlid = content.intlid;
if ("****" == intlid)
{
tscname =intlid= tsename = "TD";
}
var mint = content.mint;//台风最早时间
var t2 = new Date(mint.replace(/\-/g, "\/"))
var typhoon_info_tr = $("
" + intlid + "
" + tscname + "
" + tsename + "
");
if (t2 > t) {//当年
typhoon_info_tr.appendTo($("#typhoonList"))
} else {//历年
typhoon_info_tr.appendTo($("#typhoonList_history"));
}
})
$("#typhoonList tr:odd,#typhoonList_history tr:odd").css("background", "#f6f6f6");
Typhoon_radio_Click();
$("#typhoonList input:first").click();
});
}
//选择台风
function Typhoon_radio_Click()
{
$("input[name='typhoon_id']").bind('click', function () {
var tsid = $(this).attr("tsid");
//$.getJSON(postUrl + "?action=real&tsid=" + tsid, function (json) {
$.getJSON("/typhoon/data/real-" + tsid + ".js", function (json) {
typhoon_Data = json;
draCurveLine(json)
});
})
}
//获取预报台
function Getlegend()
{
var legend = new Array();
$("input[name='typhoon-legend']:checked").each(function () {
legend.push($(this).val());
})
return legend;
}
if (!Array.indexOf) {
Array.prototype.indexOf = function (obj) {
for (var i = 0; i < this.length; i++) {
if (this[i] == obj) {
return i;
}
}
return -1;
}
}
})();
function SubHours(nd, hours) {
//date = date.replace(/-/g, "/"); //更改日期格式
//var nd = new Date();
nd = nd.valueOf();
nd = nd + hours * 60 * 60 * 1000;
nd = new Date(nd);
return nd;
//alert(nd.getFullYear() + "年" + (nd.getMonth() + 1) + "月" + nd.getDate() + "日");
var y = nd.getFullYear();
var m = nd.getMonth() + 1;
var d = nd.getDate();
var h = nd.getHours();
var mm = nd.getMinutes();
var ss = nd.getSeconds();
m = m <= 9 ? m = "0" + m : m;
d = d <= 9 ? d = "0" + d : d;
h = h <= 9 ? h = "0" + h : h;
mm = mm <= 9 ? mm = "0" + mm : mm;
ss = ss <= 9 ? ss = "0" + ss : ss;
var cdate = y + "-" + m + "-" + d +" "+h+":"+mm+":"+ss;
//var cdate = y + "/" + m + "/" + d + " " + h + ":00:00";
return cdate;
//调用方法 (注意日期格式)
//console.log(SubHours("2014/4/30 16:40:00",25))
}