识别在c#上单击的多边形



我正在地图上添加多个多边形,并试图确定点击了哪一个。C#已经可以判断是否点击了多边形,但我需要确定点击了哪个。我已经尝试了很多变体,但目前我在底部有错误:

{
gMapControl1.MapProvider = GMapProviders.GoogleMap;
gMapControl1.Position = new PointLatLng(52.2659416, 10.5267296);
GMapOverlay polygons = new GMapOverlay("polygons");
List<PointLatLng> points = new List<PointLatLng>();
points.Add(new PointLatLng(52.2659416, 10.5267296));
points.Add(new PointLatLng(62.2659416, 10.5267296));
points.Add(new PointLatLng(62.2659416, 20.5267296));
points.Add(new PointLatLng(52.2659416, 20.5267296));
GMapPolygon polygon = new GMapPolygon(points, "test");
polygons.Polygons.Add(polygon);
gMapControl1.Overlays.Add(polygons);
}
private void gmap_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
{
Console.WriteLine(String.Format("Polygon {0} with tag {1} was clicked",
item.Name, item.Tag));
}

错误CS0104'MouseEventArgs'是'System.Windows.Forms.MouseEventArgs'和'System.Windows.Input.MouseEventArgs'之间的不明确引用

您必须将多边形的IsHitTestVisible指定为true:

polygon.IsHitTestVisible = true;

在这里找到它:GMap-无法检测到点击多边形

相关内容

  • 没有找到相关文章

最新更新