Marker offset does not until I move the map

Topics: Windows Forms
May 28, 2012 at 4:19 AM

Here is my onRender:

        public override void OnRender(System.Drawing.Graphics g)
        {
            double circleDiam = wp.m_radius/gmc.MapProvider.Projection.GetGroundResolution((int)Math.Round(gmc.Zoom,0),wp.Position.Lat);
            
            this.Offset = new Point((int)(-1 * (circleDiam / 2.0)), (int)(-1 * (circleDiam / 2.0)));
            this.Size = new System.Drawing.Size((int)circleDiam, (int)circleDiam);
            Pen p = new Pen(Color.Red, 2);
            Rectangle r = new Rectangle(LocalPosition.X, LocalPosition.Y, (int)circleDiam, (int)circleDiam);

            g.DrawEllipse(p, r);
            SolidBrush sb = new SolidBrush(Color.White);
            GraphicsPath gp = new GraphicsPath();
            p = new Pen(Color.Black, 2);
            Font drawFont = new Font("Arial", 24);
            gp.AddString(num.ToString(), drawFont.FontFamily, (int)FontStyle.Bold, 20, LocalPosition, StringFormat.GenericDefault);
            g.DrawPath(p, gp);
            g.FillPath(Brushes.White, gp);
        }

My issue is that when I add the marker, it shows up with the corner of it at the position. however when I move the map the marker appears to accept the offset. and move to the correct location.

Any ideas on what I am doing wrong?

 

Thank you for this great control.

May 28, 2012 at 8:58 AM

that definitely will overload the memory

and you set the size/offset in render function, thats why

May 28, 2012 at 9:10 AM
Edited May 28, 2012 at 9:11 AM

Thank you for the quick response.

Where do you propose I set the size and offset?

GMap.onZoomChange event comes to mind, however it doesn't seem very elegant