private void addpolygonmarker(string tag, double lng, double lat, int alt, Color?color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(point); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; try { mBorders.wprad = (int)(float.Parse(ArdupilotMega.MainV2.config["TXT_WPRad"].ToString()) / MainV2.comPort.MAV.cs.multiplierdist); } catch { } //mBorders.MainMap = MainMap; if (color.HasValue) { mBorders.Color = color.Value; } } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
// add marker on current position private void button4_Click(object sender, EventArgs e) { GMapMarker m = new GMapMarkerGoogleGreen(currentMarker.Position); GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); mBorders.Size = new System.Drawing.Size(100, 100); //Placemark p = null; //if (checkBoxPlacemarkInfo.Checked) //{ // p = GMaps.Instance.GetPlacemarkFromGeocoder(currentMarker.Position); //} //if (p != null) //{ // mBorders.ToolTipText = p.Address; //} //else //{ // mBorders.ToolTipText = currentMarker.Position.ToString(); //} objects.Markers.Add(m); objects.Markers.Add(mBorders); }
// click on some marker 我现在不知道这些功能 void MainMap_OnMarkerClick(GMapMarker item, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (item is GMapMarkerRect) { GeoCoderStatusCode status; var pos = GMapProviders.GoogleMap.GetPlacemark(item.Position, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pos != null) { GMapMarkerRect v = item as GMapMarkerRect; { v.ToolTipText = pos.Value.Address; } MainMap1.Invalidate(false); } } else { if (item.Tag != null) { if (currentTransport != null) { currentTransport.ToolTipMode = MarkerTooltipMode.OnMouseOver; currentTransport = null; } currentTransport = item; currentTransport.ToolTipMode = MarkerTooltipMode.Always; } } } }
// add demo circle void MainMap_MouseDoubleClick(object sender, MouseEventArgs e) { //string constring = "datasource=" + metroTextBox1.Text + ";database=" + metroTextBox2.Text + ";username="******";password="******";port=" + Convert.ToInt32(metroTextBox5.Text); //string constring = "datasource=" + metroTextBox1.Text + ";username="******";password="******";port=" + Convert.ToInt32(metroTextBox5.Text); GMarkerGoogle m = new GMarkerGoogle(currentMarker.Position, GMarkerGoogleType.yellow); GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); { mBorders.InnerMarker = m; if (polygon != null) { // mBorders.Tag = polygon.Points.Count; } mBorders.ToolTipMode = MarkerTooltipMode.OnMouseOver; } Placemark?p = null; //if (checkBoxPlacemarkInfo.Checked) //{ //mBorders.ToolTipText = currentMarker.Position.ToString(); mBorders.ToolTipText = "ha"; string Query = "insert into " + metroTextBox2.Text + ".maptable (No,Name,Lattitude,Longitude) values ('2','" + metroTextBox6.Text + "','" + Convert.ToString(currentMarker.Position.Lat) + "','" + Convert.ToString(currentMarker.Position.Lng) + "');"; //MySqlConnection conDataBase = new MySqlConnection(constring); //MySqlCommand cmdDataBase = new MySqlCommand(Query, conData Base); objects.Markers.Add(m); objects.Markers.Add(mBorders); MainMap.Overlays.Add(objects); //var cc = new GMapMarkerCircle(MainMap.FromLocalToLatLng(e.X, e.Y)); //objects.Markers.Add(cc); }
private void addpolygonmarkerred(string tag, double lng, double lat, int alt, Color?color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; } Invoke((Action) delegate { overlay.Markers.Add(m); overlay.Markers.Add(mBorders); }); } catch (Exception) { } }
/// <summary> /// used to add a marker to the map display /// </summary> /// <param name="tag"></param> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="alt"></param> /// <param name="color"></param> private void addpolygonmarker(string tag, double lng, double lat, double?alt, Color?color, double wpradius, MAVLink.MAV_MISSION_TYPE type = MAVLink.MAV_MISSION_TYPE.MISSION, Color?fillcolor = null) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarker m = null; if (type == MAVLink.MAV_MISSION_TYPE.MISSION) { m = new GMapMarkerWP(point, tag); if (alt.HasValue) { m.ToolTipMode = MarkerTooltipMode.OnMouseOver; m.ToolTipText = "Alt: " + alt.Value.ToString("0"); } m.Tag = tag; } else if (type == MAVLink.MAV_MISSION_TYPE.FENCE) { m = new GMarkerGoogle(point, GMarkerGoogleType.blue_dot); m.Tag = tag; } else if (type == MAVLink.MAV_MISSION_TYPE.RALLY) { m = new GMapMarkerRallyPt(point); if (alt.HasValue) { m.ToolTipMode = MarkerTooltipMode.OnMouseOver; m.ToolTipText = "Alt: " + alt.Value.ToString("0"); } m.Tag = tag; } //MissionPlanner.GMapMarkerRectWPRad mBorders = new MissionPlanner.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.Tag = tag; mBorders.wprad = (int)wpradius; if (color.HasValue) { mBorders.Color = color.Value; } if (fillcolor.HasValue) { mBorders.FillColor = fillcolor.Value; } } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
void MainMap_OnMarkerLeave(GMapMarker item) { if (item is GMapMarkerRect) { CurentRectMarker = null; GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Blue; Debug.WriteLine("OnMarkerLeave: " + item.Position); } }
void MainMap_OnMarkerEnter(GMapMarker item) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; CurentRectMarker = rc; Debug.WriteLine("OnMarkerEnter: " + item.Position); } }
// key-up events void MainForm_KeyUp(object sender, GUI.KeyEventArgs e) { int offset = -22; if (e.KeyCode == GUI.Keys.Left) { MainMap.Offset(-offset, 0); } else if (e.KeyCode == GUI.Keys.Right) { MainMap.Offset(offset, 0); } else if (e.KeyCode == GUI.Keys.Up) { MainMap.Offset(0, -offset); } else if (e.KeyCode == GUI.Keys.Down) { MainMap.Offset(0, offset); } else if (e.KeyCode == GUI.Keys.Delete) { if (currentPolygon != null) { polygons.Polygons.Remove(currentPolygon); currentPolygon = null; } if (currentRoute != null) { routes.Routes.Remove(currentRoute); currentRoute = null; } if (CurentRectMarker != null) { objects.Markers.Remove(CurentRectMarker); if (CurentRectMarker.InnerMarker != null) { objects.Markers.Remove(CurentRectMarker.InnerMarker); } CurentRectMarker = null; RegeneratePolygon(); } } else if (e.KeyCode == GUI.Keys.Escape) { MainMap.Bearing = 0; } }
void gmap_OnMarkerLeave(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { CurentRectMarker = null; GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Blue; gmap.Invalidate(false); } } }
void gmap_OnMarkerEnter(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; gmap.Invalidate(false); CurentRectMarker = rc; } } }
void MainMap_OnMarkerEnter(GMapMarker item) { metroTextBox10.Text = Convert.ToString(item.Position.Lat); metroTextBox11.Text = Convert.ToString(item.Position.Lng); /*string constring = "datasource=" + metroTextBox1.Text + ";database=" + metroTextBox2.Text + ";username="******";password="******";port=" + Convert.ToInt32(metroTextBox5.Text); * MySqlConnection conDataBase = new MySqlConnection(constring); * //MySqlCommand cmdDataBase = new MySqlCommand("select id,name,age from database.edata ;", conDataBase); * MySqlCommand cmdDataBase = new MySqlCommand("select * from mapdatabase.maptable where Latitude='" + metroTextBox10.Text + "' AND Longitude='"+metroTextBox11.Text , conDataBase); * MySqlDataReader myReader; * try * { * conDataBase.Open(); * myReader = cmdDataBase.ExecuteReader(); * metroLabel7.Text = dataGridView1.RowCount.ToString(); * int count = 0; * while (myReader.Read()) * count = count + 1; * * if (count == 1) * { * GMarkerGoogle m = new GMarkerGoogle(currentMarker.Position, GMarkerGoogleType.yellow); * GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); * { * mBorders.InnerMarker = m; * mBorders.ToolTipMode = MarkerTooltipMode.OnMouseOver; * } * mBorders.ToolTipText = myReader[1].ToString(); * } * else if (count > 1) * MessageBox.Show("Access denied, duplicate username"); * else * MessageBox.Show("Data isn't Found"); * } * catch * { * * }*/ if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; CurentRectMarker = rc; } //Debug.WriteLine("OnMarkerEnter: " + item.Position); }
private void MapControl_OnRouteEnter(GMapRoute item) { if (marker != null) { item.Overlay.Markers.Remove(marker); } var point = item.Overlay.Control.PointToClient(Control.MousePosition); var pos = item.Overlay.Control.FromLocalToLatLng(point.X, point.Y); marker = new GMapMarkerRect(pos) { ToolTipMode = MarkerTooltipMode.Always, ToolTipText = createMessage(item.Tag), IsHitTestVisible = false }; item.Overlay.Markers.Add(marker); }
// click on some marker void MainMap_OnMarkerClick(GMapMarker item, Alt.GUI.MouseEventArgs e) { if (e.Button == Alt.GUI.MouseButtons.Left) { if (item is GMapMarkerRect) { GeoCoderStatusCode status; var pos = GMapProviders.GoogleMap.GetPlacemark(item.Position, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pos != null) { GMapMarkerRect v = item as GMapMarkerRect; { v.ToolTipText = pos.Value.Address; } MainMap.Invalidate();//TEMP false); } } } }
/// <summary> /// adds marker using geocoder /// </summary> /// <param name="place"></param> void AddLocationLithuania(string place) { GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Lithuania, " + place, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMarkerGoogle m = new GMarkerGoogle(pos.Value, GMarkerGoogleType.green); m.ToolTip = new GMapRoundedToolTip(m); GMapMarkerRect mBorders = new GMapMarkerRect(pos.Value); { mBorders.InnerMarker = m; mBorders.ToolTipText = place; mBorders.ToolTipMode = MarkerTooltipMode.Always; } objects.Markers.Add(m); objects.Markers.Add(mBorders); } }
// add marker on current position void button4_Click(object sender, EventArgs e) { GMarkerGoogle m = new GMarkerGoogle(currentMarker.Position, GMarkerGoogleType.green_pushpin); GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); { mBorders.InnerMarker = m; if (polygon != null) { mBorders.Tag = polygon.Points.Count; } mBorders.ToolTipMode = MarkerTooltipMode.Always; } Placemark?p = null; if (checkBoxPlacemarkInfo.IsChecked) { GeoCoderStatusCode status; var ret = GMapProviders.GoogleMap.GetPlacemark(currentMarker.Position, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && ret != null) { p = ret; } } if (p != null) { mBorders.ToolTipText = p.Value.Address; } else { mBorders.ToolTipText = currentMarker.Position.ToString(); } objects.Markers.Add(m); objects.Markers.Add(mBorders); RegeneratePolygon(); }
/// <summary> /// used to add a marker to the map display /// </summary> /// <param name="tag"></param> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="alt"></param> /// <param name="color"></param> private void addpolygonmarker(string tag, double lng, double lat, double alt, Color?color, double wpradius) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerWP m = new GMapMarkerWP(point, tag); m.ToolTipMode = MarkerTooltipMode.OnMouseOver; m.ToolTipText = "Alt: " + alt.ToString("0"); m.Tag = tag; int wpno = -1; if (int.TryParse(tag, out wpno)) { // preselect groupmarker //if (groupmarkers.Contains(wpno)) //m.selected = true; } //MissionPlanner.GMapMarkerRectWPRad mBorders = new MissionPlanner.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.Tag = tag; mBorders.wprad = (int)wpradius; if (color.HasValue) { mBorders.Color = color.Value; } } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
private void addpolygonmarker(string tag, double lng, double lat, int alt, Color?color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.green); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; try { mBorders.wprad = (int)(Settings.Instance.GetFloat("TXT_WPRad") / CurrentState.multiplierdist); } catch { } if (color.HasValue) { mBorders.Color = color.Value; } } Invoke((Action) delegate { overlay.Markers.Add(m); overlay.Markers.Add(mBorders); }); } catch (Exception) { } }
private void addpolygonmarkergrid(string tag, double lng, double lat, int alt) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Never; m.ToolTipText = "grid" + tag; m.Tag = "grid" + tag; //MissionPlanner.GMapMarkerRectWPRad mBorders = new MissionPlanner.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; } drawnpolygonsoverlay.Markers.Add(m); drawnpolygonsoverlay.Markers.Add(mBorders); } catch (Exception ex) { // log.Info(ex.ToString()); } }
// key-up events private void MainForm_KeyUp(object sender, KeyEventArgs e) { int offset = -22; if (e.KeyCode == Keys.Left) { MainMap.Offset(-offset, 0); } else if (e.KeyCode == Keys.Right) { MainMap.Offset(offset, 0); } else if (e.KeyCode == Keys.Up) { MainMap.Offset(0, -offset); } else if (e.KeyCode == Keys.Down) { MainMap.Offset(0, offset); } else if (e.KeyCode == Keys.Delete) { if (currentPolygon != null) { polygons.Polygons.Remove(currentPolygon); currentPolygon = null; } if (currentRoute != null) { routes.Routes.Remove(currentRoute); currentRoute = null; } if (CurentRectMarker != null) { objects.Markers.Remove(CurentRectMarker); if (CurentRectMarker.InnerMarker != null) { objects.Markers.Remove(CurentRectMarker.InnerMarker); } CurentRectMarker = null; //RegeneratePolygon(); } } else if (e.KeyCode == Keys.Escape) { MainMap.Bearing = 0; } }
void MainMap_OnMarkerLeave(GMapMarker item) { if (item is GMapMarkerRect) { CurentRectMarker = null; GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Blue; // Debug.WriteLine("OnMarkerLeave: " + item.Position); } }
void MainMap_MouseUp(object sender, MouseEventArgs e) { //在规划模式下生效 if (isPlanMode) { if (isMouseClickOffMenu) { isMouseClickOffMenu = false; return; } MouseDownEnd = gMapControl1.FromLocalToLatLng(e.X, e.Y); if (e.Button == MouseButtons.Right) { return; } if (isMouseDown) { if (e.Button == MouseButtons.Left) isMouseDown = false; if (ModifierKeys == Keys.Control) { // group select wps GMapPolygon poly = new GMapPolygon(new List<PointLatLng>(), "temp"); poly.Points.Add(MouseDownStart); poly.Points.Add(new PointLatLng(MouseDownStart.Lat, MouseDownEnd.Lng)); poly.Points.Add(MouseDownEnd); poly.Points.Add(new PointLatLng(MouseDownEnd.Lat, MouseDownStart.Lng)); foreach (var marker in objectsoverlay.Markers) { if (poly.IsInside(marker.Position)) { try { if (marker.Tag != null) { groupmarkeradd(marker); } } catch { } } } isMouseDraging = false; return; } } if (!isMouseDraging) { if (CurentRectMarker != null) { } else { AddWPToMap(currentMarker.Position.Lat, currentMarker.Position.Lng, 0); } } else { if (groupmarkers.Count > 0) { Dictionary<string, PointLatLng> dest = new Dictionary<string, PointLatLng>(); foreach (var markerid in groupmarkers) { for (int a = 0; a < objectsoverlay.Markers.Count; a++) { var marker = objectsoverlay.Markers[a]; if (marker.Tag != null && marker.Tag.ToString() == markerid.ToString()) { dest[marker.Tag.ToString()] = marker.Position; break; } } } foreach (KeyValuePair<string, PointLatLng> item in dest) { var value = item.Value; callMeDrag(item.Key, value.Lat, value.Lng, -1); } gMapControl1.SelectedArea = RectLatLng.Empty; groupmarkers.Clear(); // redraw to remove selection writeKML(); CurentRectMarker = null; } if (CurentRectMarker != null) { if (CurentRectMarker.InnerMarker.Tag.ToString().Contains("grid")) { try { drawnpolygon.Points[int.Parse(CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", "")) - 1] = new PointLatLng(MouseDownEnd.Lat, MouseDownEnd.Lng); gMapControl1.UpdatePolygonLocalPosition(drawnpolygon); gMapControl1.Invalidate(); } catch { } } else { callMeDrag(CurentRectMarker.InnerMarker.Tag.ToString(), currentMarker.Position.Lat, currentMarker.Position.Lng, -1); } CurentRectMarker = null; } } } isMouseDraging = false; }
void MainMap_OnMarkerLeave(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { CurentRectMarker = null; GMapMarkerRect rc = item as GMapMarkerRect; rc.ResetColor(); gMapControl1.Invalidate(false); } if (item is GMapMarkerRallyPt) { CurrentRallyPt = null; } if (item is GMapMarker) { // when you click the context menu this triggers and causes problems CurrentGMapMarker = null; } } }
/// <summary> /// used to add a marker to the map display /// </summary> /// <param name="tag"></param> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="alt"></param> private void addpolygonmarker(string tag, double lng, double lat, int alt, Color? color) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerWP m = new GMapMarkerWP(point, tag); m.ToolTipMode = MarkerTooltipMode.OnMouseOver; m.ToolTipText = "高度: " + alt.ToString("0"); m.Tag = tag; try { // preselect groupmarker if (groupmarkers.Count > 0) if (groupmarkers.Contains(int.Parse(tag))) m.selected = true; } catch { } //MissionPlanner.GMapMarkerRectWPRad mBorders = new MissionPlanner.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.Tag = tag; //隐藏到达航点半径 //mBorders.wprad = (int)(float.Parse(TXT_WPRad.Text) / CurrentState.multiplierdist); if (color.HasValue) { mBorders.Color = color.Value; } } objectsoverlay.Markers.Add(m); objectsoverlay.Markers.Add(mBorders); } catch (Exception) { } }
public void CreateOverlay(PointLatLngAlt home, List <Locationwp> missionitems, double wpradius, double loiterradius, double altunitmultiplier) { overlay.Clear(); GMapPolygon fencepoly = null; double maxlat = -180; double maxlong = -180; double minlat = 180; double minlong = 180; Func <MAVLink.MAV_FRAME, double, double, double> gethomealt = (altmode, lat, lng) => GetHomeAlt(altmode, home.Alt, lat, lng); if (home != PointLatLngAlt.Zero) { home.Tag = "H"; pointlist.Add(home); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker("H", home.Lng, home.Lat, home.Alt * altunitmultiplier, null, 0); } int a = 0; foreach (var itemtuple in missionitems.PrevNowNext()) { var itemprev = itemtuple.Item1; var item = itemtuple.Item2; var itemnext = itemtuple.Item3; ushort command = item.id; // invalid locationwp if (command == 0) { continue; } if (command < (ushort)MAVLink.MAV_CMD.LAST && command != (ushort)MAVLink.MAV_CMD.TAKEOFF && // doesnt have a position command != (ushort)MAVLink.MAV_CMD.VTOL_TAKEOFF && // doesnt have a position command != (ushort)MAVLink.MAV_CMD.RETURN_TO_LAUNCH && command != (ushort)MAVLink.MAV_CMD.CONTINUE_AND_CHANGE_ALT && command != (ushort)MAVLink.MAV_CMD.DELAY && command != (ushort)MAVLink.MAV_CMD.GUIDED_ENABLE || command == (ushort)MAVLink.MAV_CMD.DO_SET_ROI) { // land can be 0,0 or a lat,lng if (command == (ushort)MAVLink.MAV_CMD.LAND && item.lat == 0 && item.lng == 0) { continue; } if (command == (ushort)MAVLink.MAV_CMD.DO_SET_ROI) { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt((MAVLink.MAV_FRAME)item.frame, item.lat, item.lng), "ROI" + (a + 1)) { color = Color.Red }); // do set roi is not a nav command. so we dont route through it //fullpointlist.Add(pointlist[pointlist.Count - 1]); GMarkerGoogle m = new GMarkerGoogle(new PointLatLng(item.lat, item.lng), GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = (a + 1).ToString(); m.Tag = (a + 1).ToString(); GMapMarkerRect mBorders = new GMapMarkerRect(m.Position); { mBorders.InnerMarker = m; mBorders.Tag = "Dont draw line"; } // check for clear roi, and hide it if (m.Position.Lat != 0 && m.Position.Lng != 0) { // order matters overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } } else if (command == (ushort)MAVLink.MAV_CMD.LOITER_TIME || command == (ushort)MAVLink.MAV_CMD.LOITER_TURNS || command == (ushort)MAVLink.MAV_CMD.LOITER_UNLIM) { if (item.lat == 0 && item.lng == 0) { // loiter at current location. if (fullpointlist.Count >= 1) { var lastpnt = fullpointlist[fullpointlist.Count - 1]; //addpolygonmarker((a + 1).ToString(), lastpnt.Lng, lastpnt.Lat,item.alt, Color.LightBlue, loiterradius); } } else { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt((MAVLink.MAV_FRAME)item.frame, item.lat, item.lng), (a + 1).ToString()) { color = Color.LightBlue }); // exit at tangent if (item.p4 == 1) { var from = pointlist.Last(); var to = itemnext.lat != 0 && itemnext.lng != 0 ? new PointLatLngAlt(itemnext) { Alt = itemnext.alt + gethomealt((MAVLink.MAV_FRAME)item.frame, item.lat, item.lng) } : from; var bearing = from.GetBearing(to); var dist = from.GetDistance(to); if (dist > loiterradius) { fullpointlist.Add(pointlist[pointlist.Count - 1]); var offset = from.newpos(bearing + 90, loiterradius); fullpointlist.Add(offset); } else { fullpointlist.Add(pointlist[pointlist.Count - 1]); } } else { fullpointlist.Add(pointlist[pointlist.Count - 1]); } addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt * altunitmultiplier, Color.LightBlue, loiterradius); } } else if (command == (ushort)MAVLink.MAV_CMD.SPLINE_WAYPOINT) { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt((MAVLink.MAV_FRAME)item.frame, item.lat, item.lng), (a + 1).ToString()) { Tag2 = "spline" }); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt * altunitmultiplier, Color.Green, wpradius); } else if (command == (ushort)MAVLink.MAV_CMD.WAYPOINT && item.lat == 0 && item.lng == 0) { fullpointlist.Add(pointlist[pointlist.Count - 1]); } else { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt((MAVLink.MAV_FRAME)item.frame, item.lat, item.lng), (a + 1).ToString())); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt * altunitmultiplier, null, wpradius); } maxlong = Math.Max(item.lng, maxlong); maxlat = Math.Max(item.lat, maxlat); minlong = Math.Min(item.lng, minlong); minlat = Math.Min(item.lat, minlat); } else if (command == (ushort)MAVLink.MAV_CMD.DO_JUMP) // fix do jumps into the future { pointlist.Add(null); int wpno = (int)Math.Max(item.p1, 0); int repeat = (int)item.p2; List <PointLatLngAlt> list = new List <PointLatLngAlt>(); // cycle through reps for (int repno = repeat; repno > 0; repno--) { // cycle through wps for (int no = wpno; no <= a; no++) { if (pointlist[no] != null) { list.Add(pointlist[no]); } } } fullpointlist.AddRange(list); } else if (command == (ushort)MAVLink.MAV_CMD.FENCE_POLYGON_VERTEX_INCLUSION) // fence { if (fencepoly == null) { fencepoly = new GMapPolygon(new List <PointLatLng>(), a.ToString()); } pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); fencepoly.Points.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Blue, 0, MAVLink.MAV_MISSION_TYPE.FENCE); if (fencepoly.Points.Count == item.p1) { fencepoly.Fill = Brushes.Transparent; fencepoly.Stroke = Pens.Pink; overlay.Polygons.Add(fencepoly); fencepoly = null; } } else if (command == (ushort)MAVLink.MAV_CMD.FENCE_POLYGON_VERTEX_EXCLUSION) // fence { if (fencepoly == null) { fencepoly = new GMapPolygon(new List <PointLatLng>(), a.ToString()); } pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); fencepoly.Points.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Red, 0, MAVLink.MAV_MISSION_TYPE.FENCE); if (fencepoly.Points.Count == item.p1) { fencepoly.Fill = new SolidBrush(Color.FromArgb(30, 255, 0, 0)); fencepoly.Stroke = Pens.Red; overlay.Polygons.Add(fencepoly); fencepoly = null; } } else if (command == (ushort)MAVLink.MAV_CMD.FENCE_CIRCLE_EXCLUSION) // fence { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Red, item.p1, MAVLink.MAV_MISSION_TYPE.FENCE, Color.FromArgb(30, 255, 0, 0)); } else if (command == (ushort)MAVLink.MAV_CMD.FENCE_CIRCLE_INCLUSION) // fence { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Blue, item.p1, MAVLink.MAV_MISSION_TYPE.FENCE); } else if (command == (ushort)MAVLink.MAV_CMD.FENCE_RETURN_POINT) // fence { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Orange, 0, MAVLink.MAV_MISSION_TYPE.FENCE); } else if (command >= (ushort)MAVLink.MAV_CMD.RALLY_POINT) // rally { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, 0, (a + 1).ToString())); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, null, Color.Orange, 0, MAVLink.MAV_MISSION_TYPE.RALLY); } else { pointlist.Add(null); } a++; } RegenerateWPRoute(fullpointlist, home); }
private void deleteWPToolStripMenuItem_Click(object sender, EventArgs e) { int no = 0; if (CurentRectMarker != null) { if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString(), out no)) { Commands.Rows.RemoveAt(no - 1); // home is 0 } else if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", ""), out no)) { drawnpolygon.Points.RemoveAt(no - 1); drawnpolygons.Markers.Clear(); int a = 1; foreach (PointLatLng pnt in drawnpolygon.Points) { addpolygonmarkergrid(a.ToString(), pnt.Lng, pnt.Lat, 0); a++; } MainMap.UpdatePolygonLocalPosition(drawnpolygon); MainMap.Invalidate(); } } CurentRectMarker = null; writeKML(); }
void MainMap_MouseUp(object sender, MouseEventArgs e) { end = MainMap.FromLocalToLatLng(e.X, e.Y); if (e.Button == MouseButtons.Right) // ignore right clicks { return; } if (isMouseDown) // mouse down on some other object and dragged to here. { if (e.Button == MouseButtons.Left) { isMouseDown = false; } if (!isMouseDraging) { if (CurentRectMarker != null) { // cant add WP in existing rect } else { callMe(currentMarker.Position.Lat, currentMarker.Position.Lng, 0); } } else { if (CurentRectMarker != null) { if (CurentRectMarker.InnerMarker.Tag.ToString().Contains("grid")) { drawnpolygon.Points[int.Parse(CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", "")) - 1] = new PointLatLng(end.Lat, end.Lng); MainMap.UpdatePolygonLocalPosition(drawnpolygon); } else { callMeDrag(CurentRectMarker.InnerMarker.Tag.ToString(), currentMarker.Position.Lat, currentMarker.Position.Lng, -1); } CurentRectMarker = null; } } } isMouseDraging = false; }
void MainMap_OnMarkerEnter(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; MainMap.Invalidate(false); CurentRectMarker = rc; } } }
/// <summary> /// used to add a marker to the map display /// </summary> /// <param name="tag"></param> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="alt"></param> private void addpolygonmarker(string tag, double lng, double lat, int alt) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(point); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; //ArdupilotMega.GMapMarkerRectWPRad mBorders = new ArdupilotMega.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.wprad = (int)float.Parse(TXT_WPRad.Text); mBorders.MainMap = MainMap; } objects.Markers.Add(m); objects.Markers.Add(mBorders); } catch (Exception) { } }
private void tsMenuDeleteWP_Click(object sender, EventArgs e) { int no = 0; if (CurentRectMarker != null) { if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString(), out no)) { try { missionDataGrid.Rows.RemoveAt(no - 1); // home is 0 updateMap(); updateIndex(); } catch { MessageBox.Show(MWGUIControlsResources.mainGUI_tsMenuDeleteWP_Click_航点错误__请重新选择_提示); } } } if (currentMarker != null) CurentRectMarker = null; }
// add marker on current position private void button4_Click(object sender, EventArgs e) { GMapMarker m = new GMapMarkerGoogleGreen(currentMarker.Position); GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); mBorders.Size = new System.Drawing.Size(100, 100); Placemark p = null; if(checkBoxPlacemarkInfo.Checked) { p = GMaps.Instance.GetPlacemarkFromGeocoder(currentMarker.Position); } if(p != null) { mBorders.ToolTipText = p.Address; } else { mBorders.ToolTipText = currentMarker.Position.ToString(); } objects.Markers.Add(m); objects.Markers.Add(mBorders); }
GMapMarker createMarker(PointLatLng pos) { GMapMarkerVector marker = new GMapMarkerVector(pos); if (objects.Markers.Count % 2.0 == 0) marker = new GMapMarkerRect(pos); marker.Pen =new Pen(Color.FromArgb(144, Color.MidnightBlue),2); marker.IsHitTestVisible = true; marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; routes.Markers.Add(marker); if (routes.Markers.Count > 1) marker.ToolTipText = routes.Routes[0].Distance + "";// rMap1.Manager.GetDistance(pos, objects.Markers[objects.Markers.Count - 1].Position) + ""; return marker; }
public void AddLocation(string szAddress) { textBoxGeo.Text = szAddress; GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng? pos = GMaps.Instance.GetLatLngFromGeocoder("Ruckersville, " + szAddress, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMapMarker m = new GMapMarkerGoogleGreen(pos.Value); GMapMarkerRect mBorders = new GMapMarkerRect(pos.Value); mBorders.Size = new System.Drawing.Size(100, 100); { mBorders.ToolTipText = szAddress; mBorders.TooltipMode = MarkerTooltipMode.Always; } objects.Markers.Add(m); objects.Markers.Add(mBorders); } }
private void addpolygonmarker(string tag, double lng, double lat, int alt, Color? color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.green); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; try { mBorders.wprad = (int) (float.Parse(MainV2.config["TXT_WPRad"].ToString())/CurrentState.multiplierdist); } catch { } if (color.HasValue) { mBorders.Color = color.Value; } } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
void MainMap_OnMarkerEnter(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; gMapControl1.Invalidate(false); int answer; if (item.Tag != null && rc.InnerMarker != null && int.TryParse(rc.InnerMarker.Tag.ToString(), out answer)) { try { Commands.CurrentCell = Commands[0, answer - 1]; item.ToolTipText = "高度: " + Commands[Alt.Index, answer - 1].Value; item.ToolTipMode = MarkerTooltipMode.OnMouseOver; } catch { } } CurentRectMarker = rc; } if (item is GMapMarkerRallyPt) { CurrentRallyPt = item as GMapMarkerRallyPt; } if (item is GMapMarkerAirport) { // do nothing - readonly return; } if (item is GMapMarker) { CurrentGMapMarker = item; } } }
private void DeleteWP_Click(object sender, EventArgs e) { int no = 0; if (CurentRectMarker != null) { if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString(), out no)) { try { Commands.Rows.RemoveAt(no - 1); // home is 0 } catch { CustomMessageBox.Show("error selecting wp, please try again."); } } else if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", ""), out no)) { try { drawnpolygon.Points.RemoveAt(no - 1); drawnpolygonsoverlay.Markers.Clear(); int a = 1; foreach (PointLatLng pnt in drawnpolygon.Points) { addpolygonmarkergrid(a.ToString(), pnt.Lng, pnt.Lat, 0); a++; } gMapControl1.UpdatePolygonLocalPosition(drawnpolygon); gMapControl1.Invalidate(); } catch { CustomMessageBox.Show("Remove point Failed. Please try again."); } } } else if (CurrentRallyPt != null) { rallypointoverlay.Markers.Remove(CurrentRallyPt); gMapControl1.Invalidate(true); CurrentRallyPt = null; } if (currentMarker != null) CurentRectMarker = null; writeKML(); }
/// <summary> /// used to write a KML, update the Map view polygon, and update the row headers /// </summary> public void writeKML() { // quickadd is for when loading wps from eeprom or file, to prevent slow, loading times if (quickadd) return; // this is to share the current mission with the data tab pointlist = new List<PointLatLngAlt>(); fullpointlist.Clear(); Debug.WriteLine(DateTime.Now); try { if (objectsoverlay != null) // hasnt been created yet { objectsoverlay.Markers.Clear(); } // process and add home to the list string home; if (TXT_homealt.Text != "" && TXT_homelat.Text != "" && TXT_homelng.Text != "") { home = string.Format("{0},{1},{2}\r\n", TXT_homelng.Text, TXT_homelat.Text, TXT_DefaultAlt.Text); if (objectsoverlay != null) // during startup { pointlist.Add(new PointLatLngAlt(double.Parse(TXT_homelat.Text), double.Parse(TXT_homelng.Text), (int)double.Parse(TXT_homealt.Text), "H")); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker("H", double.Parse(TXT_homelng.Text), double.Parse(TXT_homelat.Text), 0, null); } } else { home = ""; pointlist.Add(null); fullpointlist.Add(pointlist[pointlist.Count - 1]); } // setup for centerpoint calc etc. double avglat = 0; double avglong = 0; double maxlat = -180; double maxlong = -180; double minlat = 180; double minlong = 180; double homealt = 0; try { if (!String.IsNullOrEmpty(TXT_homealt.Text)) homealt = (int)double.Parse(TXT_homealt.Text); } catch { } //if ((altmode)CMB_altmode.SelectedValue == altmode.Absolute) //{ // homealt = 0; // for absolute we dont need to add homealt //} int usable = 0; updateRowNumbers(); long temp = Stopwatch.GetTimestamp(); string lookat = ""; for (int a = 0; a < Commands.Rows.Count - 0; a++) { try { if (Commands.Rows[a].Cells[Command.Index].Value.ToString().Contains("UNKNOWN")) continue; int command = (byte)(int)Enum.Parse(typeof(MAVLink.MAV_CMD), Commands.Rows[a].Cells[Command.Index].Value.ToString(), false); if (command < (byte)MAVLink.MAV_CMD.LAST && command != (byte)MAVLink.MAV_CMD.TAKEOFF && command != (byte)MAVLink.MAV_CMD.RETURN_TO_LAUNCH && command != (byte)MAVLink.MAV_CMD.CONTINUE_AND_CHANGE_ALT && command != (byte)MAVLink.MAV_CMD.GUIDED_ENABLE || command == (byte)MAVLink.MAV_CMD.DO_SET_ROI) { string cell2 = Commands.Rows[a].Cells[Alt.Index].Value.ToString(); // alt string cell3 = Commands.Rows[a].Cells[Lat.Index].Value.ToString(); // lat string cell4 = Commands.Rows[a].Cells[Lon.Index].Value.ToString(); // lng // land can be 0,0 or a lat,lng if (command == (byte)MAVLink.MAV_CMD.LAND && cell3 == "0" && cell4 == "0") continue; if (cell4 == "?" || cell3 == "?") continue; if (command == (byte)MAVLink.MAV_CMD.DO_SET_ROI) { pointlist.Add(new PointLatLngAlt(double.Parse(cell3), double.Parse(cell4), (int)double.Parse(cell2) + homealt, "ROI" + (a + 1)) { color = Color.Red }); // do set roi is not a nav command. so we dont route through it //fullpointlist.Add(pointlist[pointlist.Count - 1]); GMarkerGoogle m = new GMarkerGoogle(new PointLatLng(double.Parse(cell3), double.Parse(cell4)), GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = (a + 1).ToString(); m.Tag = (a + 1).ToString(); GMapMarkerRect mBorders = new GMapMarkerRect(m.Position); { mBorders.InnerMarker = m; mBorders.Tag = "Dont draw line"; } // check for clear roi, and hide it if (m.Position.Lat != 0 && m.Position.Lng != 0) { // order matters objectsoverlay.Markers.Add(m); objectsoverlay.Markers.Add(mBorders); } } else if (command == (byte)MAVLink.MAV_CMD.LOITER_TIME || command == (byte)MAVLink.MAV_CMD.LOITER_TURNS || command == (byte)MAVLink.MAV_CMD.LOITER_UNLIM) { pointlist.Add(new PointLatLngAlt(double.Parse(cell3), double.Parse(cell4), (int)double.Parse(cell2) + homealt, (a + 1).ToString()) { color = Color.LightBlue }); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), double.Parse(cell4), double.Parse(cell3), (int)double.Parse(cell2), Color.LightBlue); } else if (command == (byte)MAVLink.MAV_CMD.SPLINE_WAYPOINT) { pointlist.Add(new PointLatLngAlt(double.Parse(cell3), double.Parse(cell4), (int)double.Parse(cell2) + homealt, (a + 1).ToString()) { Tag2 = "spline" }); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), double.Parse(cell4), double.Parse(cell3), (int)double.Parse(cell2), Color.Green); } else { pointlist.Add(new PointLatLngAlt(double.Parse(cell3), double.Parse(cell4), (int)double.Parse(cell2) + homealt, (a + 1).ToString())); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), double.Parse(cell4), double.Parse(cell3), (int)double.Parse(cell2), null); } avglong += double.Parse(Commands.Rows[a].Cells[Lon.Index].Value.ToString()); avglat += double.Parse(Commands.Rows[a].Cells[Lat.Index].Value.ToString()); usable++; maxlong = Math.Max(double.Parse(Commands.Rows[a].Cells[Lon.Index].Value.ToString()), maxlong); maxlat = Math.Max(double.Parse(Commands.Rows[a].Cells[Lat.Index].Value.ToString()), maxlat); minlong = Math.Min(double.Parse(Commands.Rows[a].Cells[Lon.Index].Value.ToString()), minlong); minlat = Math.Min(double.Parse(Commands.Rows[a].Cells[Lat.Index].Value.ToString()), minlat); Debug.WriteLine(temp - Stopwatch.GetTimestamp()); } else if (command == (byte)MAVLink.MAV_CMD.DO_JUMP) // fix do jumps into the future { pointlist.Add(null); int wpno = int.Parse(Commands.Rows[a].Cells[Param1.Index].Value.ToString()); int repeat = int.Parse(Commands.Rows[a].Cells[Param2.Index].Value.ToString()); List<PointLatLngAlt> list = new List<PointLatLngAlt>(); // cycle through reps for (int repno = repeat; repno > 0; repno--) { // cycle through wps for (int no = wpno; no <= a; no++) { if (pointlist[no] != null) list.Add(pointlist[no]); } } fullpointlist.AddRange(list); } else { pointlist.Add(null); } } catch (Exception e) { log.Info("writekml - bad wp data " + e); } } if (usable > 0) { avglat = avglat / usable; avglong = avglong / usable; double latdiff = maxlat - minlat; double longdiff = maxlong - minlong; float range = 4000; Locationwp loc1 = new Locationwp(); loc1.lat = (minlat); loc1.lng = (minlong); Locationwp loc2 = new Locationwp(); loc2.lat = (maxlat); loc2.lng = (maxlong); //double distance = getDistance(loc1, loc2); // same code as ardupilot double distance = 2000; if (usable > 1) { range = (float)(distance * 2); } else { range = 4000; } if (avglong != 0 && usable < 3) { // no autozoom lookat = "<LookAt> <longitude>" + (minlong + longdiff / 2).ToString(new CultureInfo("en-US")) + "</longitude> <latitude>" + (minlat + latdiff / 2).ToString(new CultureInfo("en-US")) + "</latitude> <range>" + range + "</range> </LookAt>"; //MainMap.ZoomAndCenterMarkers("objects"); //MainMap.Zoom -= 1; //MainMap_OnMapZoomChanged(); } } else if (home.Length > 5 && usable == 0) { lookat = "<LookAt> <longitude>" + TXT_homelng.Text.ToString(new CultureInfo("en-US")) + "</longitude> <latitude>" + TXT_homelat.Text.ToString(new CultureInfo("en-US")) + "</latitude> <range>4000</range> </LookAt>"; RectLatLng? rect = gMapControl1.GetRectOfAllMarkers("objects"); if (rect.HasValue) { gMapControl1.Position = rect.Value.LocationMiddle; } //MainMap.Zoom = 17; //MainMap_OnMapZoomChanged(); } //RegeneratePolygon(); RegenerateWPRoute(fullpointlist); if (fullpointlist.Count > 0) { double homedist = 0; if (home.Length > 5) { homedist = gMapControl1.MapProvider.Projection.GetDistance(fullpointlist[fullpointlist.Count - 1], fullpointlist[0]); } double dist = 0; for (int a = 1; a < fullpointlist.Count; a++) { if (fullpointlist[a - 1] == null) continue; if (fullpointlist[a] == null) continue; dist += gMapControl1.MapProvider.Projection.GetDistance(fullpointlist[a - 1], fullpointlist[a]); } //lbl_distance.Text = rm.GetString("lbl_distance.Text") + ": " + FormatDistance(dist + homedist, false); } setgradanddistandaz(); } catch (Exception ex) { log.Info(ex.ToString()); } Debug.WriteLine(DateTime.Now); }
// add marker on current position private void button4_Click(object sender, EventArgs e) { GMarkerGoogle m = new GMarkerGoogle(currentMarker.Position, GMarkerGoogleType.green_pushpin); GMapMarkerRect mBorders = new GMapMarkerRect(currentMarker.Position); { mBorders.InnerMarker = m; if (polygon != null) { mBorders.Tag = polygon.Points.Count; } mBorders.ToolTipMode = MarkerTooltipMode.Always; } Placemark? p = null; if (checkBoxPlacemarkInfo.Checked) { GeoCoderStatusCode status; var ret = GMapProviders.GoogleMap.GetPlacemark(currentMarker.Position, out status); if (status == GeoCoderStatusCode.G_GEO_SUCCESS && ret != null) { p = ret; } } if (p != null) { mBorders.ToolTipText = p.Value.Address; } else { mBorders.ToolTipText = currentMarker.Position.ToString(); } objects.Markers.Add(m); objects.Markers.Add(mBorders); RegeneratePolygon(); }
private void addpolygonmarkergrid(string tag, double lng, double lat, int alt) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Never; m.ToolTipText = "grid" + tag; m.Tag = "grid" + tag; //MissionPlanner.GMapMarkerRectWPRad mBorders = new MissionPlanner.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; } drawnpolygonsoverlay.Markers.Add(m); drawnpolygonsoverlay.Markers.Add(mBorders); } catch (Exception ex) { log.Info(ex.ToString()); } }
private void AddPOIMarker(string tag, double lng, double lat) { PointLatLng point = new PointLatLng(lat, lng); GMapMarker m = new GMapMarkerMissionStep(point, Convert.ToByte(tag), WP_ACTION.SET_POI); m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.wprad = (int)mw_gui.wp_radius / 100; mBorders.MainMap = MainMap; } GMOverlayPOI.Markers.Add(m); GMOverlayPOI.Markers.Add(mBorders); }
private void MapControl_OnRouteLeave(GMapRoute item) { item.Overlay.Markers.Remove(marker); marker = null; }
private void AddWPMarker(string tag, double lng, double lat, int alt, Color? color, int markertype) { PointLatLng point = new PointLatLng(lat, lng); GMapMarker m = new GMapMarkerMissionStep(point, Convert.ToByte(tag), (byte)markertype); m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.wprad = (int)mw_gui.wp_radius/100; mBorders.MainMap = MainMap; if (color.HasValue) { mBorders.Color = color.Value; } } GMOverlayWaypoints.Markers.Add(m); GMOverlayWaypoints.Markers.Add(mBorders); }
void MainMap_OnMarkerEnter(GMapMarker item) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Red; CurentRectMarker = rc; // Debug.WriteLine("OnMarkerEnter: " + item.Position); } }
void MainMap_OnMarkerLeave(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { CurentRectMarker = null; GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Blue; MainMap.Invalidate(false); } } }
private void addpolygonmarker(string tag, double lng, double lat, int alt, Color? color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.green); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; try { mBorders.wprad = (int) (Settings.Instance.GetFloat("TXT_WPRad")/CurrentState.multiplierdist); } catch { } if (color.HasValue) { mBorders.Color = color.Value; } } Invoke((MethodInvoker) delegate { overlay.Markers.Add(m); overlay.Markers.Add(mBorders); }); } catch (Exception) { } }
void MainMap_OnMarkerEnter(GMapMarker item) { if (!isMouseDown) { if (item is GMapMarkerRect) { GMapMarkerRect rc = item as GMapMarkerRect; rc.Pen.Color = Color.Green; MainMap.Invalidate(false); CurentRectMarker = rc; int answer; if (item.Tag != null && rc.InnerMarker != null && int.TryParse(rc.InnerMarker.Tag.ToString(), out answer)) { try { missionDataGrid.CurrentCell = missionDataGrid[0, answer - 1]; item.ToolTipText = "Altitude: " + missionDataGrid[ALTCOL.Index, answer - 1].Value.ToString()+"m"; item.ToolTipMode = MarkerTooltipMode.OnMouseOver; } catch { } } } } }
public void CreateOverlay(MAVLink.MAV_FRAME altmode, PointLatLngAlt home, List <Locationwp> missionitems, double wpradius, double loiterradius) { overlay.Clear(); double maxlat = -180; double maxlong = -180; double minlat = 180; double minlong = 180; Func <double, double, double> gethomealt = (lat, lng) => GetHomeAlt(altmode, home.Alt, lat, lng); home.Tag = "H"; home.Tag2 = altmode.ToString(); pointlist.Add(home); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker("H", home.Lng, home.Lat, home.Alt, null, 0); int a = 0; foreach (var itemtuple in missionitems.PrevNowNext()) { var itemprev = itemtuple.Item1; var item = itemtuple.Item2; var itemnext = itemtuple.Item3; ushort command = item.id; // invalid locationwp if (command == 0) { continue; } if (command < (ushort)MAVLink.MAV_CMD.LAST && command != (ushort)MAVLink.MAV_CMD.TAKEOFF && // doesnt have a position command != (ushort)MAVLink.MAV_CMD.VTOL_TAKEOFF && // doesnt have a position command != (ushort)MAVLink.MAV_CMD.RETURN_TO_LAUNCH && command != (ushort)MAVLink.MAV_CMD.CONTINUE_AND_CHANGE_ALT && command != (ushort)MAVLink.MAV_CMD.DELAY && command != (ushort)MAVLink.MAV_CMD.GUIDED_ENABLE || command == (ushort)MAVLink.MAV_CMD.DO_SET_ROI) { // land can be 0,0 or a lat,lng if (command == (ushort)MAVLink.MAV_CMD.LAND && item.lat == 0 && item.lng == 0) { continue; } if (command == (ushort)MAVLink.MAV_CMD.DO_SET_ROI) { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt(item.lat, item.lng), "ROI" + (a + 1)) { color = Color.Red }); // do set roi is not a nav command. so we dont route through it //fullpointlist.Add(pointlist[pointlist.Count - 1]); GMarkerGoogle m = new GMarkerGoogle(new PointLatLng(item.lat, item.lng), GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = (a + 1).ToString(); m.Tag = (a + 1).ToString(); GMapMarkerRect mBorders = new GMapMarkerRect(m.Position); { mBorders.InnerMarker = m; mBorders.Tag = "Dont draw line"; } // check for clear roi, and hide it if (m.Position.Lat != 0 && m.Position.Lng != 0) { // order matters overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } } else if (command == (ushort)MAVLink.MAV_CMD.LOITER_TIME || command == (ushort)MAVLink.MAV_CMD.LOITER_TURNS || command == (ushort)MAVLink.MAV_CMD.LOITER_UNLIM) { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt(item.lat, item.lng), (a + 1).ToString()) { color = Color.LightBlue }); // exit at tangent if (item.p4 == 1) { var from = pointlist.Last(); var to = itemnext.lat != 0 && itemnext.lng != 0 ? new PointLatLngAlt(itemnext) { Alt = itemnext.alt + gethomealt(item.lat, item.lng) } : from; var bearing = from.GetBearing(to); var dist = from.GetDistance(to); if (dist > loiterradius) { fullpointlist.Add(pointlist[pointlist.Count - 1]); var offset = from.newpos(bearing + 90, loiterradius); fullpointlist.Add(offset); } else { fullpointlist.Add(pointlist[pointlist.Count - 1]); } } else { fullpointlist.Add(pointlist[pointlist.Count - 1]); } addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt, Color.LightBlue, loiterradius); } else if (command == (ushort)MAVLink.MAV_CMD.SPLINE_WAYPOINT) { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt(item.lat, item.lng), (a + 1).ToString()) { Tag2 = "spline" }); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt, Color.Green, wpradius); } else { pointlist.Add(new PointLatLngAlt(item.lat, item.lng, item.alt + gethomealt(item.lat, item.lng), (a + 1).ToString())); fullpointlist.Add(pointlist[pointlist.Count - 1]); addpolygonmarker((a + 1).ToString(), item.lng, item.lat, item.alt, null, wpradius); } maxlong = Math.Max(item.lng, maxlong); maxlat = Math.Max(item.lat, maxlat); minlong = Math.Min(item.lng, minlong); minlat = Math.Min(item.lat, minlat); } else if (command == (ushort)MAVLink.MAV_CMD.DO_JUMP) // fix do jumps into the future { pointlist.Add(null); int wpno = (int)item.p1; int repeat = (int)item.p2; List <PointLatLngAlt> list = new List <PointLatLngAlt>(); // cycle through reps for (int repno = repeat; repno > 0; repno--) { // cycle through wps for (int no = wpno; no <= a; no++) { if (pointlist[no] != null) { list.Add(pointlist[no]); } } } fullpointlist.AddRange(list); } else { pointlist.Add(null); } a++; } RegenerateWPRoute(fullpointlist, home); }
private void tsMenuDeleteWP_Click(object sender, EventArgs e) { int no = 0; if (CurentRectMarker != null) { if (int.TryParse(CurentRectMarker.InnerMarker.Tag.ToString(), out no)) { try { missionDataGrid.Rows.RemoveAt(no - 1); // home is 0 updateMap(); updateIndex(); } catch { MessageBox.Show("error selecting wp, please try again."); } } } if (currentMarker != null) CurentRectMarker = null; }
private void addpolygonmarker(string tag, double lng, double lat, int alt, Color? color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(point); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; try { mBorders.wprad = (int)float.Parse(ArdupilotMega.MainV2.config["TXT_WPRad"].ToString()); } catch { } mBorders.MainMap = gMapControl1; if (color.HasValue) { mBorders.Color = color.Value; } } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
private void addpolygonmarkergrid(string tag, double lng, double lat, int alt) { try { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerGoogleRed m = new GMapMarkerGoogleRed(point); m.ToolTipMode = MarkerTooltipMode.Never; m.ToolTipText = "grid" + tag; m.Tag = "grid" + tag; //ArdupilotMega.GMapMarkerRectWPRad mBorders = new ArdupilotMega.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; } drawnpolygons.Markers.Add(m); drawnpolygons.Markers.Add(mBorders); } catch (Exception) { } }
private void addpolygonmarkerred(string tag, double lng, double lat, int alt, Color? color, GMapOverlay overlay) { try { PointLatLng point = new PointLatLng(lat, lng); GMarkerGoogle m = new GMarkerGoogle(point, GMarkerGoogleType.red); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; } overlay.Markers.Add(m); overlay.Markers.Add(mBorders); } catch (Exception) { } }
/* void MainMap_MouseDown(object sender, MouseEventArgs e) { // start = MainMap.FromLocalToLatLng(e.X, e.Y); if (e.Button == MouseButtons.Left) { // copterPosMarker.Position = start; // points.Add(new PointLatLng(copterPos.Lat, copterPos.Lng)); // Grout.Points.Add(start); // = new GMapRoute(points, "track"); // //routes.Routes.Add(Grout); // MainMap.Position = start; // MainMap.Invalidate(); } } void MainMap_MouseMove(object sender, MouseEventArgs e) { PointLatLng point = MainMap.FromLocalToLatLng(e.X, e.Y); currentMarker.Position = point; } */ private void addpolygonmarker(string tag, double lng, double lat, int alt, Color? color) { PointLatLng point = new PointLatLng(lat, lng); GMapMarkerGoogleGreen m = new GMapMarkerGoogleGreen(point); m.ToolTipMode = MarkerTooltipMode.Always; m.ToolTipText = tag; m.Tag = tag; //ArdupilotMega.GMapMarkerRectWPRad mBorders = new ArdupilotMega.GMapMarkerRectWPRad(point, (int)float.Parse(TXT_WPRad.Text), MainMap); GMapMarkerRect mBorders = new GMapMarkerRect(point); { mBorders.InnerMarker = m; mBorders.wprad = (int)float.Parse("5"); mBorders.MainMap = MainMap; if (color.HasValue) { mBorders.Color = color.Value; } } markers.Markers.Add(m); markers.Markers.Add(mBorders); }