Trouble with some little code piece

Topics: Help
Dec 12, 2011 at 12:42 PM

 

I found here a little code piece to drawing circles but i cant get it to work because

Overlay.Control is unknown.

...

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using GMap.NET.WindowsForms;
using GMap.NET;

namespace GMap.NET.WindowsForms.Markers
{
    public class GMapMarkerCircle : GMapMarker
    {
        public int Radius;  //In Meters
        public Pen OutlinePen;
        public Brush FillBrush;
        public bool Fill;

        public GMapMarkerCircle(PointLatLng p)
            : base(p)
        {
            OutlinePen = new Pen(Brushes.Blue, 1);
            FillBrush = new SolidBrush(Color.FromArgb(20, Color.Blue));
            Radius = 0;
           
           
        }

        public override void OnRender(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            int R = (int)((Radius) / Overlay.Control.Core.Projection.GetGroundResolution(Overlay.Control.Zoom, Position.Lat)) * 2;

            if (Fill == true)
            {
                g.FillEllipse(FillBrush, new System.Drawing.Rectangle(LocalPosition.X - R / 2, LocalPosition.Y - R / 2, R, R));
            }
            g.DrawEllipse(OutlinePen, new System.Drawing.Rectangle(LocalPosition.X - R / 2, LocalPosition.Y - R / 2, R, R));
        }
    }

 

Coordinator
Dec 12, 2011 at 12:56 PM

LocalPosition.X - R, i doubt it will give you correct results ;} anyway calculations should be done somewhere else

Dec 12, 2011 at 1:56 PM
radioman wrote:

LocalPosition.X - R, i doubt it will give you correct results ;} anyway calculations should be done somewhere else

i think this could be righ ;)

Rr is not defined and I need the zoom level for the calculation.

 

 

Apr 17, 2012 at 11:59 AM

Hi,

I'm trying to add the custom marker circle but I have the same problem: Overlay.Control is unknown

I added the file GMapMarkerCircle.cs founded on Demo.WindowsForms to my app but it has some compilation errors: can't access to control because is declared as friend...

any idea?

thank you so much

Coordinator
Apr 17, 2012 at 12:09 PM

works fine for me ;}

Dec 12, 2013 at 1:39 PM
Hi,

On a WindowsForms I implement the above code

My call for the class looks like this:
private void gMapControl1_OnMapZoomChanged()
        {            
            GMapMarkerCircle circ = new GMapMarkerCircle(new PointLatLng(50.755786121111, 8.617633343333));
            gMapControl1.Invalidate();         
            
        }
but the "OnRender(Graphics g)" method doen't fire


dll version is 1.6.0.0



What am I doing wrong ?