public frmStreetView(int driverId, Fleet_Driver_Location objLoc) { InitializeComponent(); this.DriverId = driverId; timer1.Tick += new EventHandler(timer1_Tick); this.FormClosing += new FormClosingEventHandler(frmStreetView_FormClosing); RefreshView(objLoc); this.KeyDown += new KeyEventHandler(frmStreetView_KeyDown); this.Shown += new EventHandler(frmStreetView_Shown); }
private void RefreshView(Fleet_Driver_Location objLocation) { try { if (objLocation == null || objLocation.Latitude == Latitude) { return; } dataGridView1.Rows.Clear(); dataGridView1.Rows.Add(); dataGridView1.Rows[0].Cells["Driver"].Value = objLocation.Fleet_Driver.DriverNo; dataGridView1.Rows[0].Cells["Location"].Value = objLocation.LocationName; dataGridView1.Rows[0].Cells["colDateTime"].Value = string.Format("{0:dd/MM/yyyy HH:mm:ss}", objLocation.UpdateDate); dataGridView1.Rows[0].Cells["Speed"].Value = Math.Round(objLocation.Speed, 2); Latitude = objLocation.Latitude; Longitude = objLocation.Longitude; string text = "<!DOCTYPE html>" + "<html>" + "<head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">" + "<meta charset=\"utf-8\">" + "<link href=\"/maps/documentation/javascript/examples/default.css\" rel=\"stylesheet\">" + "<script src=\"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false\"></script>" + "<script>" + "function initialize() {" + "var fenway = new google.maps.LatLng(" + Latitude + "," + Longitude + ");" + "var mapOptions = {" + "center: fenway," + "zoom: 14," + "mapTypeId: google.maps.MapTypeId.ROADMAP" + "};" + "var map = new google.maps.Map(" + "document.getElementById('map-canvas'), mapOptions);" + "var panoramaOptions = {" + "position: fenway," + "pov: {" + "heading: 34," + "pitch: 10" + "}" + "};" + "var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'),panoramaOptions);" + "map.setStreetView(panorama);" + "}" + "google.maps.event.addDomListener(window, 'load', initialize);" + "</script>" + "</head>" + " <body>" + "<div id=\"map-canvas\" style=\"display:none\"></div>" + "<div id=\"pano\" style=\"position:absolute; top: 1px;left:1px; width: 1020px; height: 760px;\"></div>" + " </body>" + " </html>"; webBrowser1.DocumentText = @text; } catch (Exception ex) { } }
public void SetLocation(Fleet_Driver_Location objLoc) { RefreshView(objLoc); }