GMAP.NET WPF - 点周围的中心形状

时间:2017-04-01 18:13:59

标签: wpf gmap.net

我使用以下代码为我的WPF GMap.NET控件添加形状:

System.Windows.Point p = e.GetPosition(gMapControl1);
var point = gMapControl1.FromLocalToLatLng((int)p.X, (int)p.Y);
GMapMarker m = new GMapMarker(point);
m.Shape = new Rectangle
{
    Width = 10,
    Height = 10,
    Fill = System.Windows.Media.Brushes.Red

};
m.Tag = "PolyDot";
gMapControl1.Markers.Add(m);      

我遇到的一个问题是形状不在点上。形状的左上角通常是指向的位置。如何围绕该点居中形状?

1 个答案:

答案 0 :(得分:2)

想出来。其实超级简单

GMapMarker m = new GMapMarker(point);
Rectangle recShape = new Rectangle
{
    Width = 100,
    Height = 100,
    Fill = System.Windows.Media.Brushes.Red

};
m.Shape = recShape;
m.Tag = "PolyDot";
m.Offset = new Point(-recShape.Width / 2, -recShape.Height/2);
gMapControl1.Markers.Add(m);