private void Stavirutu(double X, double Y, double Fx, double Fy, string mId) { List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(X, Y); PointLatLng end = new PointLatLng(Fx, Fy); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(mId); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; rute nova_rute = new rute(); nova_rute.start_X = X; nova_rute.tstart_X = X; nova_rute.start_Y = Y; nova_rute.tstart_Y = Y; nova_rute.finish_X = Fx; nova_rute.finish_Y = Fy; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = mId.ToString(); rutes.Add(nova_rute); }
private void example1() { GMap.NET.PointLatLng start; GMap.NET.PointLatLng end; //GMap.NET.GDirections gDirections1; GMap.NET.WindowsForms.GMapRoute gMapRoute1; GMap.NET.WindowsForms.GMapOverlay gMapOverlay1; try { // Luis hard-codes an example start- and end-point, // I think I might try to make it dynamic to help me understand it // and give me practice with it. // However at first to get the code running, I'm going to hard-code it. // start = new GMap.NET.PointLatLng(46.299106, -119.295999); end = new GMap.NET.PointLatLng(46.276860, -119.291511); var dirstatcode = GMap.NET.MapProviders.GMapProviders.GoogleMap.GetDirections(out gDirections1, start, end, false, // bool avoidHighways false, // bool avoidTolls false, // bool walking mode false, // bool sensor false // bool metric ); gMapRoute1 = new GMap.NET.WindowsForms.GMapRoute(gDirections1.Route, "foo"); // After trying this, I get an error at the aboe line, saying that gDirections1 was null. // // Try 1 // Changed MapProvider to GoogleMapProvider (was BingMapProvider). // No difference. // // Try 2 // Moved the declaration of "gDirections1" to the entire form. // No difference. gMapOverlay1 = new GMap.NET.WindowsForms.GMapOverlay(); // string param is optional gMapOverlay1.Routes.Add(gMapRoute1); //MainMap.Overlays.Add(gMapOverlay1); this.gMapControl1.Overlays.Add(gMapOverlay1); } catch (Exception ex) { MessageBox.Show("Exception happened, {0}", ex.Message); } }
private void DrawTrack(Core.NavigationElements.ITrack track) { if (_mapRoutes.ContainsKey(track.UniqueID) == false) { _mapRoutes.Add(track.UniqueID, null); } List <GMap.NET.WindowsForms.GMapRoute> routes = new List <GMapRoute>(); foreach (ITrackSegment segment in track.TrackSegments) { List <GMap.NET.PointLatLng> points = ConvertTrackSegment(segment); var route = new GMap.NET.WindowsForms.GMapRoute(points, "segment"); routes.Add(route); _trackOverlay.Routes.Add(route); } _mapRoutes[track.UniqueID] = routes; _trackOverlay.IsVisibile = true; }
private void DrawTrack(Core.NavigationElements.ITrack track) { if (_mapRoutes.ContainsKey(track.UniqueID) == false) { _mapRoutes.Add(track.UniqueID, null); } List<GMap.NET.WindowsForms.GMapRoute> routes = new List<GMapRoute>(); foreach (ITrackSegment segment in track.TrackSegments) { List<GMap.NET.PointLatLng> points = ConvertTrackSegment(segment); var route = new GMap.NET.WindowsForms.GMapRoute(points, "segment"); routes.Add(route); _trackOverlay.Routes.Add(route); } _mapRoutes[track.UniqueID] = routes; _trackOverlay.IsVisibile = true; }
public TrackPoint(int trackIndex, PointLatLng point, GMap.NET.WindowsForms.GMapRoute relatedRoute) : base(point) { _trackIndex = trackIndex; _route = relatedRoute; }
private void gMapControl1_MouseDoubleClick(object sender, MouseEventArgs e) { double X = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng; double Y = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat; if (r3.Checked == true) { gMapControl1.Position = new PointLatLng(Y, X); GMarkerGoogle marker; if (r2.Checked == true) { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.pink); } else { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.blue); } int indexOdabranePostrojbe = comboBox1.SelectedIndex + 41; TheChosenOne = indexOdabranePostrojbe.ToString(); marker.ToolTipText = marker_Id.ToString(); overlayOne.Markers.Add(marker); gMapControl1.Overlays.Add(overlayOne); podaci m = new podaci(); m.imena = TheChosenOne; m.prezimena = TheChosenOne; m.id_markera = marker_Id; marker_Id = marker_Id + 1; m.korX = X; m.korY = Y; if (r1.Checked == false) { m.vrsta = "enemy"; } else { m.vrsta = "our_team"; } markeri.Add(m); } else if (r4.Checked == true) { if (marker_ruta == null) { MessageBox.Show("Moraš prvo kreirati barem jedan marker da bi mu mogao dodijeliti rutu..."); } else { rute nova_rute = new rute(); nova_rute.start_X = temporary.korX; nova_rute.tstart_X = temporary.korX; nova_rute.start_Y = temporary.korY; nova_rute.tstart_Y = temporary.korY; nova_rute.finish_X = Y; nova_rute.finish_Y = X; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = marker_ruta; rutes.Add(nova_rute); List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(temporary.korX, temporary.korY); PointLatLng end = new PointLatLng(Y, X); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(marker_ruta); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; } } }
private void gMapControl1_MouseDoubleClick(object sender, MouseEventArgs e) { double X = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng; double Y = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat; if (mr.Text == "marker") { gMapControl1.Position = new PointLatLng(Y, X); GMarkerGoogle marker; if (strana.Text == "neprijatelj") { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.pink); } else { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.blue); } TheChosenOne = comboBox1.Text; marker.ToolTipText = TheChosenOne; overlayOne.Markers.Add(marker); gMapControl1.Overlays.Add(overlayOne); markeri.Where(podaci => podaci.imena == TheChosenOne).First().korX = X; markeri.Where(podaci => podaci.imena == TheChosenOne).First().korY = Y; if (strana.Text == "neprijatelj") { markeri.Where(podaci => podaci.imena == TheChosenOne).First().vrsta = "enemy"; } else { markeri.Where(podaci => podaci.imena == TheChosenOne).First().vrsta = "our_team"; } } else if (mr.Text == "rute") { if (marker_ruta == null) { MessageBox.Show("Moraš prvo kreirati barem jedan marker da bi mu mogao dodijeliti rutu..."); } else { rute nova_rute = new rute(); nova_rute.start_X = temporary.korY; nova_rute.tstart_X = temporary.korY; nova_rute.start_Y = temporary.korX; nova_rute.tstart_Y = temporary.korX; nova_rute.finish_X = Y; nova_rute.finish_Y = X; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = marker_ruta; rutes.Add(nova_rute); List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(temporary.korY, temporary.korX); PointLatLng end = new PointLatLng(Y, X); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(idRute_povecaj); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; } } else { MessageBox.Show("Feel the nope!! Moraš il rute il markere odabrati za postavljanje.. :)"); } }
private void frmDriver_Load(object sender, EventArgs e) { panel2.Visible = false; pctSettings2.Visible = false; panel3.Visible = false; pctProfile2.Visible = false; timer1.Start(); GMapProviders.GoogleMap.ApiKey = @"AIzaSyA2yOciCrtfmt8Gt7290nUFBqfptsSuo9I"; gMap.DragButton = MouseButtons.Left; gMap.MapProvider = GMapProviders.GoogleMap; double lat = 14.526587; double longt = 121.056003; gMap.Position = new GMap.NET.PointLatLng(lat, longt); gMap.MinZoom = 1; gMap.MaxZoom = 18; gMap.Zoom = 25; //new marker Bitmap studmarker = (Bitmap)Image.FromFile("img/stusdiyer.png"); Bitmap studmarker2 = (Bitmap)Image.FromFile("img/stusdiyer2.png"); GMap.NET.PointLatLng point = new GMap.NET.PointLatLng(lat, longt); GMap.NET.WindowsForms.GMapOverlay markers = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point, GMap.NET.WindowsForms.Markers.GMarkerGoogleType.red_dot); markers.Markers.Add(marker); gMap.Overlays.Add(markers); //destination GMap.NET.PointLatLng pointD = new GMap.NET.PointLatLng(14.555360, 121.043873); GMap.NET.WindowsForms.GMapOverlay markersD = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker markerD = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(pointD, GMap.NET.WindowsForms.Markers.GMarkerGoogleType.red_dot); markers.Markers.Add(markerD); gMap.Overlays.Add(markersD); //route GMap.NET.PointLatLng pointR = new GMap.NET.PointLatLng(14.555360, 121.043873); var route = GoogleMapProvider.Instance.GetRoute(point, pointR, false, false, 10); var r = new GMap.NET.WindowsForms.GMapRoute(route.Points, "My Route") { Stroke = new Pen(Color.Blue, 5) }; var routes = new GMapOverlay("routes"); routes.Routes.Add(r); gMap.Overlays.Add(routes); //student1 GMap.NET.PointLatLng point1 = new GMap.NET.PointLatLng(14.527394, 121.056395); GMap.NET.WindowsForms.GMapOverlay markers1 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker1 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point1, studmarker); markers.Markers.Add(marker1); gMap.Overlays.Add(markers1); //student1.1 GMap.NET.PointLatLng point11 = new GMap.NET.PointLatLng(14.527005, 121.056209); GMap.NET.WindowsForms.GMapOverlay markers11 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker11 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point11, studmarker); markers.Markers.Add(marker11); gMap.Overlays.Add(markers11); //student1.2 GMap.NET.PointLatLng point12 = new GMap.NET.PointLatLng(14.528199, 121.056666); GMap.NET.WindowsForms.GMapOverlay markers12 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker12 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point12, studmarker2); markers.Markers.Add(marker12); gMap.Overlays.Add(markers12); //student2 GMap.NET.PointLatLng point2 = new GMap.NET.PointLatLng(14.535635, 121.057739); GMap.NET.WindowsForms.GMapOverlay markers2 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker2 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point2, studmarker); markers.Markers.Add(marker2); gMap.Overlays.Add(markers2); //student21 GMap.NET.PointLatLng point21 = new GMap.NET.PointLatLng(14.535594, 121.057733); GMap.NET.WindowsForms.GMapOverlay markers21 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker21 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point21, studmarker2); markers.Markers.Add(marker21); gMap.Overlays.Add(markers21); //student21 GMap.NET.PointLatLng point22 = new GMap.NET.PointLatLng(14.536337, 121.057685); GMap.NET.WindowsForms.GMapOverlay markers22 = new GMap.NET.WindowsForms.GMapOverlay("markers"); GMap.NET.WindowsForms.GMapMarker marker22 = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(point22, studmarker2); markers.Markers.Add(marker22); gMap.Overlays.Add(markers22); }