public void mapLoad(bool isRoute) { string map_type = ""; int i = 0; string strInfoHtml = ""; int Vessel_Count = 0; int Err_Vessel_Count = 0; string Err_Vessel_Msg = "<table>"; lbtn_error.Visible = false; int Vessel_ID = int.Parse(ddl_veslist.SelectedValue); int Fleet_ID = int.Parse(ddlTechmanager.SelectedValue); try { DataTable dtData = new DataTable(); if (isRoute) { GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); dtData = BLL_OPS_DPL.Get_TelegramData_Route(Vessel_ID, Fleet_ID, Convert.ToDateTime(txtFromDT.Text), Convert.ToDateTime(txtTODT.Text), strReportType); // GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; } else { GoogleMapForASPNet1.GoogleMapObject.AutomaticBoundaryAndZoom = false; GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); dtData = BLL_OPS_DPL.Get_TelegramData(Vessel_ID, Fleet_ID, strReportType); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 3; } //You must specify Google Map API Key for this component. You can obtain this key from http://code.google.com/apis/maps/signup.html //For samples to run properly, set GoogleAPIKey in Web.Config file // GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; GoogleMapForASPNet1.GoogleMapObject.Width = "100%"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "850px"; map_type = htxt_sat_nor_hybrid.Text.ToString(); if (map_type == "satmap") { GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.SATELLITE_MAP; } if (map_type == "hybridmap") { GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.HYBRID_MAP; } if (map_type == "normalmap") { GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.NORMAL_MAP; } if (map_type == "") { GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.NORMAL_MAP; } GoogleMapForASPNet1.GoogleMapObject.MapType = GoogleMapType.HYBRID_MAP; GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); if (dtData.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); GooglePoint[] gp = new GooglePoint[dtData.Rows.Count]; int AreaID = 0; int VertexID = 0; GooglePolygon[] PiracyArea = new GooglePolygon[2]; #region -- Draw Piracy Area -- if (chkPiracyArea.Checked == true) { GoogleMapForASPNet1.GoogleMapObject.Polygons.Clear(); DataTable dt = BLL_OPS_DPL.Get_PiracyArea(); if (dt.Rows.Count > 0) { GooglePolygon PG = new GooglePolygon(); PG.FillColor = "#FF0000"; PG.FillOpacity = 0.3; PG.StrokeColor = "#FF0000"; PG.StrokeOpacity = 1; PG.StrokeWeight = 1; AreaID = UDFLib.ConvertToInteger(dt.Rows[0]["AreaID"].ToString()); GooglePoint GP1 = new GooglePoint(); GP1.ID = "GP" + VertexID.ToString(); GP1.Latitude = UDFLib.ConvertToDouble(dt.Rows[0]["Latitude"].ToString()); GP1.Longitude = UDFLib.ConvertToDouble(dt.Rows[0]["Longitude"].ToString()); foreach (DataRow dr in dt.Rows) { VertexID++; if (AreaID != UDFLib.ConvertToInteger(dr["AreaID"].ToString())) { PG.ID = "PG" + AreaID.ToString(); PG.Points.Add(GP1); GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(PG); PiracyArea[AreaID - 1] = PG; PG = new GooglePolygon(); PG.FillColor = "#FF0000"; PG.FillOpacity = 0.3; PG.StrokeColor = "#FF0000"; PG.StrokeOpacity = 1; PG.StrokeWeight = 1; AreaID = UDFLib.ConvertToInteger(dr["AreaID"].ToString()); GP1 = new GooglePoint(); GP1.ID = "GP" + VertexID.ToString(); GP1.Latitude = UDFLib.ConvertToDouble(dr["Latitude"].ToString()); GP1.Longitude = UDFLib.ConvertToDouble(dr["Longitude"].ToString()); } GooglePoint GP = new GooglePoint(); GP.ID = "GP" + VertexID.ToString(); GP.Latitude = UDFLib.ConvertToDouble(dr["Latitude"].ToString()); GP.Longitude = UDFLib.ConvertToDouble(dr["Longitude"].ToString()); PG.Points.Add(GP); } PG.ID = "PG" + AreaID.ToString(); PG.Points.Add(GP1); GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(PG); PiracyArea[AreaID - 1] = PG; } } else { GoogleMapForASPNet1.GoogleMapObject.Polygons.Clear(); } #endregion if (!isRoute) { #region ---------Draw all vessels icons and baloons-------- foreach (DataRow dr in dtData.Rows) { Vessel_Count++; gp[i] = new GooglePoint(); //string sangle = dr[5].ToString(); string sangle = dr["Vessel_Course"].ToString(); CreateImage(dr["Vessel_Short_Name"].ToString()); string latitude = ""; string longitude = ""; string longi_pos1; string longi_pos2; string lati_pos1; string lati_pos2; decimal lat_degree = 0; decimal lat_min = 0; decimal lat_sec = 0; string slat_dir = ""; decimal long_degree = 0; decimal long_min = 0; decimal long_sec = 0; string slong_dir = ""; try { lat_degree = UDFLib.ConvertToDecimal(dr["Latitude_Degrees"].ToString()); lat_min = UDFLib.ConvertToDecimal(dr["Latitude_Minutes"].ToString()); lat_sec = UDFLib.ConvertToDecimal(dr["Latitude_Seconds"].ToString()); slat_dir = dr["LATITUDE_N_S"].ToString(); if (slat_dir != "N" && slat_dir != "S") { slat_dir = "N"; } latitude = Conv_Deg2Decimal_new(Convert.ToDouble(lat_degree), Convert.ToDouble(lat_min), Convert.ToDouble(lat_sec), slat_dir.ToString()); long_degree = UDFLib.ConvertToDecimal(dr["Longitude_Degrees"].ToString()); long_min = UDFLib.ConvertToDecimal(dr["Longitude_Minutes"].ToString()); long_sec = UDFLib.ConvertToDecimal(dr["Longitude_Seconds"].ToString()); slong_dir = dr["Longitude_E_W"].ToString(); if (slong_dir != "E" && slong_dir != "W") { slat_dir = "E"; } longitude = Conv_Deg2Decimal_new(Convert.ToDouble(long_degree), Convert.ToDouble(long_min), Convert.ToDouble(long_sec), slong_dir.ToString()); if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "N") { gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + ".png"; } else if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "P") { gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + "-P" + ".png"; } gp[i].Latitude = double.Parse(latitude); gp[i].Longitude = double.Parse(longitude); // - check if in piracy area bool iPointInPolygon = PointInPolygon(gp[i], PiracyArea); if (iPointInPolygon == true) { GooglePoint shipInPiracy = new GooglePoint(); shipInPiracy.Latitude = double.Parse(latitude); shipInPiracy.Longitude = double.Parse(longitude); shipInPiracy.IconImage = "../Images/star.gif"; //shipInPiracy.IconImageHeight = 20; //shipInPiracy.IconImageWidth = 20; GoogleMapForASPNet1.GoogleMapObject.Points.Add(shipInPiracy); } string simagename = ""; if (sangle == "" || sangle == null) { simagename = "boat_.png"; } else { Double angle = Convert.ToDouble(sangle); if ((angle >= 0) && (angle <= 90)) { simagename = "UpSide45_f_.png"; } if ((angle >= 90) && (angle <= 180)) { simagename = "UpSide_135_.png"; } if ((angle >= 180) && (angle <= 270)) { simagename = "Down_225_.png"; } if ((angle >= 270) && (angle <= 360)) { simagename = "Down_315_.png"; } } strInfoHtml = "<table border=0 cellspacing=0 cellpadding=0 style='font-size:10px;font-family:Verdana'>"; strInfoHtml += "<tr><td colspan=2 style='font-weight:bold;'>" + dr["Vessel_Name"].ToString() + " <img src='images/" + simagename + "'>" + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Report Date:</td><td style='color:blue;font-weight:bold'>" + dr["infodate"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Location:</td><td>" + dr["Location_Name"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Latitude:</td><td>" + dr["Latitude_Degrees"].ToString() + " " + dr["Latitude_Minutes"].ToString() + " " + dr["Latitude_Seconds"].ToString() + " " + dr["LATITUDE_N_S"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Longitude:</td><td>" + dr["Longitude_Degrees"].ToString() + " " + dr["Longitude_Minutes"].ToString() + " " + dr["Longitude_Seconds"].ToString() + " " + dr["Longitude_E_W"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Course:</td><td>" + sangle.ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Wind Direction/ Force:</td><td>" + dr["Wind_Direction"].ToString() + "/" + dr["Wind_Force"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Average speed:</td><td>" + dr["AVERAGE_SPEED"].ToString() + " knts</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Next port/<br>ETA:</td><td>" + dr["PORT_NAME"].ToString() + "<br>" + dr["etanextport"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'></td><td></td></tr>"; string CrewLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Crew/CrewList_PhotoView.aspx?vcode=" + dr["Vessel_Short_Name"].ToString() + "' target='_blank'>Crew List</a>"; string NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/NoonReport.aspx?LastNoon=" + dr["Vessel_Short_Name"].ToString() + "&ID=" + dr["PKID"].ToString() + "' target='_blank'>Last Noon</a>"; strInfoHtml += "<td>" + CrewLink + "</td><td>" + NoonLink + "</td>"; strInfoHtml += "</tr>"; strInfoHtml += "</table>"; gp[i].InfoHTML = strInfoHtml.ToString(); GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]); i++; } catch { Err_Vessel_Count++; lbtn_error.Visible = true; lati_pos1 = "1"; lati_pos2 = "2"; longi_pos1 = "1"; longi_pos2 = "2"; gp[i].Latitude = double.Parse(lati_pos1 + lati_pos2); gp[i].Longitude = double.Parse(longi_pos1 + longi_pos2); Err_Vessel_Msg += "<tr><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>Latitude:" + UDFLib.ConvertToInteger(latitude.ToString()) + "</td><td>Longitude:" + longitude.ToString() + "</td></tr>"; continue; } } //End For if (Err_Vessel_Msg == "<table>") { Err_Vessel_Msg = ""; } else { Err_Vessel_Msg += "</table>"; } if (Err_Vessel_Count > 0) { lblVessels.ForeColor = System.Drawing.Color.Red; lblVessels.Text = "Total Ships: " + Vessel_Count.ToString() + " (" + Err_Vessel_Count.ToString() + " Ship(s) found with Error!!)"; lblLoadingIssues.Text = Err_Vessel_Msg; } else { lblVessels.ForeColor = System.Drawing.Color.Blue; lblVessels.Text = "Total Ships: " + Vessel_Count.ToString(); } #endregion } else { #region ---------------- Route---------- double lat_pos_g = 0; double log_pos_g = 0; GooglePolyline objPolyLine = new GooglePolyline(); if (strReportType == "N") { objPolyLine.ColorCode = "#7FFF00"; } else { objPolyLine.ColorCode = "#FF00FF"; } objPolyLine.Width = 1; objPolyLine.Geodesic = true; foreach (DataRow dr in dtData.Rows) { Vessel_Count++; gp[i] = new GooglePoint(); //string sangle = dr[5].ToString(); string sangle = dr["Vessel_Course"].ToString(); CreateImage(dr["Vessel_Short_Name"].ToString()); string latitude = ""; string longitude = ""; string longi_pos1; string longi_pos2; string lati_pos1; string lati_pos2; decimal lat_degree = 0; decimal lat_min = 0; decimal lat_sec = 0; string slat_dir = ""; decimal long_degree = 0; decimal long_min = 0; decimal long_sec = 0; string slong_dir = ""; try { lat_degree = UDFLib.ConvertToDecimal(dr["Latitude_Degrees"].ToString()); lat_min = UDFLib.ConvertToDecimal(dr["Latitude_Minutes"].ToString()); lat_sec = UDFLib.ConvertToDecimal(dr["Latitude_Seconds"].ToString()); slat_dir = dr["LATITUDE_N_S"].ToString(); if (slat_dir != "N" && slat_dir != "S") { slat_dir = "N"; } latitude = Conv_Deg2Decimal_new(Convert.ToDouble(lat_degree), Convert.ToDouble(lat_min), Convert.ToDouble(lat_sec), slat_dir.ToString()); long_degree = UDFLib.ConvertToDecimal(dr["Longitude_Degrees"].ToString()); long_min = UDFLib.ConvertToDecimal(dr["Longitude_Minutes"].ToString()); long_sec = UDFLib.ConvertToDecimal(dr["Longitude_Seconds"].ToString()); slong_dir = dr["Longitude_E_W"].ToString(); if (slong_dir != "E" && slong_dir != "W") { slat_dir = "E"; } longitude = Conv_Deg2Decimal_new(Convert.ToDouble(long_degree), Convert.ToDouble(long_min), Convert.ToDouble(long_sec), slong_dir.ToString()); //else if (Convert.ToString(dr["Telegram_Type"]).ToUpper() == "P") // gp[i].IconImage = dr["Vessel_Short_Name"].ToString() + "-P" + ".png"; gp[i].Latitude = double.Parse(latitude); gp[i].Longitude = double.Parse(longitude); string simagename = ""; if (sangle == "" || sangle == null) { simagename = "boat_.png"; } else { Double angle = Convert.ToDouble(sangle); if ((angle >= 0) && (angle <= 90)) { simagename = "UpSide45_f_.png"; } if ((angle >= 90) && (angle <= 180)) { simagename = "UpSide_135_.png"; } if ((angle >= 180) && (angle <= 270)) { simagename = "Down_225_.png"; } if ((angle >= 270) && (angle <= 360)) { simagename = "Down_315_.png"; } } strInfoHtml = "<table border=0 cellspacing=0 cellpadding=0 style='font-size:10px;font-family:Verdana'>"; strInfoHtml += "<tr><td colspan=2 style='font-weight:bold;'>" + dr["Vessel_Name"].ToString() + " <img src='images/" + simagename + "'>" + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Report Date:</td><td style='color:blue;font-weight:bold'>" + dr["infodate"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Location:</td><td>" + dr["Location_Name"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Latitude:</td><td>" + dr["Latitude_Degrees"].ToString() + " " + dr["Latitude_Minutes"].ToString() + " " + dr["Latitude_Seconds"].ToString() + " " + dr["LATITUDE_N_S"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Longitude:</td><td>" + dr["Longitude_Degrees"].ToString() + " " + dr["Longitude_Minutes"].ToString() + " " + dr["Longitude_Seconds"].ToString() + " " + dr["Longitude_E_W"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Course:</td><td>" + sangle.ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Wind Direction/ Force:</td><td>" + dr["Wind_Direction"].ToString() + "/" + dr["Wind_Force"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Average speed:</td><td>" + dr["AVERAGE_SPEED"].ToString() + " knts</td></tr>"; strInfoHtml += "<tr><td style='width:80px'>Next port/<br>ETA:</td><td>" + dr["PORT_NAME"].ToString() + "<br>" + dr["etanextport"].ToString() + "</td></tr>"; strInfoHtml += "<tr><td style='width:80px'></td><td></td></tr>"; string ReportName = rbtnNoonReport.Checked == true ? "Noon Report" : (rbtnPurpleReport.Checked == true ? "PurpleFinder" : "Noon Report"); string CrewLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Crew/CrewListHistory.aspx?VesselID=" + dr["Vessel_ID"].ToString() + "&AsofDate=" + dr["Telegram_Date"].ToString() + "' target='_blank'>Crew List</a>"; string NoonLink = ""; if (strReportType == "N") { NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/NoonReport.aspx?id=" + dr["PKID"].ToString() + "' target='_blank'>" + ReportName + "</a>"; } else { NoonLink = "<a href='" + ConfigurationManager.AppSettings["APP_URL"].ToString() + "Operations/PurpleReport.aspx?id=" + dr["PKID"].ToString() + "' target='_blank'>" + ReportName + "</a>"; } strInfoHtml += "<td>" + CrewLink + "</td><td>" + NoonLink + "</td>"; strInfoHtml += "</tr>"; strInfoHtml += "</table>"; gp[i].InfoHTML = strInfoHtml.ToString(); objPolyLine.Points.Add(gp[i]); if (i == 0) { //gp[i].IconImage = "red-button.png"; lat_pos_g = double.Parse(latitude); log_pos_g = double.Parse(longitude); GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]); } else { gp[i].IconImage = "number_" + Convert.ToDateTime(dr["Telegram_Date"]).Day.ToString() + ".png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]); } i++; } catch { Err_Vessel_Count++; lbtn_error.Visible = true; lati_pos1 = "1"; lati_pos2 = "2"; longi_pos1 = "1"; longi_pos2 = "2"; gp[i].Latitude = double.Parse(lati_pos1 + lati_pos2); gp[i].Longitude = double.Parse(longi_pos1 + longi_pos2); Err_Vessel_Msg += "<tr><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>Latitude:" + UDFLib.ConvertToInteger(latitude.ToString()) + "</td><td>Longitude:" + longitude.ToString() + "</td></tr>"; continue; } } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(objPolyLine); GoogleMapForASPNet1.GoogleMapObject.CenterPoint.Latitude = lat_pos_g; GoogleMapForASPNet1.GoogleMapObject.CenterPoint.Longitude = log_pos_g; GoogleMapForASPNet1.GoogleMapObject.AutomaticBoundaryAndZoom = true; #endregion } } else { lblVessels.Text = "Total Ships: " + Err_Vessel_Count.ToString(); } } catch (Exception ex) { Response.Write(ex.Message); } }
public void Show_Nearest_Ports() { //GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); string shipname = ddl_veslist.SelectedItem.Text.ToString(); string longitude_sel = ""; string latitude_sel = ""; string longdire_sel = ""; string latdir_sel = ""; int Vessel_ID = int.Parse(ddl_veslist.SelectedValue); int Fleet_ID = int.Parse(ddlTechmanager.SelectedValue); DataTable dtData = BLL_OPS_DPL.Get_TelegramData(Vessel_ID, Fleet_ID, strReportType); if (dtData.Rows.Count > 0) { longitude_sel = dtData.Rows[0]["Longitude_Degrees"].ToString(); latitude_sel = dtData.Rows[0]["Latitude_Degrees"].ToString(); longdire_sel = dtData.Rows[0]["Longitude_E_W"].ToString(); latdir_sel = dtData.Rows[0]["LATITUDE_N_S"].ToString(); } DataTable ds_ship_ports = BLL_OPS_DPL.Get_Ports_NearVessel(longitude_sel, latitude_sel, longdire_sel, latdir_sel); if (ds_ship_ports.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); GoogleMapForASPNet1.GoogleMapObject.AutomaticBoundaryAndZoom = true; GooglePoint[] gp = new GooglePoint[ds_ship_ports.Rows.Count]; int i = 0; foreach (DataRow dr_port in ds_ship_ports.Rows) { string latitude = ""; string longitude = ""; latitude = convdegtodecimal_all(dr_port["Port_Lat"].ToString()); longitude = convdegtodecimal_all(dr_port["Port_Lon"].ToString()); if (latitude != "" && longitude != "") { gp[i] = new GooglePoint(); gp[i].IconImage = "../Images/port.gif"; gp[i].IconImageWidth = 15; gp[i].IconImageHeight = 15; gp[i].Latitude = double.Parse(latitude); gp[i].Longitude = double.Parse(longitude); gp[i].InfoHTML = "Port Name: " + dr_port["PORT_NAME"].ToString() + "<br>Country: " + dr_port["PORT_COUNTRY"].ToString() + "<br>Longitude: " + dr_port["PORT_LON"].ToString() + "<br>Latitude: " + dr_port["PORT_LAT"].ToString(); GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp[i]); i++; } else { continue; } } } }