Font marker and marker direction

May 18, 2010 at 9:10 AM
Hi, I want to creating marker from font. For example "Ý" char for Wingdings font type. How can I do? I tried but I have a two problems. 1) Marker edges are cut after the marker rotated 2) The place of markers seems at different place on the map.( Best Regards
May 18, 2010 at 9:46 AM

"Marker edges are cut after the marker rotated' ?

May 18, 2010 at 10:06 AM
For example
May 18, 2010 at 11:02 AM

and what's wrong with that?

May 18, 2010 at 12:34 PM
Edited May 18, 2010 at 12:35 PM
If you look at the first picture you can see the markers completly but at the second picture you cann't see the completly. You can see just some parts of marker.
May 18, 2010 at 12:40 PM

mm. a green circle ;} so how do you rotate it?

May 18, 2010 at 12:58 PM
Edited May 18, 2010 at 1:02 PM
        public Bitmap CreateMarker(string MarkerFont, float MarkerFontSize, string MarkerChar, float Angle)
            Bitmap objBmpImage = new Bitmap(1, 1);
            GraphicsPath pth = new GraphicsPath();
            Graphics objGraphics = Graphics.FromImage(objBmpImage);
            objBmpImage = new Bitmap(objBmpImage, new System.Drawing.Size(Width, Height));
            objGraphics = Graphics.FromImage(objBmpImage);
            //Calculation to size
            Font objFont = new Font(MarkerFont, MarkerFontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            Width = (int)(objGraphics.MeasureString(MarkerChar, objFont).Height * Math.Abs(Math.Sin(Angle)) + objGraphics.MeasureString(MarkerChar, objFont).Width * Math.Abs(Math.Cos(Angle)));
            Height = (int)(objGraphics.MeasureString(MarkerChar, objFont).Height * Math.Abs(Math.Cos(Angle)) + objGraphics.MeasureString(MarkerChar, objFont).Width * Math.Abs(Math.Sin(Angle)));
            this.Size = new System.Drawing.Size(Width, Height);

            pth.AddString(MarkerChar, new FontFamily(MarkerFont), (int)FontStyle.Regular, MarkerFontSize, new System.Drawing.Point(0, 0), StringFormat.GenericDefault);
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

            objGraphics.TranslateTransform(Width / 2, Height / 2);
            objGraphics.TranslateTransform(-Width / 2, -Height / 2);
            Pen p = new Pen(Color.Transparent, 5);
            objGraphics.DrawPath(p, pth);
            objGraphics.FillPath(Brushes.DarkGreen, pth);
            return objBmpImage;

        public override void OnRender(Graphics g)
            Bitmap MarkerBitmap = CreateMarker("Wingdings", 25, "Ý", 230);
            //Bitmap MarkerBitmap = CreateMarker(Pair.Value.MarkerFont,Pair.Value.MarkerFontSize,Pair.Value.Marker,Ang);
            g.DrawImageUnscaled(MarkerBitmap, LocalPosition.X, LocalPosition.Y);
May 18, 2010 at 1:46 PM
Edited May 18, 2010 at 1:51 PM

creating new bitmap each frame is quite insane and kill for memory ;}

just transform onrender:

g.TranslateTransform(Width / 2, Height / 2);


g.DrawImageUnscaled(MarkerBitmap, LocalPosition.X, LocalPosition.Y);


May 18, 2010 at 2:03 PM

I have allready known what you told but can you explain me is there another way to do this? I want use a character as a marker. Also I tried the code what you gave me, but the markers doesnt seem at real place and when the change center of the map, the places of the markers change at the same time.

May 18, 2010 at 2:12 PM

let me experiment on this...

May 18, 2010 at 6:56 PM

check transport demo, i've added bearing with rotation

May 20, 2010 at 9:57 AM
Sorry, for late feedback. First of all, thank you. I will do feedback, after reviewing detailed.