Gmap.NET中标记下方的标签

时间:2016-05-10 14:23:23

标签: labels markers gmap.net

我发现此代码将标签放在Gmap.NET中的标记下。问题是标记位于错误的位置,无论你给它什么位置,它总是在同一个默认位置。有人能帮助我吗?

这是代码:

public class GmapMarkerWithLabel : GMapMarker, ISerializable
{
    private Font font;
    private GMarkerGoogle innerMarker;

    public string Caption;

    public GmapMarkerWithLabel(PointLatLng p, string caption, GMarkerGoogleType type)
        : base(p)
    {
        font = new Font("Arial", 14);
        innerMarker = new GMarkerGoogle(p, type);

        Caption = caption;
    }

    public override void OnRender(Graphics g)
    {
        if (innerMarker != null)
        {
            innerMarker.OnRender(g);    
        }

        g.DrawString(Caption, font, Brushes.Black, new PointF(0.0f, innerMarker.Size.Height));
    }

    public override void Dispose()
    {
        if(innerMarker != null)
        {
            innerMarker.Dispose();
            innerMarker = null;
        }

        base.Dispose();
    }

    #region ISerializable Members

    void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
    {
        base.GetObjectData(info, context);
    }

    protected GmapMarkerWithLabel(SerializationInfo info, StreamingContext context)
        : base(info, context)
    {
    }

    #endregion

0 个答案:

没有答案