void plotLBS(DataSet ds) { ReplayMap.MapType = (MapType)Session["mapType"]; double speed; int maxSpeed = 75; try { maxSpeed = Convert.ToInt32(ds.Tables[1].Rows[0]["maxSpeed"]); } catch (Exception) { maxSpeed = 75; } string lat = "20"; string lng = "73"; Artem.Google.UI.GooglePolyline pl = new Artem.Google.UI.GooglePolyline(); pl.StrokeColor = System.Drawing.Color.Blue; pl.StrokeWeight = 5; // ReplayMap.Markers.Clear(); if (ds.Tables[2].Rows.Count <= 0) { } else { DateTime prevTime = (DateTime)ds.Tables[2].Rows[0]["time"]; double newlat = 0; double newlong = 0; DateTime newtime = DateTime.Now; DateTime oldtime = DateTime.Now; int cnt = 1; int recordCnt = ds.Tables[2].Rows.Count; int m = 0; while (m < recordCnt) { speed = (double)ds.Tables[2].Rows[m]["speed"]; newlat = (double)ds.Tables[2].Rows[m]["latitude"]; newlong = (double)ds.Tables[2].Rows[m]["longitude"]; newtime = (DateTime)ds.Tables[2].Rows[m]["time"]; lat = newlat.ToString(); lng = newlong.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Date & Time : " + Date; GP1.Title = cnt.ToString(); cnt++; GP1.Icon = new MarkerImage().Url = "icons/tower.png"; ReplayMap.Markers.Add(GP1); //pl.Path.Add(new LatLng(newlat, newlong)); m++; } //ReplayMap.Polylines.Add(pl); ReplayMap.Center = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); } }
/* * void plotTrack(DataSet ds) * { * double speed; * int maxSpeed = 75; * Artem.Google.UI.GooglePolyline pl = new Artem.Google.UI.GooglePolyline(); * pl.StrokeColor = System.Drawing.Color.Blue; * pl.StrokeWeight = 5; * ReplayMap.Markers.Clear(); * if (ds.Tables[0].Rows.Count <= 0) * { * } * else * { * DateTime prevTime = (DateTime)ds.Tables[0].Rows[0]["time"]; * double newlat = 0; * double newlong = 0; * * DateTime newtime = DateTime.Now; * DateTime oldtime = DateTime.Now; * int cnt = 0; * int recordCnt = ds.Tables[0].Rows.Count; * int m = 0; * while (m < recordCnt) * { * speed = (double)ds.Tables[0].Rows[m]["speed"]; * newlat = (double)ds.Tables[0].Rows[m]["latitude"]; * newlong = (double)ds.Tables[0].Rows[m]["longitude"]; * newtime = (DateTime)ds.Tables[0].Rows[m]["time"]; * cnt = 0; * if (speed <=2) * { * while (m+1 < recordCnt) * { * if (Math.Round(newlat, 4) == Math.Round((double)ds.Tables[0].Rows[m+!]["latitude"], 4)&&Math.Round(newlong, 4) == Math.Round((double)ds.Tables[0].Rows[m]["longitude"],4)) * { * m++; * cnt++; * } * else * { * break; * } * } * if (cnt < 2) * { * double lat = (double)ds.Tables[0].Rows[m]["latitude"]; * double lng = (double)ds.Tables[0].Rows[m]["longitude"]; * string PlateNo = txtVehName.Text; * string Speed = speed.ToString(); * string Date = ds.Tables[0].Rows[m]["time"].ToString(); * Marker GP1 = new Marker(); * GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); * ViewState["lat"] = lat; * ViewState["lng"] = lng; * GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; * GP1.Title = newtime.TimeOfDay.ToString(); ; * GP1.Icon = new MarkerImage().Url = "icons/car_icon3.png"; * ReplayMap.Markers.Add(GP1); * pl.Path.Add(new LatLng(lat,lng)); * } * else * { * oldtime = (DateTime)ds.Tables[0].Rows[m - 1]["time"]; * string PlateNo = txtVehName.Text; * string Speed = "0"; * string Date = newtime.ToString(); * Marker GP1 = new Marker(); * GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); * ViewState["lat"] = lat; * ViewState["lng"] = lng; * GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Time from:" + newtime + " to:" + oldtime; * GP1.Title = "Stop from " + newtime.TimeOfDay + " to " + oldtime.TimeOfDay; * GP1.Icon = new MarkerImage().Url = "icons/car_icon3big.png"; * ReplayMap.Markers.Add(GP1); * pl.Path.Add(new LatLng(lat, lng)); * * } * } * else if (speed > maxSpeed) * { * lat = newlat; * lng = newlong; * string PlateNo = txtVehName.Text; * string Speed = speed.ToString(); * string Date = newtime.ToString(); * Marker GP1 = new Marker(); * GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); * ViewState["lat"] = lat; * ViewState["lng"] = lng; * GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; * GP1.Title = newtime.TimeOfDay.ToString(); * GP1.Icon = new MarkerImage().Url = "icons/car_icon2.png"; * ReplayMap.Markers.Add(GP1); * pl.Path.Add(new LatLng(lat, lng)); * } * else * { * string PlateNo = txtVehName.Text; * string Speed = speed.ToString(); * string Date = newtime.ToString(); * Marker GP1 = new Marker(); * GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); * ViewState["lat"] = lat; * ViewState["lng"] = lng; * GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + newlat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; * GP1.Title = newtime.TimeOfDay.ToString(); * GP1.Icon = new MarkerImage().Url = "icons/car_icon4.png"; * ReplayMap.Markers.Add(GP1); * pl.Path.Add(new LatLng(lat, lng)); * * } * m++; * } * ReplayMap.Polylines.Add(pl); * ReplayMap.Center = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); * } * * } */ void liveTrackPlay() { if (txtVehName.SelectedItem != null) { DataSet ds = new System.Data.DataSet(); cls_Carriers obj_carrier = new cls_Carriers(); string lat; string lng; ds = obj_carrier.fn_CarrierMtsLoc_FetchBY_CarrierID(Int32.Parse(txtVehName.SelectedItem.Value), (DateTime)Session["followStartTime"]); if (ds.Tables[0].Rows.Count == 0) { ds = obj_carrier.fn_CarrierLastLoc_FetchBY_CarrierID(Int32.Parse(txtVehName.SelectedItem.Value)); } LatLng ltlng = new LatLng(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { lat = ds.Tables[0].Rows[i]["latitude"].ToString(); lng = ds.Tables[0].Rows[i]["longitude"].ToString(); string PlateNo = ds.Tables[0].Rows[i]["carrierName"].ToString(); string Speed = ds.Tables[0].Rows[i]["speed"].ToString(); string D1 = ds.Tables[0].Rows[i]["Din1"].ToString(); string Date = ds.Tables[0].Rows[i]["time"].ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Digital Ignition : " + D1 + "</br>" + "Date & Time : " + Date; GP1.Title = PlateNo; if (D1 == "1" || Int32.Parse(Speed) > 2) { GP1.Icon = new MarkerImage().Url = "icons/car_icon4.png"; } else { GP1.Icon = new MarkerImage().Url = "icons/car_icon3.png"; } ReplayMap.Markers.Add(GP1); if (i != 0) { Artem.Google.UI.GooglePolyline pl = new Artem.Google.UI.GooglePolyline(); pl.StrokeColor = System.Drawing.Color.Blue; pl.StrokeWeight = 5; pl.Path.Add(new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng))); pl.Path.Add(ltlng); ReplayMap.Polylines.Add(pl); } ltlng = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); ReplayMap.Center = (ltlng); ReplayMap.OverviewMapControlOptions.Opened = true; } } else { // Page.ClientScript.RegisterStartupScript(Page.GetType(), "MyKey", "selectError()", true); //DateBoxError.Text = "Please select a Vehicle to follow!"; liveFollow.Checked = false; updatePanelControlPanel.Update(); } }
void plotTrack(DataSet ds) { ReplayMap.MapType = (MapType)Session["mapType"]; double speed; int maxSpeed = 75; try { maxSpeed = Convert.ToInt32(ds.Tables[1].Rows[0]["maxSpeed"]); } catch (Exception) { maxSpeed = 75; } string lat = "20"; string lng = "73"; Artem.Google.UI.GooglePolyline pl = new Artem.Google.UI.GooglePolyline(); pl.StrokeColor = System.Drawing.Color.Blue; pl.StrokeWeight = 5; ReplayMap.Markers.Clear(); if (ds.Tables[0].Rows.Count <= 0) { } else { DateTime prevTime = (DateTime)ds.Tables[0].Rows[0]["time"]; double oldspeed = 0; double newlat = 0; double newlong = 0; DateTime newtime = DateTime.Now; DateTime oldtime = DateTime.Now; int cnt = 0; int recordCnt = ds.Tables[0].Rows.Count; int m = 0; if (chkfilter.Checked == false) { while (m < recordCnt) { speed = (double)ds.Tables[0].Rows[m]["speed"]; newlat = (double)ds.Tables[0].Rows[m]["latitude"]; newlong = (double)ds.Tables[0].Rows[m]["longitude"]; newtime = (DateTime)ds.Tables[0].Rows[m]["time"]; if (speed < 1) { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString();; GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } else if (speed > maxSpeed) { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString(); GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } else { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString(); GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } m++; } } else { while (m < recordCnt) { speed = (double)ds.Tables[0].Rows[m]["speed"]; newlat = (double)ds.Tables[0].Rows[m]["latitude"]; newlong = (double)ds.Tables[0].Rows[m]["longitude"]; newtime = (DateTime)ds.Tables[0].Rows[m]["time"]; cnt = 0; if (speed <= 2) { m++; if (m >= recordCnt) { break; } oldspeed = (double)ds.Tables[0].Rows[m]["speed"]; while (oldspeed <= 2 && m < recordCnt) { oldspeed = (double)ds.Tables[0].Rows[m]["speed"]; m++; cnt++; } if (cnt < 2) { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString();; GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } else { oldspeed = (double)ds.Tables[0].Rows[m - 2]["speed"]; oldtime = (DateTime)ds.Tables[0].Rows[m - 2]["time"]; lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = "0"; string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Time from:" + newtime + " to:" + oldtime; GP1.Title = "Stop from " + newtime.TimeOfDay + " to " + oldtime.TimeOfDay; GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } } else if (speed > maxSpeed) { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString(); GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } else { lat = newlat.ToString(); lng = newlong.ToString(); string PlateNo = txtVehName.Text; string Speed = speed.ToString(); string Date = newtime.ToString(); Marker GP1 = new Marker(); GP1.Position = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); GP1.Info = "Plate No : " + PlateNo + "</br>" + "Latitude : " + lat + "</br>" + "Longitude : " + "" + lng + "</br>" + "Speed : " + "" + Speed + "</br>" + "Date & Time : " + Date; GP1.Title = newtime.TimeOfDay.ToString(); GP1.Icon = new MarkerImage().Url = "icons/personal1blue.png"; ReplayMap.Markers.Add(GP1); pl.Path.Add(new LatLng(newlat, newlong)); } m++; } } ReplayMap.Polylines.Add(pl); ReplayMap.Center = new LatLng(Convert.ToDouble(lat), Convert.ToDouble(lng)); } }