protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //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"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "600px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 14; //Specify Center Point for map. Map will be centered on this point. GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", 43.66619, -79.44268); //Add pushpins for map. //This should be done with intialization of GooglePoint class. //ID is to identify a pushpin. It must be unique for each pin. Type is string. //Other properties latitude and longitude. GooglePoint GP1 = new GooglePoint(); GP1.ID = "GP1"; GP1.Latitude = 43.65669; GP1.Longitude = -79.44268; GP1.InfoHTML = "This is point 1"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1); GooglePoint GP2 = new GooglePoint(); GP2.ID = "GP2"; GP2.Latitude = 43.66619; GP2.Longitude = -79.44268; GP2.InfoHTML = "This is point 2"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2); GooglePoint GP3 = new GooglePoint(); GP3.ID = "GP3"; GP3.Latitude = 43.67689; GP3.Longitude = -79.43270; GP3.InfoHTML = "This is point 3"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3); //Create Polylines between points GP1, GP2 and GP3. GooglePolyline PL1 = new GooglePolyline(); PL1.ID = "PL1"; //Give Hex code for line color PL1.ColorCode = "#0000FF"; //Specify width for line PL1.Width = 5; PL1.Points.Add(GP1); PL1.Points.Add(GP2); PL1.Points.Add(GP3); //Add polyline to GoogleMap object GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } }
private void BindMap(float Citylat, float Citylon, string CityName) { div_Map.Visible = true; GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "500px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "300px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Blue"; GooglePoint[] Gpoint = new GooglePoint[1]; List <string> City = new List <string>(); Gpoint[0] = new GooglePoint(); Gpoint[0].InfoHTML = CityName; Gpoint[0].Latitude = Citylat; Gpoint[0].Longitude = Citylon; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[0]); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", Citylat, Citylon); }
public void Remove() { try { int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()) + 1; GooglePoint[] Gpoint = new GooglePoint[i + 1]; GooglePolyline PL1 = new GooglePolyline(); Array.Clear(Gpoint, 0, Gpoint.Length); PL1.Points.Clear(); GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); GooglePoint Gp = new GooglePoint(); } catch (Exception) {} }
public static GooglePolylines CloneMe(GooglePolylines prev) { GooglePolylines p = new GooglePolylines(); for (int i = 0; i < prev.Count; i++) { GooglePolyline GPL = new GooglePolyline(); GPL.ColorCode = prev[i].ColorCode; GPL.Geodesic = prev[i].Geodesic; GPL.ID = prev[i].ID; GPL.Points = GooglePoints.CloneMe(prev[i].Points); GPL.Width = prev[i].Width; p.Add(GPL); } return(p); }
public override bool Equals(System.Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. GooglePolyline p = obj as GooglePolyline; if ((System.Object)p == null) { return(false); } // Return true if the fields match: return((Geodesic == p.Geodesic) && (Width == p.Width) && (p.ID == ID) && (p.ColorCode == ColorCode) && (p.Points.Equals(Points))); }
public void Remove() { try { List <GooglePoint> Gp = new List <GooglePoint>(); List <GooglePoint> Gp2 = new List <GooglePoint>(); int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint = new GooglePoint[i]; int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePolyline PL1 = new GooglePolyline(); GooglePoint[] Gpoint2 = new GooglePoint[i2]; Array.Clear(Gpoint, 0, Gpoint.Length); Array.Clear(Gpoint2, 0, Gpoint.Length); Gp.Clear(); Gp2.Clear(); PL1.Points.Clear(); GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); } catch (Exception) {} }
public void Remove() { try { List<GooglePoint> Gp = new List<GooglePoint>(); List<GooglePoint> Gp2 = new List<GooglePoint>(); int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint = new GooglePoint[i]; int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePolyline PL1 = new GooglePolyline(); GooglePoint[] Gpoint2 = new GooglePoint[i2]; Array.Clear(Gpoint, 0, Gpoint.Length); Array.Clear(Gpoint2, 0, Gpoint.Length); Gp.Clear(); Gp2.Clear(); PL1.Points.Clear(); GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); } catch (Exception) {} }
public static GooglePolylines CloneMe(GooglePolylines prev) { GooglePolylines p = new GooglePolylines(); for (int i = 0; i < prev.Count; i++) { GooglePolyline GPL = new GooglePolyline(); GPL.ColorCode = prev[i].ColorCode; GPL.Geodesic = prev[i].Geodesic; GPL.ID = prev[i].ID; GPL.Points = GooglePoints.CloneMe(prev[i].Points); GPL.Width = prev[i].Width; p.Add(GPL); } return p; }
void GenerateRMap(List <string> Rlonlat, List <string> RipS, List <string> Rrttave, string dirname) { List <double> test = Rlonlat.Select(x => double.Parse(x)).ToList(); GooglePolyline PL2 = new GooglePolyline(); PL2.ID = "PL2"; PL2.ColorCode = "#000000"; PL2.Width = 5; int m = 0; int IDpp = 60; double longg = 0; double lat = 0; string ll1 = "0"; string ll2 = "0"; List <string> Rlonglatlist = new List <string>(); List <string> zeroballoonlist = new List <string>(); int k = 0; int Rrepeat = 0; int Rrep2 = 1; int zeroflag = 0; foreach (double prime in test) { if (m < 1) { longg = prime; m = 1; ll1 = Convert.ToString(longg); } else if (m > 0) { lat = prime; ll2 = Convert.ToString(lat); ll2 = ll1 + "_" + ll2; Rlonglatlist.Add(ll2); m = 0; } } for (int ind = 0; ind < Rlonglatlist.Count; ind++) { Rrep2 = 1; if (Rlonglatlist[ind] == "0_0") { zeroballoonlist.Add("<pre>" + Convert.ToString(ind) + "\t\t\t" + RipS[ind] + "\t\t\t" + Rrttave[ind] + "\n</pre>"); zeroflag = 1; } else { if (ind > 0) { k = 0; while ((k < ind) & (Rrep2 > 0)) { if (Rlonglatlist[ind] == Rlonglatlist[k]) { string filename = "RDesc" + k.ToString() + ".txt"; if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } string nonzeroinfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + RipS[ind] + "\t\t\t" + Rrttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + RipS[ind] + "\t\t\t" + Rrttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Rdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Rlonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, "icons/snow.png", Rdesctext)); PL2.Points.Add(new GooglePoint(idpps, lat, longg)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); Rrepeat = Rrepeat + 1; Rrep2 = 0; } else { k = k + 1; Rrepeat = 0; } } } if (Rrepeat == 0) { string filename = "RDesc" + ind.ToString() + ".txt"; string heading = "<pre>\nHop No.\t\t\tIP Address\t\t\tAverage RTT\n"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), heading); if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } string nonzeroinfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + RipS[ind] + "\t\t\t" + Rrttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + RipS[ind] + "\t\t\t" + Rrttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Rdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Rlonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, "icons/snow.png", Rdesctext)); PL2.Points.Add(new GooglePoint(idpps, lat, longg)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); } IDpp = IDpp + 1; } } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL2); }
private void BindMap() { GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "620px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Blue"; int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()) + 1; GooglePoint[] Gpoint = new GooglePoint[i + 1]; List <string> City = new List <string>(); bool frmCity = false; bool toCity = false; int objCont = 0; if (grdStagePlan.Rows.Count > 0) { for (int Count = 0; Count < grdStagePlan.Rows.Count; Count++) { string FromCity, ToCity = string.Empty; float FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0; try { FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text; ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text; FromCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[6].Text); FromCitylon = float.Parse(grdStagePlan.Rows[Count].Cells[7].Text); ToCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[8].Text); ToCitylog = float.Parse(grdStagePlan.Rows[Count].Cells[9].Text); if (FromCity != null && !City.Contains(FromCity)) { City.Add(FromCity); Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].InfoHTML = FromCity; Gpoint[objCont].Latitude = FromCitylat; Gpoint[objCont].Longitude = FromCitylon; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = true; objCont++; } if (ToCity != null && !City.Contains(ToCity)) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].InfoHTML = ToCity; Gpoint[objCont].Latitude = ToCitylat; Gpoint[objCont].Longitude = ToCitylog; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); City.Add(ToCity); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = false; objCont++; } } catch (Exception ex) { } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field <double>("Lattitude"); double Longitude = dr.Field <double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } else { GooglePoint GP0 = new GooglePoint(); GP0.Latitude = 51.165691; GP0.Longitude = 10.451526; GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude); } }
public void Add(GooglePolyline pPolyline) { this.List.Add(pPolyline); }
private void _BindMap(string startCity, string endCity, double percentage, double startcitylat, double startcitylong, double endCitylat, double endCitylong) { try { dlBlog.DataBind(); GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 6; double centerlat; double ceterlong; GooglePoint GP1 = new GooglePoint(); GP1.ID = "GP1"; if (startCity != null) { double latitude = startcitylat; double longitude = startcitylong; GP1.Latitude = latitude; GP1.Longitude = longitude; GP1.InfoHTML = startCity; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1); } GooglePoint GP2 = new GooglePoint(); GP2.ID = "GP2"; //Chemnitz if (endCity != null) { double latitude = endCitylat; double longitude = endCitylong; GP2.Latitude = latitude; //49.8776483; GP2.Longitude = longitude; // 8.6517617; GP2.InfoHTML = endCity; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2); } GooglePoint Gp3 = new GooglePoint(); // End City Lat & long Max Test if (GP1.Latitude < GP2.Latitude && GP1.Longitude < GP2.Longitude) { Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //Start City Lat & Long Max if (GP1.Latitude > GP2.Latitude && GP1.Longitude > GP2.Longitude) { Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //Start city Lat max & long Mini Test if (GP1.Latitude > GP2.Latitude && GP1.Longitude < GP2.Longitude) { Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //start city lat Min & long Max Test if (GP1.Latitude < GP2.Latitude && GP1.Longitude > GP2.Longitude) { Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } } } } Gp3.IconImage = "../_images/cycle.png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gp3); if (GP1.Latitude > GP2.Latitude) centerlat = GP2.Latitude; else centerlat = GP1.Latitude; if (GP1.Longitude > GP2.Longitude) ceterlong = GP2.Longitude; else ceterlong = GP1.Longitude; //GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 146; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", centerlat, ceterlong); GooglePolyline PL1 = new GooglePolyline(); PL1.ID = "PL1"; //Give Hex code for line color PL1.ColorCode = "#0000FF"; //Specify width for line PL1.Width = 5; PL1.Points.Add(GP1); PL1.Points.Add(GP2); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } catch (Exception ex) { Helper.Log(ex.Message, "Bind Google Map & Cycle "); } }
private void BindMap(string GpxFile, string FileName) { lblJourny.Text = FileName; div_GpxMap.Visible = true; GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "960px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "450px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 15; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Green"; DataTable _dt = new DataTable(); _dt = LoadGPXWaypoints(GpxFile); if (_dt != null && _dt.Rows.Count > 0) { int i = Convert.ToInt32(_dt.Rows.Count); GooglePoint[] Gpoint = new GooglePoint[i + 1]; List<string> City = new List<string>(); bool frmCity = false; bool toCity = false; int objCont = 0; int pointsCount = 20; if (i < pointsCount) { pointsCount = i; } int pointsInterval = i / 20; int pointsPloatted = 1; for (int Count = 0; Count < _dt.Rows.Count; Count++) { if (Count % (pointsInterval + 1) == 0 && pointsPloatted < 19) { string FromCity, ToCity = string.Empty; double FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0; try { FromCitylat = double.Parse(_dt.Rows[Count]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture); FromCitylon = double.Parse(_dt.Rows[Count]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture); ToCitylat = double.Parse(_dt.Rows[Count + 1]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture); ToCitylog = double.Parse(_dt.Rows[Count + 1]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture); if (FromCitylat != 0) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].Latitude = FromCitylat; Gpoint[objCont].Longitude = FromCitylon; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = true; objCont++; } if (ToCitylat != 0) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].Latitude = ToCitylat; Gpoint[objCont].Longitude = ToCitylog; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = false; objCont++; } } catch (Exception ex) { } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); pointsPloatted++; } } Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field<double>("Lattitude"); double Longitude = dr.Field<double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } else { GooglePoint GP0 = new GooglePoint(); GP0.Latitude = 51.165691; GP0.Longitude = 10.451526; GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude); } }
void chargeData(DataSet ds) { GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); string[] TobeDistinct = { "nom", "latitude", "longitude", "numero" }; DataTable dtDistinct = GetDistinctRecords(ds.Tables[0], TobeDistinct); DataSet ds2 = new System.Data.DataSet(); ds2.Tables.Add(dtDistinct); if (ds2.Tables[0].Rows.Count == 0) { //this.Label1.Text = "Aucune données trouvée."; return; } CultureInfo culture = new CultureInfo("en"); Double lat_fin, lng_fin, lat_debu, lon_debu; //GooglePoint POSTE = new GooglePoint(); //double lat = double.Parse(la.ToString().Replace(",", "."), culture); //POSTE.ID = "8541"; //POSTE.Latitude = 11.528576; //POSTE.Longitude = 42.854527; //POSTE.InfoHTML = "POSTE : 100 LOGEMENT"; //POSTE.IconImage = "icons/home.png"; //POSTE.IconImage = "icons\\poste_electrique.png"; //POSTE.Draggable = true; //POSTE.ToolTip = "100 LOGEMENT"; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(POSTE); //GooglePoint POSTE1 = new GooglePoint(); //POSTE1.ID = "8547"; //POSTE1.Latitude = 11.587656; //POSTE1.Longitude = 43.075940; //POSTE1.InfoHTML = "POSTE : 160 LOGEMENT"; //POSTE.IconImage = "icons/home.png"; //POSTE1.IconImage = "icons\\poste_electrique.png"; //POSTE1.Draggable = true; //POSTE1.ToolTip = "160 LOGEMENT"; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(POSTE1); foreach (DataRow r in ds.Tables[0].Rows) { if (r["nom"].ToString() != String.Empty) { if (r["nom"].ToString() != "line") { GooglePoint POSTE = new GooglePoint(); POSTE.ID = r["id"].ToString().Trim(); POSTE.Latitude = double.Parse(r["latitude"].ToString().Replace(",", ".").Trim(), culture); POSTE.Longitude = double.Parse(r["longitude"].ToString().Replace(",", ".").Trim(), culture); // POSTE.InfoHTML = "POSTE : " + r["nom"].ToString().ToLower().Trim(); POSTE.InfoHTML = inser_num(int.Parse(POSTE.ID.ToString())); POSTE.IconImage = r["url_image"].ToString().Trim(); POSTE.Draggable = true; POSTE.ToolTip = r["nom"].ToString().Trim(); try { GoogleMapForASPNet1.GoogleMapObject.Points.Add(POSTE); POSTE = null; } catch (Exception ex) { Console.WriteLine(ex.Message); } } else if (r["nom"].ToString() == "line") { String la = r["latitude"].ToString(); String lo = r["longitude"].ToString(); string[] lati = la.Split('-'); string[] lon = lo.Split('-'); GooglePolyline POSTE1 = new GooglePolyline(); GooglePoint debu = new GooglePoint(); GooglePoint fin = new GooglePoint(); lat_debu = Double.Parse(lati[0].ToString().Replace(",", "."), culture); lon_debu = Double.Parse(lati[1].ToString().Replace(",", "."), culture); debu.Latitude = lat_debu; debu.Longitude = lon_debu; lat_fin = Double.Parse(lon[0].ToString().Replace(",", "."), culture); lng_fin = Double.Parse(lon[1].ToString().Replace(",", "."), culture); fin.Latitude = lat_fin; fin.Longitude = lng_fin; POSTE1.ID = r["nom"].ToString(); POSTE1.Points.Add(debu); POSTE1.Points.Add(fin); POSTE1.LineStatus = "POSTE : " + r["nom"].ToString(); POSTE1.ColorCode = "blue"; POSTE1.Width = 1; GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(POSTE1); } } } }
public GoogleObject GetOptimizedGoogleObject() { GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"]; GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"]; GoogleObject objGoogle = new GoogleObject(); if (objGoogleOld != null) { for (int i = 0; i < objGoogleNew.Points.Count; i++) { string pointStatus = ""; GooglePoint NewPoint = objGoogleNew.Points[i]; GooglePoint OldPoint = objGoogleOld.Points[NewPoint.ID]; //if old point not found, means this is a new point. if (OldPoint == null) { pointStatus = "N"; //New } else { //If old point found and old not equal to new point, means it's value is changed. if (!OldPoint.Equals(NewPoint)) { pointStatus = "C"; //Changed } //Remove found point from old object. This is to reduce iteration in next loop. objGoogleOld.Points.Remove(OldPoint.ID); } if (pointStatus != "") { //If new point is changed, add it in list which is to be sent to client. NewPoint.PointStatus = pointStatus; objGoogle.Points.Add(NewPoint); } } //Loop through rest of old points to mark them as deleted. for (int i = 0; i < objGoogleOld.Points.Count; i++) { GooglePoint OldPoint = objGoogleOld.Points[i]; OldPoint.PointStatus = "D"; objGoogle.Points.Add(OldPoint); } //******************************************** for (int i = 0; i < objGoogleNew.Polylines.Count; i++) { string lineStatus = ""; GooglePolyline NewLine = objGoogleNew.Polylines[i]; GooglePolyline OldLine = objGoogleOld.Polylines[NewLine.ID]; //if old point not found, means this is a new point. if (OldLine == null) { lineStatus = "N"; //New } else { //If old point found and old not equal to new point, means it's value is changed. if (!OldLine.Equals(NewLine)) { lineStatus = "C"; //Changed } //Remove found point from old object. This is to reduce iteration in next loop. objGoogleOld.Polylines.Remove(OldLine.ID); } if (lineStatus != "") { //If new point is changed, add it in list which is to be sent to client. NewLine.LineStatus = lineStatus; objGoogle.Polylines.Add(NewLine); } } //Loop through rest of old points to mark them as deleted. for (int i = 0; i < objGoogleOld.Polylines.Count; i++) { GooglePolyline OldPolyline = objGoogleOld.Polylines[i]; OldPolyline.LineStatus = "D"; objGoogle.Polylines.Add(OldPolyline); } //******************************************** for (int i = 0; i < objGoogleNew.Polygons.Count; i++) { string gonStatus = ""; GooglePolygon NewGon = objGoogleNew.Polygons[i]; GooglePolygon OldGon = objGoogleOld.Polygons[NewGon.ID]; //if old point not found, means this is a new point. if (OldGon == null) { gonStatus = "N"; //New } else { //If old point found and old not equal to new point, means it's value is changed. if (!OldGon.Equals(NewGon)) { gonStatus = "C"; //Changed } //Remove found point from old object. This is to reduce iteration in next loop. objGoogleOld.Polygons.Remove(OldGon.ID); } if (gonStatus != "") { //If new point is changed, add it in list which is to be sent to client. NewGon.Status = gonStatus; objGoogle.Polygons.Add(NewGon); } } //Loop through rest of old points to mark them as deleted. for (int i = 0; i < objGoogleOld.Polygons.Count; i++) { GooglePolygon OldPolygon = objGoogleOld.Polygons[i]; // OldPolygon.Status = "D"; objGoogle.Polygons.Add(OldPolygon); } } objGoogle.CenterPoint = objGoogleNew.CenterPoint; objGoogle.ZoomLevel = objGoogleNew.ZoomLevel; objGoogle.ShowTraffic = objGoogleNew.ShowTraffic; objGoogle.RecenterMap = objGoogleNew.RecenterMap; objGoogle.MapType = objGoogleNew.MapType; objGoogle.AutomaticBoundaryAndZoom = objGoogleNew.AutomaticBoundaryAndZoom; //Save new Google object state in session variable. //System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = objGoogleNew; System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = new GoogleObject(objGoogleNew); return(objGoogle); }
void GenerateFMap(List <string> Flonlat, List <string> FipS, List <string> Frttave, string dirname) { List <double> test = Flonlat.Select(x => double.Parse(x)).ToList(); GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; GoogleMapForASPNet1.GoogleMapObject.APIVersion = "3"; GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; GoogleMapForASPNet1.GoogleMapObject.Height = "400px"; GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 14; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("0", 0, 0); GooglePolyline PL1 = new GooglePolyline(); PL1.ID = "PL1"; PL1.ColorCode = "#FFF014"; PL1.Width = 5; int m = 0; int IDpp = 60; double longg = 0; double lat = 0; string ll1 = "0"; string ll2 = "0"; List <string> Flonglatlist = new List <string>(); List <string> zeroballoonlist = new List <string>(); int k = 0; int Frepeat = 0; int Frep2 = 1; int zeroflag = 0; foreach (double prime in test) { if (m < 1) { longg = prime; m = 1; ll1 = Convert.ToString(longg); } else if (m > 0) { lat = prime; ll2 = Convert.ToString(lat); ll2 = ll1 + "_" + ll2; Flonglatlist.Add(ll2); m = 0; } } for (int ind = 0; ind < Flonglatlist.Count; ind++) { Frep2 = 1; if (Flonglatlist[ind] == "0_0") { zeroballoonlist.Add("<pre>" + Convert.ToString(ind) + "\t\t\t" + FipS[ind] + "\t\t\t" + Frttave[ind] + "\n</pre>"); zeroflag = 1; } else { if (ind > 0) { k = 0; while ((k < ind) & (Frep2 > 0)) { if (Flonglatlist[ind] == Flonglatlist[k]) { string filename = "FDesc" + k.ToString() + ".txt"; if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } string nonzeroinfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + FipS[ind] + "\t\t\t" + Frttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + FipS[ind] + "\t\t\t" + Frttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Fdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Flonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, "icons/satellite.png", Fdesctext)); PL1.Points.Add(new GooglePoint(idpps, lat, longg)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); Frepeat = Frepeat + 1; Frep2 = 0; } else { k = k + 1; Frepeat = 0; } } } if (Frepeat == 0) { string filename = "FDesc" + ind.ToString() + ".txt"; string heading = "<pre>\nHop No.\t\t\tIP Address\t\t\tAverage RTT\n"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), heading); if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } string nonzeroinfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + FipS[ind] + "\t\t\t" + Frttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<pre>" + Convert.ToString(ind) + "\t\t\t" + FipS[ind] + "\t\t\t" + Frttave[ind] + "\n</pre>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Fdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Flonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, "icons/satellite.png", Fdesctext)); PL1.Points.Add(new GooglePoint(idpps, lat, longg)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); } IDpp = IDpp + 1; } } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); }
// ***** charger les donnees de la base pour represente sur la carte *****// void chargeData(DataSet ds) { GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); string[] TobeDistinct = { "name", "latitude", "longitude" }; DataTable dtDistinct = GetDistinctRecords(ds.Tables[0], TobeDistinct); DataSet ds2 = new System.Data.DataSet(); ds2.Tables.Add(dtDistinct); if (ds2.Tables[0].Rows.Count == 0) { //this.Label1.Text = "Aucune données trouvée."; return; } CultureInfo culture = new CultureInfo("en"); Double lat_fin, lng_fin, lat_debu, lon_debu; foreach (DataRow r in ds.Tables[0].Rows) { if (r["name"].ToString() != String.Empty) { if (r["name"].ToString() != "line") { String la = r["latitude"].ToString(); string[] words = la.Split('-'); GooglePoint POSTE = new GooglePoint(); lat_debu = Double.Parse(words[0].ToString().Replace(",", "."), culture); lat_fin = Double.Parse(words[1].ToString().Replace(",", "."), culture); POSTE.ID = r["name"].ToString(); POSTE.Latitude = lat_debu; POSTE.Longitude = lat_fin; POSTE.InfoHTML = "POSTE : " + r["name"].ToString(); //POSTE.IconImage = "icons/home.png"; POSTE.IconImage = r["url_image"].ToString(); POSTE.Draggable = true; POSTE.ToolTip = r["name"].ToString(); GoogleMapForASPNet1.GoogleMapObject.Points.Add(POSTE); } else if (r["name"].ToString() == "line") { String la = r["latitude"].ToString(); String lo = r["longitude"].ToString(); string[] lati = la.Split('-'); string[] lon = lo.Split('-'); GooglePolyline POSTE = new GooglePolyline(); GooglePoint debu = new GooglePoint(); GooglePoint fin = new GooglePoint(); lat_debu = Double.Parse(lati[0].ToString().Replace(",", "."), culture); lon_debu = Double.Parse(lati[1].ToString().Replace(",", "."), culture); debu.Latitude = lat_debu; debu.Longitude = lon_debu; lat_fin = Double.Parse(lon[0].ToString().Replace(",", "."), culture); lng_fin = Double.Parse(lon[1].ToString().Replace(",", "."), culture); fin.Latitude = lat_fin; fin.Longitude = lng_fin; POSTE.ID = r["name"].ToString(); POSTE.Points.Add(debu); POSTE.Points.Add(fin); POSTE.LineStatus = "POSTE : " + r["name"].ToString(); POSTE.ColorCode = "blue"; POSTE.Width = 1; GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(POSTE); } } } }
/**************fonction du click sur la map*************/ void OnMapClicked(double lat, double longi) { centre.Latitude = lat; centre.Longitude = longi; string name1 = null; DataSet ds; ds = ges.ReturnData("select * from objet", "objet"); nom = TextBox1.Text; GooglePoint GP = new GooglePoint(); //Session ["sesion"] = new List<GooglePoint>(); foreach (DataRow r in ds.Tables[0].Rows) { if (nom == "line" && r["nom_objet"].ToString() == nom) { if (HiddenField1.Value == string.Empty) { HiddenField1.Value = "0"; } if (ViewState["increm"] == null) { ViewState["increm"] = "0"; } name1 = r["nom_objet"].ToString(); GP.Latitude = lat; GP.Longitude = longi; listP.Add(GP); ViewState["increm"] = Convert.ToInt16(ViewState["increm"]) + 1; i = Convert.ToInt16(ViewState["increm"]); } } if (i == 2) { GooglePolyline PL1 = new GooglePolyline(); GooglePoint p = new GooglePoint(); //listP =(List<GooglePoint>)ViewState["point"]; if (listP.Count == 2) { foreach (var k in listP) { PL1.Points.Add(k); } } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); //ges.DataUpdate("insert into poste (latitude , longitude ,name) values ( '" + listP[0].Latitude + " - " + listP[0].Longitude + " ' , '" + listP[1].Latitude + " - " + listP[1].Longitude + "','" + name1 + "' )"); i = 0; ViewState["increm"] = null; listP.Clear(); } }
/************** fonction du click sur un marqueure *****************/ void OnPushpinClicked(string pID) { id_mark = pID.ToString(); string name = null; DataSet ds; ds = ges.ReturnData("select * from objet", "objet"); nom = TextBox1.Text; GooglePoint GP = new GooglePoint(); foreach (DataRow r in ds.Tables[0].Rows) { if (nom == "line" && r["nom_objet"].ToString() == nom) { if (HiddenField1.Value == string.Empty) { HiddenField1.Value = "0"; } TextBox8.Text = pID.ToString(); ////name = r["nom_objet"].ToString(); GP.Latitude = GoogleMapForASPNet1.GoogleMapObject.Points[pID].Latitude; GP.Longitude = GoogleMapForASPNet1.GoogleMapObject.Points[pID].Longitude; i = i + 1; listP.Add(GP); HiddenField1.Value = HiddenField1.Value + 1; ScriptManager.RegisterStartupScript(Page, this.GetType(), "tracer_line", "initMap(" + GP.Latitude + "," + GP.Longitude + ");", true); } } if (i >= 2) { group.Add(listP[1]); GooglePolyline PL1 = new GooglePolyline(); if (group.Count == 2) { for (int h = 0; h > group.Count; h++) { if (group[h].Longitude != GoogleMapForASPNet1.GoogleMapObject.Points[pID].Longitude && group[h].Latitude != GoogleMapForASPNet1.GoogleMapObject.Points[pID].Longitude) { if (group.Count == 2) { foreach (var k in group) { PL1.Points.Add(k); } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); //ges.DataUpdate("insert into poste1 (latitude , longitude ,name) values ( '" + listP[0].Latitude + " - " + listP[0].Longitude + " ' , '" + listP[1].Latitude + " - " + listP[1].Longitude + "','" + name + "' )"); i = 0; listP.Clear(); group.Clear(); } i = 0; listP.Clear(); } else if (group.Count == 2) { foreach (var k in group) { PL1.Points.Add(k); } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } } } // GooglePolyline PL1 = new GooglePolyline(); // if (listP.Count == 2) // { // foreach (var k in listP ) // { // PL1.Points.Add(k); // } // } // GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); // ges.DataUpdate("insert into poste1 (latitude , longitude ,name) values ( '" + listP[0].Latitude + " - " + listP[0].Longitude + " ' , '" + listP[1].Latitude + " - " + listP[1].Longitude + "','" + name + "' )"); // i = 0; // listP.Clear(); //} //} //catch (Exception e) //{ // Label6.Text = e.Message; ////} //group.Clear(); } }
private void BindMap() { GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "620px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Blue"; int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()) + 1; GooglePoint[] Gpoint = new GooglePoint[i + 1]; List<string> City = new List<string>(); bool frmCity = false; bool toCity = false; int objCont = 0; if (grdStagePlan.Rows.Count > 0) { for (int Count = 0; Count < grdStagePlan.Rows.Count; Count++) { string FromCity, ToCity = string.Empty; float FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0; try { FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text; ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text; FromCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[6].Text); FromCitylon = float.Parse(grdStagePlan.Rows[Count].Cells[7].Text); ToCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[8].Text); ToCitylog = float.Parse(grdStagePlan.Rows[Count].Cells[9].Text); if (FromCity != null && !City.Contains(FromCity)) { City.Add(FromCity); Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].InfoHTML = FromCity; Gpoint[objCont].Latitude = FromCitylat; Gpoint[objCont].Longitude = FromCitylon; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = true; objCont++; } if (ToCity != null && !City.Contains(ToCity)) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].InfoHTML = ToCity; Gpoint[objCont].Latitude = ToCitylat; Gpoint[objCont].Longitude = ToCitylog; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); City.Add(ToCity); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = false; objCont++; } } catch (Exception ex) { } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field<double>("Lattitude"); double Longitude = dr.Field<double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } else { GooglePoint GP0 = new GooglePoint(); GP0.Latitude = 51.165691; GP0.Longitude = 10.451526; GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //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"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "400px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 14; //Specify Center Point for map. Map will be centered on this point. GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", 43.66619, -79.44268); //Add pushpins for map. //This should be done with intialization of GooglePoint class. //ID is to identify a pushpin. It must be unique for each pin. Type is string. //Other properties latitude and longitude. GooglePoint GP1 = new GooglePoint(); GP1.ID = "GP1"; GP1.Latitude = 43.65669; GP1.Longitude = -79.44268; GP1.InfoHTML = "This is point 1"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1); GooglePoint GP2 = new GooglePoint(); GP2.ID = "GP2"; GP2.Latitude = 43.66619; GP2.Longitude = -79.44268; GP2.InfoHTML = "This is point 2"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2); GooglePoint GP3 = new GooglePoint(); GP3.ID = "GP3"; GP3.Latitude = 43.67689; GP3.Longitude = -79.43270; GP3.InfoHTML = "This is point 3"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3); //Create Polylines between points GP1, GP2 and GP3. GooglePolyline PL1 = new GooglePolyline(); PL1.ID = "PL1"; //Give Hex code for line color PL1.ColorCode = "#0000FF"; //Specify width for line PL1.Width = 5; PL1.Points.Add(GP1); PL1.Points.Add(GP2); PL1.Points.Add(GP3); //Add polyline to GoogleMap object GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } }
private void BindMap() { try { Remove(); GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 2; //Specify Center Point for map. Map will be centered on this point. // Run time you can ava of lat or long List<GooglePoint> Gp = new List<GooglePoint>(); GooglePoint min = new GooglePoint(); int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint = new GooglePoint[i]; GooglePolyline PL1 = new GooglePolyline(); List<GooglePoint> Gp2 = new List<GooglePoint>(); int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint2 = new GooglePoint[i2]; GooglePoint min1 = new GooglePoint(); double centerlat; double ceterlong; DataTable dat1=new DataTable(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); DataTable dat2 = new DataTable(); dat2.Columns.Add("Lattitude", typeof(double)); dat2.Columns.Add("Longitude", typeof(double)); PL1.ColorCode = "#0000FF"; PL1.Width = 5; for (int Count = 0; Count <= grdStagePlan.Rows.Count; Count++) { string FromCity = string.Empty; string ToCity = string.Empty; FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text; ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text; if (FromCity != null) { Gpoint[Count] = new GooglePoint(); Gp.Add(Gpoint[Count]); Gpoint[Count].ID = "Gpoint[Count]"; string appId = "dj0yJmk9NUdkWVpoeGhPMHh1JmQ9WVdrOVZXRnFaa0poTm1zbWNHbzlNVEl6TURBek1UYzJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD04Nw--"; string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(FromCity), appId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); try { using (WebResponse response = request.GetResponse()) { using (DataSet ds = new DataSet()) { try { ds.ReadXml(response.GetResponseStream()); Gpoint[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); Gpoint[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[Count]); Gpoint[Count].InfoHTML=FromCity; Gpoint[Count].IconImage ="icons/sun.png"; dat1.NewRow(); dat1.Rows.Add(Gpoint[Count].Latitude, Gpoint[Count].Longitude); response.Close(); } catch (Exception ex) { } finally { ds.Dispose(); } } } } catch (Exception ex) { } } if (ToCity != null) { Gpoint2[Count] = new GooglePoint(); Gp2.Add(Gpoint[Count]); Gpoint2[Count].ID = "Gpoint2[Count]"; string appId = "{ConsumerKey}"; string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(ToCity), appId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); using (WebResponse response = request.GetResponse()) { using (DataSet ds = new DataSet()) { try { ds.ReadXml(response.GetResponseStream()); Gpoint2[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); Gpoint2[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint2[Count]); Gpoint2[Count].InfoHTML =ToCity; Gpoint[Count].IconImage = "icons/snow.png"; dat2.NewRow(); dat2.Rows.Add(Gpoint2[Count].Latitude, Gpoint2[Count].Longitude); response.Close(); } catch (Exception ex) { } finally { //ds.Clear(); ds.Dispose(); } } } } PL1.Points.Add(Gpoint[Count]); PL1.Points.Add(Gpoint2[Count]); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } //Plyline Draw // GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); //Google Map Certer Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field<double>("Lattitude"); double Longitude = dr.Field<double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } catch (Exception ex) { } }
private void _BindMap(string startCity, string endCity, double percentage, double startcitylat, double startcitylong, double endCitylat, double endCitylong) { try { dlBlog.DataBind(); GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 6; double centerlat; double ceterlong; GooglePoint GP1 = new GooglePoint(); GP1.ID = "GP1"; if (startCity != null) { double latitude = startcitylat; double longitude = startcitylong; GP1.Latitude = latitude; GP1.Longitude = longitude; GP1.InfoHTML = startCity; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1); } GooglePoint GP2 = new GooglePoint(); GP2.ID = "GP2"; //Chemnitz if (endCity != null) { double latitude = endCitylat; double longitude = endCitylong; GP2.Latitude = latitude; //49.8776483; GP2.Longitude = longitude; // 8.6517617; GP2.InfoHTML = endCity; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2); } GooglePoint Gp3 = new GooglePoint(); // End City Lat & long Max Test if (GP1.Latitude < GP2.Latitude && GP1.Longitude < GP2.Longitude) { Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //Start City Lat & Long Max if (GP1.Latitude > GP2.Latitude && GP1.Longitude > GP2.Longitude) { Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //Start city Lat max & long Mini Test if (GP1.Latitude > GP2.Latitude && GP1.Longitude < GP2.Longitude) { Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } else { //start city lat Min & long Max Test if (GP1.Latitude < GP2.Latitude && GP1.Longitude > GP2.Longitude) { Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100); Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100); } } } } Gp3.IconImage = "../_images/cycle.png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gp3); if (GP1.Latitude > GP2.Latitude) { centerlat = GP2.Latitude; } else { centerlat = GP1.Latitude; } if (GP1.Longitude > GP2.Longitude) { ceterlong = GP2.Longitude; } else { ceterlong = GP1.Longitude; } //GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 146; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", centerlat, ceterlong); GooglePolyline PL1 = new GooglePolyline(); PL1.ID = "PL1"; //Give Hex code for line color PL1.ColorCode = "#0000FF"; //Specify width for line PL1.Width = 5; PL1.Points.Add(GP1); PL1.Points.Add(GP2); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } catch (Exception ex) { Helper.Log(ex.Message, "Bind Google Map & Cycle "); } }
private void BindMap(string GpxFile, string FileName) { lblJourny.Text = FileName; div_GpxMap.Visible = true; GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "960px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "450px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 15; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Green"; DataTable _dt = new DataTable(); _dt = LoadGPXWaypoints(GpxFile); if (_dt != null && _dt.Rows.Count > 0) { int i = Convert.ToInt32(_dt.Rows.Count); GooglePoint[] Gpoint = new GooglePoint[i + 1]; List <string> City = new List <string>(); bool frmCity = false; bool toCity = false; int objCont = 0; int pointsCount = 20; if (i < pointsCount) { pointsCount = i; } int pointsInterval = i / 20; int pointsPloatted = 1; for (int Count = 0; Count < _dt.Rows.Count; Count++) { if (Count % (pointsInterval + 1) == 0 && pointsPloatted < 19) { string FromCity, ToCity = string.Empty; double FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0; try { FromCitylat = double.Parse(_dt.Rows[Count]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture); FromCitylon = double.Parse(_dt.Rows[Count]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture); ToCitylat = double.Parse(_dt.Rows[Count + 1]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture); ToCitylog = double.Parse(_dt.Rows[Count + 1]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture); if (FromCitylat != 0) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].Latitude = FromCitylat; Gpoint[objCont].Longitude = FromCitylon; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = true; objCont++; } if (ToCitylat != 0) { Gpoint[objCont] = new GooglePoint(); Gpoint[objCont].Latitude = ToCitylat; Gpoint[objCont].Longitude = ToCitylog; //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]); dat1.NewRow(); dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude); PL1.Points.Add(Gpoint[objCont]); frmCity = false; objCont++; } } catch (Exception ex) { } GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); pointsPloatted++; } } Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field <double>("Lattitude"); double Longitude = dr.Field <double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } else { GooglePoint GP0 = new GooglePoint(); GP0.Latitude = 51.165691; GP0.Longitude = 10.451526; GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "400px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 14; //Specify Center Point for map. Map will be centered on this point. GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", 43.66619, -79.44268); //Add pushpins for map. //This should be done with intialization of GooglePoint class. //ID is to identify a pushpin. It must be unique for each pin. Type is string. //Other properties latitude and longitude. GooglePoint GP1 = new GooglePoint(); GP1.ID = "pushpin"; GP1.Latitude = 43.65669; GP1.Longitude = -79.44268; //Specify bubble text here. You can use standard HTML tags here. GP1.InfoHTML = "This is Pushpin 1"; //Specify icon image. This should be relative to root folder. GP1.IconImage = "icons/pushpin-blue.png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1); GooglePoint GP2 = new GooglePoint(); GP2.ID = "horse"; GP2.Latitude = 43.66619; GP2.Longitude = -79.44268; GP2.InfoHTML = "This is Pushpin 2"; GP2.IconImage = "icons/horse.png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2); GooglePoint GP3 = new GooglePoint(); GP3.ID = "arrows"; GP3.Latitude = 43.67689; GP3.Longitude = -79.43270; GP3.InfoHTML = "This is Pushpin 3"; GP3.IconImage = "icons/recycle.png"; GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3); GooglePolyline poly1 = new GooglePolyline(); poly1.ID = "Poly1"; poly1.Points.Add(GP1); poly1.Points.Add(GP2); poly1.Width = 3; GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(poly1); GooglePolyline poly2 = new GooglePolyline(); poly2.ID = "Poly2"; poly2.Points.Add(GP2); poly2.Points.Add(GP3); poly2.Width = 3; GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(poly2); GooglePolygon polygon1 = new GooglePolygon(); polygon1.ID = "Polygon1"; polygon1.Points.Add(new GooglePoint("p1", 43.67689, -79.42370)); polygon1.Points.Add(new GooglePoint("p2", 43.66689, -79.42570)); polygon1.Points.Add(new GooglePoint("p3", 43.65789, -79.41570)); GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(polygon1); } }
protected void Polylines_Add() { GridPostaje.DataBind(); gridPostajeLast.DataBind(); Random random = new Random(); int value = 0; GooglePolyline polyline = new GooglePolyline(); for (int i = 0; i < GridPostaje.Rows.Count; i++) { if (value != Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text)) { value = Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text); polyline = new GooglePolyline(); polyline.StrokeColor = System.Drawing.Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); polyline.StrokeWeight = 3; LatLng latlong = new LatLng(); latlong.Latitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[2].Text); latlong.Longitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[3].Text); polyline.Path.Add(latlong); } else { LatLng latlong = new LatLng(); latlong.Latitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[2].Text); latlong.Longitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[3].Text); polyline.Path.Add(latlong); } if (i == (GridPostaje.Rows.Count - 1)) value = 0; else { if (Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text) != Convert.ToInt16(GridPostaje.Rows[i + 1].Cells[1].Text)) value = 0; } GoogleMap1.Polylines.Add(polyline); } }
private void BindMap() { try { Remove(); GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "350px"; //Specify initial Zoom level. GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 2; //Specify Center Point for map. Map will be centered on this point. // Run time you can ava of lat or long List <GooglePoint> Gp = new List <GooglePoint>(); GooglePoint min = new GooglePoint(); int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint = new GooglePoint[i]; GooglePolyline PL1 = new GooglePolyline(); List <GooglePoint> Gp2 = new List <GooglePoint>(); int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()); GooglePoint[] Gpoint2 = new GooglePoint[i2]; GooglePoint min1 = new GooglePoint(); double centerlat; double ceterlong; DataTable dat1 = new DataTable(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); DataTable dat2 = new DataTable(); dat2.Columns.Add("Lattitude", typeof(double)); dat2.Columns.Add("Longitude", typeof(double)); PL1.ColorCode = "#0000FF"; PL1.Width = 5; for (int Count = 0; Count <= grdStagePlan.Rows.Count; Count++) { string FromCity = string.Empty; string ToCity = string.Empty; FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text; ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text; if (FromCity != null) { Gpoint[Count] = new GooglePoint(); Gp.Add(Gpoint[Count]); Gpoint[Count].ID = "Gpoint[Count]"; string appId = "dj0yJmk9NUdkWVpoeGhPMHh1JmQ9WVdrOVZXRnFaa0poTm1zbWNHbzlNVEl6TURBek1UYzJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD04Nw--"; string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(FromCity), appId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); try { using (WebResponse response = request.GetResponse()) { using (DataSet ds = new DataSet()) { try { ds.ReadXml(response.GetResponseStream()); Gpoint[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); Gpoint[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[Count]); Gpoint[Count].InfoHTML = FromCity; Gpoint[Count].IconImage = "icons/sun.png"; dat1.NewRow(); dat1.Rows.Add(Gpoint[Count].Latitude, Gpoint[Count].Longitude); response.Close(); } catch (Exception ex) { } finally { ds.Dispose(); } } } } catch (Exception ex) { } } if (ToCity != null) { Gpoint2[Count] = new GooglePoint(); Gp2.Add(Gpoint[Count]); Gpoint2[Count].ID = "Gpoint2[Count]"; string appId = "{ConsumerKey}"; string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(ToCity), appId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); using (WebResponse response = request.GetResponse()) { using (DataSet ds = new DataSet()) { try { ds.ReadXml(response.GetResponseStream()); Gpoint2[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); Gpoint2[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture); GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint2[Count]); Gpoint2[Count].InfoHTML = ToCity; Gpoint[Count].IconImage = "icons/snow.png"; dat2.NewRow(); dat2.Rows.Add(Gpoint2[Count].Latitude, Gpoint2[Count].Longitude); response.Close(); } catch (Exception ex) { } finally { //ds.Clear(); ds.Dispose(); } } } } PL1.Points.Add(Gpoint[Count]); PL1.Points.Add(Gpoint2[Count]); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); } //Plyline Draw // GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); //Google Map Certer Double MinLattitude = Double.MaxValue; Double MinLongitude = Double.MaxValue; foreach (DataRow dr in dat1.Rows) { double Lattitude = dr.Field <double>("Lattitude"); double Longitude = dr.Field <double>("Longitude"); MinLattitude = Math.Min(MinLattitude, Lattitude); MinLongitude = Math.Min(MinLongitude, Longitude); } GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude); } catch (Exception ex) { } }
protected void Polylines_Add_From_gvDrawOnMap() { double golden_ratio = 0.618033988749895; Random random = new Random(); double h = random.NextDouble(); int value = 0; GooglePolyline polyline = new GooglePolyline(); for (int i = 0; i < gvDrawOnMap.Rows.Count; i++) { if (value != Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text)) { h += golden_ratio; h %= 1; value = Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text); polyline = new GooglePolyline(); polyline.StrokeColor = ColorFromHSV(h, 0.99, 0.99); polyline.StrokeWeight = 4; LatLng latlong = new LatLng(); latlong.Latitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[2].Text); latlong.Longitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[3].Text); polyline.Path.Add(latlong); } else { LatLng latlong = new LatLng(); latlong.Latitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[2].Text); latlong.Longitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[3].Text); polyline.Path.Add(latlong); } if (i == (gvDrawOnMap.Rows.Count - 1)) value = 0; else { if (Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text) != Convert.ToInt16(gvDrawOnMap.Rows[i + 1].Cells[1].Text)) value = 0; } GoogleMap1.Polylines.Add(polyline); } }
/// THIS FUNCTION JUST GENERATES THE LINES BETWEEN POINTS void GenerateGMap(List <string> LongLat, List <string> FipS, List <string> Frttave, string dirname, List <string> methodstr, List <string> FASno, List <string> FASna) { //GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear(); //GoogleMapForASPNet1.GoogleMapObject.Points.Clear(); List <double> LonLat = LongLat.Select(x => double.Parse(x)).ToList(); int m = 0; double longg = 0; double lat = 0; string ll1 = "0"; string ll2 = "0"; List <string> Flonglatlist = new List <string>(); List <string> zeroballoonlist = new List <string>(); List <double> rttcompare = new List <double>(); foreach (double prime in LonLat) { if (m < 1) { longg = prime; m = 1; ll1 = Convert.ToString(longg); } else if (m > 0) { lat = prime; ll2 = Convert.ToString(lat); ll2 = ll1 + "_" + ll2; Flonglatlist.Add(ll2); m = 0; } } for (int indx = 0; indx < Frttave.Count; indx++) { string Rrtttemp = Frttave[indx]; string[] numbers = Regex.Split(Rrtttemp, @"\D+"); foreach (string value in numbers) { if (!string.IsNullOrEmpty(value)) { int i = int.Parse(value); rttcompare.Add(i); } } } int idline = 0; for (int indx = 0; indx < Flonglatlist.Count; indx++) { if (indx != 0) { if (Flonglatlist[indx] == "0_0") { continue; } else { int prevll = indx; prevll = prevll - 1; while (prevll >= 0) { if (Flonglatlist[prevll] == "0_0") { prevll = prevll - 1; } else { idline = idline + 1; string idl = Convert.ToString(idline); GooglePolyline PL1 = new GooglePolyline(); double sss = rttcompare[indx]; if (sss <= 80) { PL1.ColorCode = "#FFF014"; } else if ((sss > 80) & (sss <= 160)) { PL1.ColorCode = "#00FF78"; } else if ((sss > 160) & (sss <= 240)) { PL1.ColorCode = "#3C78FF"; } else if ((sss > 240) & (sss <= 320)) { PL1.ColorCode = "#FF7814"; } else if ((sss > 320) & (sss <= 400)) { PL1.ColorCode = "#14FFF0"; } else if (sss > 400) { PL1.ColorCode = "#FF0014"; } PL1.ID = "PL1"; PL1.Width = 5; string[] words2 = Flonglatlist[prevll].Split('_'); double longg0 = Convert.ToDouble(words2[0]); double lat0 = Convert.ToDouble(words2[1]); PL1.Points.Add(new GooglePoint(idl, lat0, longg0)); string[] words = Flonglatlist[indx].Split('_'); double longg1 = Convert.ToDouble(words[0]); double lat1 = Convert.ToDouble(words[1]); PL1.Points.Add(new GooglePoint(idl, lat1, longg1)); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); break; } } } } } }
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); } }
void GenerateGMap(List <string> LongLat, List <string> FipS, List <string> Frttave, string dirname, List <string> methodstr, List <string> FASno, List <string> FASna) { List <double> LonLat = LongLat.Select(x => double.Parse(x)).ToList(); int m = 0; int IDpp = 60; int k = 0; int Frepeat = 0; int Frep2 = 1; int zeroflag = 0; double longg = 0; double lat = 0; string ll1 = "0"; string ll2 = "0"; List <string> Flonglatlist = new List <string>(); List <string> zeroballoonlist = new List <string>(); List <double> rttcompare = new List <double>(); foreach (double prime in LonLat) { if (m < 1) { longg = prime; m = 1; ll1 = Convert.ToString(longg); } else if (m > 0) { lat = prime; ll2 = Convert.ToString(lat); ll2 = ll1 + "_" + ll2; Flonglatlist.Add(ll2); m = 0; } } for (int ind = 0; ind < Flonglatlist.Count; ind++) { Frep2 = 1; if (Flonglatlist[ind] == "0_0") { zeroballoonlist.Add("<tr><td width=10%>" + Convert.ToString(ind) + "</td><td width=35%>" + FipS[ind] + "</td><th width=25%>" + Frttave[ind] + "</td><td width=5%>" + methodstr[ind] + "</td><td width=10%>" + FASno[ind] + "</td><td width=15%>" + FASna[ind] + "</td></tr></table>"); zeroflag = 1; } else { if (ind > 0) { k = 0; while ((k < ind) & (Frep2 > 0)) { if (Flonglatlist[ind] == Flonglatlist[k]) { string filename = "FDesc" + k.ToString() + ".txt"; System.IO.StreamReader replac = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string replactabl = replac.ReadToEnd(); replactabl = replactabl.Replace("</table>", ""); replac.Close(); System.IO.File.WriteAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), replactabl); if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } zeroballoonlist.Clear(); string nonzeroinfo = "<tr><td width=10%>" + Convert.ToString(ind) + "</td><td width=35%>" + FipS[ind] + "</td><th width=25%>" + Frttave[ind] + "</td><td width=5%>" + methodstr[ind] + "</td><td width=10%>" + FASno[ind] + "</td><td width=15%>" + FASna[ind] + "</td></tr></table>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<tr><td width=10%>" + Convert.ToString(ind) + "</td><td width=35%>" + FipS[ind] + "</td><th width=25%>" + Frttave[ind] + "</td><td width=5%>" + methodstr[ind] + "</td><td width=10%>" + FASno[ind] + "</td><td width=15%>" + FASna[ind] + "</td></tr></table>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Fdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Flonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string icon = ""; if (ind == 0) { icon = "icons/database.png"; } else if (ind == (Flonglatlist.Count - 1)) { icon = "icons/database.png"; } else { icon = "icons/wifi.png"; } string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, icon, Fdesctext)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); Frepeat = Frepeat + 1; Frep2 = 0; } else { k = k + 1; Frepeat = 0; } } } if (Frepeat == 0) { string filename = "FDesc" + ind.ToString() + ".txt"; string heading = "<table width=100% table border=1 cellspacing=3><tr><th width=10%>Hop No</th><th width=35%>IP Address</th><th width=25%>RTT Average</th><th width=5%>Method</th><th width=10%>AS No</th><th width=15%>AS</th></tr>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), heading); if (zeroflag == 1) { foreach (string inf in zeroballoonlist) { File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), inf); } zeroballoonlist.Clear(); string nonzeroinfo = "<tr><td width=10%>" + Convert.ToString(ind) + "</td><td width=35%>" + FipS[ind] + "</td><th width=25%>" + Frttave[ind] + "</td><td width=5%>" + methodstr[ind] + "</td><td width=10%>" + FASno[ind] + "</td><td width=15%>" + FASna[ind] + "</td></tr></table>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), nonzeroinfo); zeroflag = 0; } else { string ballooninfo = "<tr><td width=10%>" + Convert.ToString(ind) + "</td><td width=35%>" + FipS[ind] + "</td><th width=25%>" + Frttave[ind] + "</td><td width=5%>" + methodstr[ind] + "</td><td width=10%>" + FASno[ind] + "</td><td width=15%>" + FASna[ind] + "</td></tr></table>"; File.AppendAllText(Server.MapPath("~/App_Data/" + dirname + "/" + filename), ballooninfo); } System.IO.StreamReader descfile = new System.IO.StreamReader(Server.MapPath("~/App_Data/" + dirname + "/" + filename)); string Fdesctext = descfile.ReadToEnd(); descfile.Close(); string[] words = Flonglatlist[ind].Split('_'); longg = Convert.ToDouble(words[0]); lat = Convert.ToDouble(words[1]); string icon = ""; if (ind == 0) { icon = "icons/database.png"; } else if (ind == (Flonglatlist.Count - 1)) { icon = "icons/database.png"; } else { icon = "icons/wifi.png"; } string idpps = Convert.ToString(IDpp); GoogleMapForASPNet1.GoogleMapObject.Points.Add(new GooglePoint(idpps, lat, longg, icon, Fdesctext)); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint(idpps, lat, longg); } IDpp = IDpp + 1; } } for (int indx = 0; indx < Frttave.Count; indx++) { string Rrtttemp = Frttave[indx]; string[] numbers = Regex.Split(Rrtttemp, @"\D+"); foreach (string value in numbers) { if (!string.IsNullOrEmpty(value)) { int i = int.Parse(value); rttcompare.Add(i); } } } int idline = 0; for (int indx = 0; indx < Flonglatlist.Count; indx++) { if (indx != 0) { if (Flonglatlist[indx] == "0_0") { continue; } else { int prevll = indx; prevll = prevll - 1; while (prevll >= 0) { if (Flonglatlist[prevll] == "0_0") { prevll = prevll - 1; } else { idline = idline + 1; string idl = Convert.ToString(idline); GooglePolyline PL1 = new GooglePolyline(); double sss = rttcompare[indx]; if (sss <= 100) { PL1.ColorCode = "#FFF014"; } else if ((sss > 100) & (sss <= 200)) { PL1.ColorCode = "#00FF78"; } else if ((sss > 200) & (sss <= 300)) { PL1.ColorCode = "#FFF014"; } else if ((sss > 300) & (sss <= 400)) { PL1.ColorCode = "#FF7814"; } else if (sss > 400) { PL1.ColorCode = "#FF0014"; } PL1.ID = "PL1"; PL1.Width = 5; string[] words2 = Flonglatlist[prevll].Split('_'); double longg0 = Convert.ToDouble(words2[0]); double lat0 = Convert.ToDouble(words2[1]); PL1.Points.Add(new GooglePoint(idl, lat0, longg0)); string[] words = Flonglatlist[indx].Split('_'); double longg1 = Convert.ToDouble(words[0]); double lat1 = Convert.ToDouble(words[1]); PL1.Points.Add(new GooglePoint(idl, lat1, longg1)); GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1); break; } } } } } }
private void BindMap(float Citylat, float Citylon, string CityName) { div_Map.Visible = true; GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container. GoogleMapForASPNet1.GoogleMapObject.Width = "500px"; // You can also specify percentage(e.g. 80%) here GoogleMapForASPNet1.GoogleMapObject.Height = "300px"; DataTable dat1 = new DataTable(); GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5; GooglePoint GP = new GooglePoint(); dat1.Columns.Add("Lattitude", typeof(double)); dat1.Columns.Add("Longitude", typeof(double)); GooglePolyline PL1 = new GooglePolyline(); PL1.Width = 5; PL1.ColorCode = "Blue"; GooglePoint[] Gpoint = new GooglePoint[1]; List<string> City = new List<string>(); Gpoint[0] = new GooglePoint(); Gpoint[0].InfoHTML = CityName; Gpoint[0].Latitude = Citylat; Gpoint[0].Longitude = Citylon; GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[0]); GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", Citylat, Citylon); }