Quantcast
Channel: GMap.NET - Great Maps for Windows Forms & Presentation
Viewing all articles
Browse latest Browse all 3384

New Post: how to rotate a marker 0-360 degrees

$
0
0
This work fine
class C_GmapDirectionMarker : GMapMarker
{
    Color Co;
    double Angle = 0;
    Image Img;
 
    public C_GmapDirectionMarker(PointLatLng p0,double Angle, Image _Img)
      : base(p0)
    {

      this.Img = _Img;
      this.Size = new Size(Img.Width, Img.Height);
      this.Offset = new Point(-Size.Width / 2, -Size.Height / 2);
      this.Angle = Angle;
    }

    public override void OnRender(Graphics g)
    {
      Point p0 = LocalPosition;
      p0.X -= Offset.X;
      p0.Y -= Offset.Y;

      Matrix mx = new Matrix();
      mx.RotateAt((float)Angle, new PointF(p0.X, p0.Y), MatrixOrder.Append);
      g.Transform = mx;

      g.DrawImageUnscaled(Img, LocalPosition.X, LocalPosition.Y);
      g.ResetTransform();
    }
}

Viewing all articles
Browse latest Browse all 3384