" + sd + " - " + td + "
"
text += "
" + sd + " - " + td + ""
+"
ผู้รายงาน: "+testdiv.info.contributor+"
"
+ "
ทางหลวง #" + testdiv.info.routeno + ", กม. ที่ " + testdiv.info.km +
((testdiv.info.kmstop)?(' ถึง ' + testdiv.info.kmstop):'') + "
"
+ "
ทิศทาง: "
+ testdiv.info.direction + "
"
+ "
บริเวณ: "
+ testdiv.info.nearplace + "
"
+ "
รายละเอียด: "
+ ((testdiv.info.comment != "")?testdiv.info.comment:"-")
+((testdiv.info.img != '')?"
":'')+" ";
var popuptext = text
+ (OFFICER?("
[แก้ไข]
"):'');
newpointarray[pointcount] = mmmap.drawCustomDivLevelWithPopup(testdiv, r.result[i].latitude, r.result[i].longitude, popuptitle, 4, 14, popuptext);
newpointarrayinfo[pointcount] = testdiv.info;
accident_customdiv[testdiv.info.id] = pointcount;
// add gpoint
if (gmapjsloaded) {
var point = new GLatLng(r.result[i].latitude, r.result[i].longitude);
var marker = new GMarker(point, gicon[testdiv.info.severity - 1]);
marker.mm_isdesc = true;
marker.mm_desc = "
" + popuptitle + "" + text;
newgpointarray[pointcount] = marker;
gmap.gmap_object.addOverlay(marker);
}
pointcount++;
} else {
newpointarray[pointcount] = pointarray[matchindex];
newpointarrayinfo[pointcount] = pointarrayinfo[matchindex];
pointarray[matchindex] = -1;
accident_customdiv[testdiv.info.id] = pointcount;
pointcount++;
}
}
for(i=0;i
[close]';
//imgdiv.style.position = 'absolute';
//imgdiv.onClick = function(){alert("lost");}
//imgdiv.style.width = document.getElementById('mmmap_div').style.width;
//imgdiv.style.height = document.getElementById('mmmap_div').style.height;
//document.getElementById('mmmap_div').style.filter = 'alpha(opacity=50)';
//document.getElementById('mmmap_div').style.opacity = 0.4;
//mmmap.drawCustomDiv(imgdiv, latitude, longitude, "");
document.getElementById('imagefrompolice').appendChild(imgdiv);
}
}
function closeFullImg(id)
{
var todel = document.getElementById(id);
todel.parentNode.removeChild(todel);
if( document.getElementById('imagefrompolice').innerHTML=='') {
document.getElementById('imagefrompolice').style.visibility = "hidden";
}
}
// ---- END -- Draw Accident
// ---- BEGIN -- News Update & Rotate
function map_flyto(lat,lng, id, src){
if (currentmode == 'gmap') {
gmap.gmap_object.panTo(new GLatLng(lat, lng));
//alert('true');
} else {
mmmap.moveTo(lat,lng);
//alert('false');
if (id) {
// alert('src:'+src+'\n'+'id:'+id+'\n'+pointarray[accident_customdiv[id]]);
var dvid = (src=='oldevents')?id:pointarray[accident_customdiv[id]];
//alert(mmmap.getCustomDiv(dvid));
mmmap.getCustomDiv(dvid).onclick();
}
}
}
newsname = ['stat','news','news2'];
function dl(dnews){
//alert('dl');
json_request("http://traffic.thai.net/rpc/getnews.php","newsid=" + dnews,"tvar","updatenews('" + dnews + "')");
}
function updatenews(dnews){
str = "";
var imgurl;
var title;
if (dnews == 1) {
color = [ '#FF9999','#AA3333', ["#FFE1D5", "#FFEDE3"] ];// #FFD9D9 #FFBCBC
typetext = ["","warning", "danger", "don't pass","construstion"];
str = "";
var today = new Date();
today.setHours(0,0,0,0);
for(i=0;i" + title + "";
}
}
document.getElementById("newsdiv_body").innerHTML = str;
curevents = str;
//------nutt added--------
eventpage = 0;
getNextEventsSet(1);
//alert('ok');
//-----------------------
} else if (dnews == 2) {
color = [ '#AAFF99', '#66AA33', ["#E9FFD9", "#CCFFBC"] ];
trafficcolor = ['#AAFFAA','#AAFFAA','#FFD9BC', '#FFBCBC'];
trafficcolorborder = ['#AAFFAA','#AAFFAA','#D9BCA0', '#FFA0A0'];
//str += "";
//------nutt added------------------------
var today = new Date();
today.setHours(0,0,0,0);
//----------------------------------------
for(i=0;i" + title + "";
//str += "";
//str += "| " + title + " |
";
}
//str += "
";
/*------------- uncomment this when use police report-----------
document.getElementById("news2div_body").innerHTML = str;
---------------------------------------------------------------*/
}
/*
if (fflush == true) {
setTimeout("dl('" + (((dnews+1)%2)+1) + "')", 50);
if ((dnews+1)%(newsname.length) == 0)
fflush = false;
} else {
if (updateinterval != -1) {
setTimeout("dl('" + (((dnews+1)%2)+1) + "')", updateinterval);
}
}
*/
setTimeout("resizenewsdiv()", 100);
}
// ---- END -- News Update & Rotate
// ---- BEGIN -- tab management
function tabupdate(tname){
tarray = ['main', 'search', 'route', 'help'];
if ((tname != null) && (activetab != tname)) {
for(i=0;iแก้ไข]';
} else {
var textarea = document.createElement("textarea");
textarea.innerHTML = (container.innerHTML=='-')?'':container.innerHTML;
container.orgtext = container.innerHTML;
textarea.style.padding = 0;
textarea.style.width = container.offsetWidth;
if (container.offsetHeight < 20)
textarea.style.height = 20;
else
textarea.style.height = container.offsetHeight + 3;
textarea.onkeyup = function () {
if (this.scrollHeight > this.offsetHeight)
this.style.height = this.scrollHeight + 3;
};
textarea.onmousedown = function (e){
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
e.returnValue = false;
}
container.innerHTML = "";
container.appendChild(textarea);
textarea.focus();
document.onkeydown='return true';
container.editing = true;
editlabel.innerHTML = '[บันทึก | ยกเลิก]';
}
}
function drawtraffic(id){
colorcode = ["#666666", "#33FF33","#FFFF00","#FF2020","","#0000AA"];
textcode = ["nodata", "Flow","Slow","Block"];
mmmap.gssetlinewidth(3);
mmmap.gssetopacity(0.7);
if ((roaddata[id] && roaddata[id].present) && (roaddata[id].change || !roaddata[id].opresent)) {
if (roaddata[id].shape) {
mmmap.removeVector(roaddata[id].shape);
roaddata[id].shape = false;
}
if (roaddata[id].glshape) {
gmap.gmap_object.removeOverlay(roaddata[id].glshape);
roaddata[id].glshape = false;
}
if ((roaddata[id].status >= 0) && (roaddata[id].points.length > 1)) {
var sls = showlinestart;
var slp = showlinestop;
var detail = " ";
var detailpopup = "";
detail += "รหัส: " + id
+ " กม.: " + roaddata[id].meta.startkm + "-" + roaddata[id].meta.stopkm
+ "
ช่วง: "
+ '' + ((roaddata[id].description=='')?'-':roaddata[id].description) + '
';
if (!showadroute)
detail += "ล่าสุด: " + roaddata[id].lastupdate.substr(roaddata[id].lastupdate.indexOf(' ') + 1, 5) + "
";
if (traffic_draw_mode == 'edit') {
detailpopup += "รหัส: " + id
+ " กม.: " + roaddata[id].meta.startkm + "-" + roaddata[id].meta.stopkm
+ '[แก้ไข]
'
+ "
ช่วง: "
+ '' + ((roaddata[id].description=='')?'-':roaddata[id].description) + '
'
+ "ล่าสุด: " + roaddata[id].lastupdate.substr(roaddata[id].lastupdate.indexOf(' ') + 1, 5) + "
";
detailpopup += "คลิกเลือกสถานะ
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
";
sls = showlinestart_edit;
slp = showlinestop_edit;
}
if (showadroute) {
sls = showlinestart_ad;
slp = showlinestop_ad;
}
if (currentmode == "gmap") {
var parr = [];
var x;
var y;
for(var i=0; i= showlinestart && z <= showlinestop) || (traffic_draw_mode == 'edit')) {
if (fetchtraffic != true) {
fetchtraffic = true;
updatetraffic();
}
} else {
fetchtraffic = false;
}
/*
checkfetchtrafficzoomtimer = setTimeout("checkfetchtrafficzoom()", 1000);
*/
}
function showadrouteline(routeid){
/*for(id in roaddata) {
if(roaddata[id].status == 5){
roaddata[id].present = false;
drawtraffic(id);
}
}*/
//json_request("http://traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "arline", "convadrouteline();");
json_request("http://main.traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "arline", "convadrouteline();");
// json_request("http://traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "tresult", "showtraffic();");
}
function convadrouteline(){
//alert(arline);
arline_conv = [];
for(var i in arline)
arline_conv[arline_conv.length] = {'link_id': arline[i], 'status' : 5,'description' : ''};
tresult = {'result' : arline_conv}
//alert(tresult);
showtraffic();
}
function getadroute(groupid){
showadroute = true;
mmmap.hideoverlay();
// hide roads
for(id in roaddata) {
roaddata[id].present = false;
drawtraffic(id);
}
//json_request("http://traffic.thai.net/rpc/getadroute.php", "groupid=" + groupid, "adresult", "showadroutechoice();");
json_request("http://main.traffic.thai.net/rpc/getadroute.php", "groupid=" + groupid, "adresult", "showadroutechoice();");
}
function clearadroute(){
showadroute = false;
mmmap.showoverlay();
for(id in roaddata) {
roaddata[id].present = false;
drawtraffic(id);
}
gettraffic();
}
function showadroutebtn(){
var ac = document.getElementById("adrouteform").adroutechoice;
var sroute = 0;
for(var i=0;i| ลำดับ | '
+'ระยะทาง '
+' |
';
resultn = 'เส้นทางที่ไม่แนะนำ
'
+'| ลำดับ | '
+'ระยะทาง '
+' |
';
for(var i=0;i 0) {
for(var j=0;j'
+ '' + adresult[i].parts[j].distance +'
'
+ adresult[i].parts[j].description
+ '';
}
} else {
pdetail = ''+adresult[i].description+'';
}
var tmp = "."
+ " "+adresult[i].distant+" "
+ "" + adresult[i].routename
+ ((adresult[i].reason != '')?(" ("+adresult[i].reason+") "):'') + " "
// + "" + pdetail + " "
+ " | "
+ "" + pdetail + " |
"
;
if (adresult[i].rank > 0) {
oc++;
resulto += "| "+(oc)+tmp;
} else {
nc++;
resultn += " |
| "+(nc)+tmp;
}
/* result += " " + adresult[i].routename + " "
+ "" + pdetail + " "
+ "";*/
}
}
resulto += ' |
';
resultn += '
';
var tmp = "";
if (oc > 0)
tmp += resulto;
if (nc > 0)
tmp += resultn;
document.getElementById("adrouteresult").innerHTML = tmp;
}
}
function showadroutepart(partid){
mmmap.showPopUp(adroutepart[partid].latitude, adroutepart[partid].longitude, 'เส้นทาง', adroutepart[partid].description);
mmmap.moveTo(adroutepart[partid].latitude, adroutepart[partid].longitude);
}
// ---- END -- draw traffic
function swap_operation_mode(mode){
var tomode = 'edit';
if (mode && mode != '') {
if (mode != 'edit')
tomode = 'normal';
} else {
if (traffic_draw_mode != 'normal')
tomode = 'normal';
}
if (tomode == traffic_draw_mode)
return false;
if (tomode == "normal") {
traffic_draw_mode = "normal";
str = "edit | view";
midbarcolor = "#F6DDDE";
mmmap.setShowOverLay(overlay_reso_start,overlay_reso_stop,"trafficoverlay");
if (!mmmap.ovl_enable) {
mmmap.setAllImagesUsedButNotSetToEmpty();
mmmap.showoverlay();
mmmap.rePaint();
} else {
mmmap.refreshoverlay();
}
} else {
traffic_draw_mode = "edit";
str = "edit | view";
//midbarcolor = "#FFAA00";
midbarcolor = "#FFCD68";
mmmap.setShowOverLay(0,0,"trafficoverlay");
mmmap.hideoverlay();
}
document.getElementById("midbar").style.backgroundColor = midbarcolor;
document.getElementById("operation_mode_div").innerHTML = str;
/*
if (gettraffic_timer) {
clearTimeout(gettraffic_timer);
gettraffic_timer = false;
}
*/
document.getElementById("showtrafficcheckbox").checked = true;
var id;
for (id in roaddata) {
if (roaddata[id]) {
roaddata[id].present = false;
if (roaddata[id].shape) {
mmmap.removeVector(roaddata[id].shape);
roaddata[id].shape = false;
}
}
}
updatetraffic();
}
function officer_trafficstatus_popup(linkid){
window.open('office/updatestatus.php?linkid=' + linkid,"trafficstatus",'status=no,toolbar=no,menubar=no,location=no,resizable=no,width=320,height=220');
}
function switchmapmode(){
var r = document.getElementById('showroadcheck');
var e = document.getElementById('showengcheck');
var f = document.getElementById('showtrafficcheckbox');
var c = document.getElementById('showcameracheckbox');
var mode;
r.disabled = false;
e.disabled = false;
mode = (r.checked?'icons':'traffic') + (e.checked?'-en':'');
mmmap.setMapMode(mode);
mmmap.showCustomDivs();
updateshowtrafficstatus(f.checked);
/*
if (!c.checked) {
// ?!?!?!?
}
*/
mapresize();
}
function setTrafficdataMode() {
var cb = document.getElementById("trafficdatacheckbox");
//alert(cb.checked);
if(cb.checked) {
mmmap.setMapMode("trafficdata");
var f = document.getElementById('showtrafficcheckbox');
f.disabled = true;
updateshowtrafficstatus(false);
}
else {
switchmapmode();
var f = document.getElementById('showtrafficcheckbox');
f.disabled = false;
updateshowtrafficstatus(true);
//mmmap.setMapMode(document.getElementById('showroadcheck').checked?'normal':'traffic');
}
}
function updatestat(){
json_request("http://traffic.thai.net/rpc/getstat.php","","upstatvar","updatestat_callback()");
}
function updatestat_callback() {
document.getElementById("stat_accident_count").innerHTML = upstatvar.incident_count[2];
document.getElementById("stat_construct_count").innerHTML = upstatvar.incident_count[1];
document.getElementById("stat_badcar_count").innerHTML = upstatvar.incident_count[0];
}
// ------------
camera_info = [];
camvar = "";
function popupcamera(camid){
var campopup = window.open('http://main.traffic.thai.net/camview.php?camid=' + camid,"cameraview_"+camid,'status=no,toolbar=no,menubar=no,location=no,resizable=yes,width=720,height=640');
}
function showcameradetail(id){
speedcolor = (camera_info[id].speed >= 80)?'#009900':((camera_info[id].speed >= 30)?'#999900':'#990000');
datetmp = camera_info[id].lastupdate.split(' ')[0];
var dateno = parseInt(datetmp.substr(8,2));
update = dateno + " " + monthShort[parseInt(datetmp.substr(5,2),10) - 1] + " " + (parseInt(datetmp.substr(0,4),10) + 543)%100;
lanes = '';
var unittype = 'กม./ชม.';
if(camera_info[id].location_type=='PK') {
unittype = '%';
}
for(var i=0;i" + camera_info[id].lanes[i].speed + " "+unittype+"
";
}
detail = "ID: " + camera_info[id].camid + ""
//+ '
ข้อมูลเฉลี่ย 1 นาที
'
+"
"
//+ camera_info[id].lanes[0].idlane+":
" + camera_info[id].lanes[0].speed + " กม./ชม.
"
//+ camera_info[id].lanes[1].idlane+":
" + camera_info[id].lanes[1].speed + " กม./ชม.
"
+ lanes
+ ""
+ "
วันที่: "+ update +""
+ ""
+ "
เวลา: "+ camera_info[id].lastupdate.split(' ')[1].substr(0,5) +""
//+ "
[ดูภาพขยาย]
";
+ " "
+ "