本文整理汇总了C#中GMapPolygon类的典型用法代码示例。如果您正苦于以下问题:C# GMapPolygon类的具体用法?C# GMapPolygon怎么用?C# GMapPolygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GMapPolygon类属于命名空间,在下文中一共展示了GMapPolygon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GMapMarkerPhoto
public GMapMarkerPhoto(MAVLink.mavlink_camera_feedback_t mark, bool shotBellowMinInterval = false)
: base(new PointLatLng(mark.lat/1e7, mark.lng/1e7))
{
local = mark;
this.shotBellowMinInterval = shotBellowMinInterval;
Offset = new Point(-localcache1.Width/2, -localcache1.Height/2);
Size = localcache1.Size;
Alt = mark.alt_msl;
ToolTipMode = MarkerTooltipMode.OnMouseOver;
Roll = local.roll - rolltrim;
Pitch = local.pitch - pitchtrim;
Yaw = local.yaw - yawtrim;
ToolTipText = "Photo" + "\nAlt: " + mark.alt_msl + "\nNo: "+ mark.img_idx + "\nRoll: "+Roll.ToString("0.00");
Tag = mark.time_usec;
var footprint = ImageProjection.calc(new PointLatLngAlt(Position.Lat, Position.Lng, Alt), Roll,
Pitch, Yaw, hfov, vfov);
footprintpoly = new GMapPolygon(footprint.ConvertAll(x => x.Point()), "FP"+mark.time_usec);
footprintpoly.Fill = Brushes.Transparent;
footprintpoly.Stroke = Pens.Crimson;
}
示例2: Build
public static void Build(ref GMapOverlay OverlayOut)
{
// Here loop through defined sectors and display them on the map
foreach (SystemAdaptationDataSet.SectorBorder Sector in SystemAdaptationDataSet.SectorBorderDataSet)
{
System.Collections.Generic.List<PointLatLng> SectorPointList = new System.Collections.Generic.List<PointLatLng>();
foreach (GeoCordSystemDegMinSecUtilities.LatLongClass SectorPoint in Sector.SectorBorderPoints)
{
SectorPointList.Add(new PointLatLng(SectorPoint.GetLatLongDecimal().LatitudeDecimal, SectorPoint.GetLatLongDecimal().LongitudeDecimal));
}
// Get sector border display attributes
DisplayAttributes.DisplayAttributesType SectorBorderDisplayAttribute = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.SectorBorder);
GMapPolygon SectorPolygon = new GMapPolygon(SectorPointList, Sector.SectorName);
SectorPolygon.Stroke = new Pen(SectorBorderDisplayAttribute.LineColor, SectorBorderDisplayAttribute.LineWidth);
Type brushType = typeof(Brushes);
Brush myBrush = (Brush)brushType.InvokeMember(SectorBorderDisplayAttribute.AreaPolygonColor.Name,
BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty,
null, null, new object[] { });
SectorPolygon.Fill = myBrush;
OverlayOut.Polygons.Add(SectorPolygon);
}
}
示例3: DrawPolygon
/// <summary>
/// 绘制多边形
/// </summary>
/// <param name="name"></param>
/// <param name="points"></param>
public void DrawPolygon(string name, List<PointLatLng> points)
{
this.RemovePolygon(name);
GMapPolygon polygon = new GMapPolygon(points, name);
polygon.Stroke = new Pen(new SolidBrush(Color.FromArgb(255, 255, 0, 0)), 2);
polygon.Fill = new SolidBrush(Color.FromArgb(30, 100, 100, 100));
overlay.Polygons.Add(polygon);
}
示例4: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
// Initialize map:
gMapControl.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
gMapControl.Position = new GMap.NET.PointLatLng(0.06,34);
// gMapControl.SetPositionByKeywords("Embu, kenya");
//Placing a marker on a certain position
GMapOverlay markersOverlay = new GMapOverlay("markers");
GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(0.06, 34.2),
GMarkerGoogleType.green);
marker.ToolTipText = "This is the first marker we put up";
marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
markersOverlay.Markers.Add(marker);
gMapControl.Overlays.Add(markersOverlay);
GMapOverlay markersOverlaymaseno = new GMapOverlay("markers");
GMarkerGoogle masenomarker = new GMarkerGoogle(new PointLatLng(45, 45),
GMarkerGoogleType.blue);
masenomarker.ToolTipText = "This is the second marker we put up";
masenomarker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
markersOverlay.Markers.Add(masenomarker);
gMapControl.Overlays.Add(markersOverlay);
markersOverlay.Markers.Add(marker);
gMapControl.Overlays.Add(markersOverlay);
GMapOverlay markersOverlaythird = new GMapOverlay("markers");
GMarkerGoogle thirdmarker = new GMarkerGoogle(new PointLatLng(-45, 45),
GMarkerGoogleType.red);
thirdmarker.ToolTipText = "This is the third marker we put up";
thirdmarker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
markersOverlay.Markers.Add(thirdmarker);
gMapControl.Overlays.Add(markersOverlay);
GMapOverlay polyOverlay = new GMapOverlay("polygons");
List<PointLatLng> points = new List<PointLatLng>();
points.Add(new PointLatLng(-25.969562, 32.585789));
points.Add(new PointLatLng(-25.966205, 32.588171));
points.Add(new PointLatLng(-25.968134, 32.591647));
points.Add(new PointLatLng(-25.971684, 32.589759));
GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
polygon.Stroke = new Pen(Color.Red, 1);
polyOverlay.Polygons.Add(polygon);
gMapControl.Overlays.Add(polyOverlay);
}
示例5: Control_OnPolygonClick
private void Control_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
return;
if (item.Overlay.Control.IsDragging)
return;
if (_mapControl.Overlays.First(x => x.Polygons.Any(i => i.Name == item.Name)) != null)
{
if (item.Tag is Feature)
{
var prop = ((Feature)item.Tag).Properties;
var display = prop["display"] as Newtonsoft.Json.Linq.JObject;
var sections = display["sections"];
string title;
string text;
if (sections.Count() == 0)
{
title = prop["detailedCategory"].ToString();
text = "";
}
else
{
var section1 = sections[0];
var iconURL = section1["iconUrl"].ToString();
title = section1["title"].ToString();
text = section1["text"].ToString();
}
var st = String.Format("{0} is categorised as a {1}\n\n{2}", prop["name"], title, text);
CustomMessageBox.Show(st, "Info", MessageBoxButtons.OK);
}
}
}
示例6: MapControl_OnPolygonEnter
private void MapControl_OnPolygonEnter(GMapPolygon 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);
}
示例7: refreshRoute
void refreshRoute() {
List<PointLatLng> linePoints = new List<PointLatLng>();
foreach (GMapMarker m in routes.Markers) {
m.Tag = linePoints.Count;
linePoints.Add(m.Position);
m.ToolTipMode = MarkerTooltipMode.Never;
}
if (linePoints.Count > 0) {
GMapPolygon route = new GMapPolygon(linePoints, "qytj");
route.Stroke = new Pen(Color.Green);
route.Stroke.Width = 2;
routes.Polygons.Clear();
routes.Polygons.Add(route);
}
}
示例8: Polygon
public Polygon(FlightPlanner host, string name, GMarkerGoogleType markerType, Color color, Brush brush, string tag = "")
{
this.markerType = markerType;
this.color = color;
this.brush = brush;
//setup drawnpolygon
List<PointLatLng> list = new List<PointLatLng>();
polygon = new GMapPolygon(list, name + "poly");
polygon.Stroke = new Pen(color, 2);
polygon.Fill = brush;
overlay = new GMapOverlay(name + "polygonoverlay");
this.host = host;
host.MainMap.Overlays.Add(this.overlay);
this.tag = tag;
}
示例9: DrawS2Cells
public static void DrawS2Cells(List<ulong> cellsIds, GMapOverlay mapLayer)
{
for (int i=0; i<cellsIds.Count; i++)
{
S2CellId cellId = new S2CellId(cellsIds[i]);
S2Cell cell = new S2Cell(cellId);
List<PointLatLng> points = new List<PointLatLng>();
for (int j=0; j<4; j++)
{
S2LatLng point = new S2LatLng(cell.GetVertex(j));
points.Add(new PointLatLng(point.LatDegrees, point.LngDegrees));
}
GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
polygon.Stroke = new Pen(Color.Red, 1);
mapLayer.Polygons.Add(polygon);
}
}
示例10: calc
//http://www.chrobotics.com/library/understanding-euler-angles
// x = north / roll
// y = pitch / east
// z = yaw / down
public static List<PointLatLngAlt> calc(PointLatLngAlt plla, double R, double P, double Y, double hfov, double vfov)
{
// alt should be asl
// P pitch where the center os pointing ie -80
// R roll
GMapPolygon poly = new GMapPolygon(new List<PointLatLng>(), "rect");
double frontangle = (P*0) + vfov/2;
double backangle = (P*0) - vfov/2;
double leftangle = (R*0) + hfov/2;
double rightangle = (R*0) - hfov/2;
var fovh = Math.Tan(hfov/2.0 * deg2rad)*2.0;
var fovv = Math.Tan(vfov/2.0 * deg2rad)*2.0;
//DoDebug();
addtomap(plla, "plane");
Matrix3 dcm = new Matrix3();
dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
dcm.normalize();
Vector3 center1 = new Vector3(0, 0, 10000);
var test = dcm * center1;
var bearing2 = Math.Atan2(test.y, test.x) * rad2deg;
var newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));
newpos2.Alt -= test.z;
var cen = calcIntersection(plla, newpos2);
var dist = plla.GetDistance(cen);
addtomap(cen, "center "+ dist.ToString("0"));
//
dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
dcm.rotate(new Vector3(rightangle * deg2rad, 0, 0));
dcm.normalize();
dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
dcm.normalize();
test = dcm * center1;
bearing2 = (Math.Atan2(test.y, test.x) * rad2deg);
newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));
newpos2.Alt -= test.z;
//addtomap(newpos2, "tr2");
var groundpointtr = calcIntersection(plla, newpos2);
poly.Points.Add(groundpointtr);
addtomap(groundpointtr, "tr");
//
dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
dcm.normalize();
dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
dcm.normalize();
test = dcm * center1;
bearing2 = Math.Atan2(test.y, test.x)*rad2deg;
newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));
newpos2.Alt -= test.z;
var groundpointtl = calcIntersection(plla, newpos2);
poly.Points.Add(groundpointtl);
addtomap(groundpointtl, "tl");
//
dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
dcm.normalize();
dcm.rotate(new Vector3(0, backangle * deg2rad, 0));
dcm.normalize();
test = dcm * center1;
//.........这里部分代码省略.........
示例11: domainUpDown1_ValueChanged
private void domainUpDown1_ValueChanged(object sender, EventArgs e)
{
if (CMB_camera.Text != "")
doCalc();
// new grid system test
grid = Grid.CreateGrid(list, (double)NUM_altitude.Value, (double)NUM_Distance.Value, (double)NUM_spacing.Value, (double)NUM_angle.Value, (double)NUM_overshoot.Value, (double)NUM_overshoot2.Value, (Grid.StartPosition)Enum.Parse(typeof(Grid.StartPosition), CMB_startfrom.Text), false);
List<PointLatLng> list2 = new List<PointLatLng>();
grid.ForEach(x => { list2.Add(x); });
map.HoldInvalidation = true;
layerpolygons.Polygons.Clear();
layerpolygons.Markers.Clear();
if (grid.Count == 0)
{
return;
}
if (chk_boundary.Checked)
AddDrawPolygon();
int strips = 0;
int images = 0;
int a = 1;
PointLatLngAlt prevpoint = grid[0];
foreach (var item in grid)
{
if (item.Tag == "M")
{
images++;
if (chk_internals.Checked)
{
layerpolygons.Markers.Add(new GMarkerGoogle(item,GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver });
a++;
}
try
{
if (TXT_fovH.Text != "")
{
double fovh = double.Parse(TXT_fovH.Text);
double fovv = double.Parse(TXT_fovV.Text);
double startangle = 0;
if (!CHK_camdirection.Checked)
{
startangle = 90;
}
double angle1 = startangle - (Math.Tan((fovv / 2.0) / (fovh / 2.0)) * rad2deg);
double dist1 = Math.Sqrt(Math.Pow(fovh / 2.0, 2) + Math.Pow(fovv / 2.0, 2));
double bearing = (double)NUM_angle.Value;// (prevpoint.GetBearing(item) + 360.0) % 360;
List<PointLatLng> footprint = new List<PointLatLng>();
footprint.Add(item.newpos(bearing + angle1, dist1));
footprint.Add(item.newpos(bearing + 180 - angle1, dist1));
footprint.Add(item.newpos(bearing + 180 + angle1, dist1));
footprint.Add(item.newpos(bearing - angle1, dist1));
GMapPolygon poly = new GMapPolygon(footprint, a.ToString());
poly.Stroke = new Pen(Color.FromArgb(250 - ((a * 5) % 240), 250 - ((a * 3) % 240), 250 - ((a * 9) % 240)), 1);
poly.Fill = new SolidBrush(Color.FromArgb(40, Color.Purple));
if (chk_footprints.Checked)
layerpolygons.Polygons.Add(poly);
}
}
catch { }
}
else
{
strips++;
if (chk_markers.Checked)
layerpolygons.Markers.Add(new GMarkerGoogle(item,GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.Always });
a++;
}
prevpoint = item;
}
// add wp polygon
wppoly = new GMapPolygon(list2, "Grid");
wppoly.Stroke.Color = Color.Yellow;
wppoly.Fill = Brushes.Transparent;
wppoly.Stroke.Width = 4;
if (chk_grid.Checked)
layerpolygons.Polygons.Add(wppoly);
Console.WriteLine("Poly Dist " + wppoly.Distance);
if (DistUnits == "Feet")
{
float multiplierdist = 3.2808399f;
lbl_area.Text = (calcpolygonarea(list) * (double)multiplierdist).ToString("#") + " ft^2";
//.........这里部分代码省略.........
示例12: RegeneratePolygon
/// <summary>
/// used to redraw the polygon
/// </summary>
void RegeneratePolygon()
{
List<PointLatLng> polygonPoints = new List<PointLatLng>();
if (objectsoverlay == null)
return;
foreach (GMapMarker m in objectsoverlay.Markers)
{
if (m is GMapMarkerRect)
{
if (m.Tag == null)
{
m.Tag = polygonPoints.Count;
polygonPoints.Add(m.Position);
}
}
}
if (wppolygon == null)
{
wppolygon = new GMapPolygon(polygonPoints, "polygon test");
polygonsoverlay.Polygons.Add(wppolygon);
}
else
{
wppolygon.Points.Clear();
wppolygon.Points.AddRange(polygonPoints);
wppolygon.Stroke = new Pen(Color.Yellow, 4);
wppolygon.Stroke.DashStyle = DashStyle.Custom;
wppolygon.Fill = Brushes.Transparent;
if (polygonsoverlay.Polygons.Count == 0)
{
polygonsoverlay.Polygons.Add(wppolygon);
}
else
{
lock (thisLock)
{
gMapControl1.UpdatePolygonLocalPosition(wppolygon);
}
}
}
}
示例13: MainMap_MouseUp
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
{
//.........这里部分代码省略.........
示例14: measureToolStripMenuItem_Click
private void measureToolStripMenuItem_Click(object sender, EventArgs e)
{
if (startmeasure.IsEmpty)
{
startmeasure = MouseDownStart;
polygonsoverlay.Markers.Add(new GMarkerGoogle(MouseDownStart, GMarkerGoogleType.red));
gMapControl1.Invalidate();
Common.MessageShowAgain("量尺工具", "量尺起点已经选定,再次点击量尺工具计算距离.");
}
else
{
List<PointLatLng> polygonPoints = new List<PointLatLng>();
polygonPoints.Add(startmeasure);
polygonPoints.Add(MouseDownStart);
GMapPolygon line = new GMapPolygon(polygonPoints, "measure dist");
line.Stroke.Color = Color.Green;
polygonsoverlay.Polygons.Add(line);
polygonsoverlay.Markers.Add(new GMarkerGoogle(MouseDownStart, GMarkerGoogleType.red));
gMapControl1.Invalidate();
CustomMessageBox.Show("距离: " + FormatDistance(gMapControl1.MapProvider.Projection.GetDistance(startmeasure, MouseDownStart), true) + " 方位角: " + (gMapControl1.MapProvider.Projection.GetBearing(startmeasure, MouseDownStart).ToString("0")));
polygonsoverlay.Polygons.Remove(line);
polygonsoverlay.Markers.Clear();
startmeasure = new PointLatLng();
}
}
示例15: map_OnPolygonClick
private void map_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
{
}