Rect marker is shown but Image marker no shown

Topics: Windows Forms
Jan 17, 2012 at 4:05 PM

Env: winxp+C#

 

The rect marker class:

 

namespace Mapameu
{
    public class GMapMarkerRect : GMapMarker
    {
        public Pen Pen;

        public GMapMarkerRect(PointLatLng p) : base(p)
        {
            Pen = new Pen(Brushes.Red, 5);

            // do not forget set Size of the marker
            // if so, you shall have no event on it ;}
            Size = new Size(25, 25);
        }

        public override void OnRender(Graphics g)
        {
            g.DrawRectangle(Pen, new System.Drawing.Rectangle(LocalPosition.X - Size.Width / 2, LocalPosition.Y - Size.Height / 2, Size.Width, Size.Height));
        }
    }
}

 

The image marker class:

 

namespace Mapameu
{
    public class GMapMarkerImg : GMapMarker
    {
        public System.Drawing.Image Image;

        public GMapMarkerImg(PointLatLng p) : base(p)
        {
            Image = Image.FromFile(@"C:\LIXO\Mapameu\Mapameu\bin\Debug\carro.jpg");
        }

        public override void OnRender(Graphics g)
        {
            g.DrawImage(Image, System.Convert.ToInt32(LocalPosition.X - Size.Width / 2), System.Convert.ToInt32(LocalPosition.Y - Size.Height / 2), Size.Width, Size.Height);
        }
    }
}

 

On the form:

 

private void gMapControl1_MouseDown(object sender, MouseEventArgs e)
        {
            //RCLICK 
            if (e.Button == MouseButtons.Right)
            {
               
                GMapMarkerRect cM = new GMapMarkerRect(gMapControl1.FromLocalToLatLng(e.X + 33, e.Y + 33));
                cM.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                cM.ToolTipText = "Welcome to Here2";
                top.Markers.Add(cM);


                GMapMarkerImg cMi = new GMapMarkerImg(gMapControl1.FromLocalToLatLng(e.X + 66, e.Y + 66));
                cMi.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                cMi.ToolTipText = "Welcome to Here3";
                top.Markers.Add(cMi);

            }

        }

GMapMarkerRect marker is shown but the GMapMarkerImg is never shown.
Why?
Thanks a lot
Alan

 

 

Jan 17, 2012 at 4:20 PM

Size!!