1

I found this code to put labels under markers in Gmap.NET. The problem is that the marker is at a wrong place, whatever position you give to it, it is always at the same default place. Can someone help me?

this is the code:

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
Ethan
  • 11
  • 2
  • Since you don't do anything with the actual marker it should work as intended, but as it is not I'm assuming you might miss something when adding the marker to the map. Please append the relevant code. – rdoubleui May 11 '16 at 05:01
  • Related: http://stackoverflow.com/questions/30173888/gmap-net-marker-initially-in-incorrect-position – rrauenza Jun 15 '16 at 18:19

0 Answers0