Added Functionality

Nov 16, 2009 at 9:45 PM

First let me say this project is pretty freaking awesome, made my life a lot simpler. 

For my purposes I needed to map out where some stuff was and color code it with dots or something similar. However i noticed that GMap only had the google maps like markers and stuff. So after digging into the code I figured out how to create a custom marker which allows you to input what color you want the marker to be on the map (the marker is basically just a dot with a black border) by entering the Color value into the constructor. I was wondering if this would be useful for the community for me to upload into a patch? Let me know.

 

Phil

Coordinator
Nov 16, 2009 at 10:02 PM

perfect! if the code is short you can just write here, i'll include it in demo markers ;}

Nov 17, 2009 at 12:32 AM

Hi Ployer

Your  idea is great and just what I was looking for but couldn't do it by myself.

I would appreciate if you can post your code so that I can try it also.

Looking forward for your feedback.

Best regards

 

Nov 17, 2009 at 1:15 PM
Edited Nov 17, 2009 at 1:16 PM

Here is the code for the marker, this code does take a bitmap resource i created as well, either you can create your own or give me a email address or some place to send the one I made in paint =) Basically the way it works is it replace pixels that have the argb value of 255,0,0,0. Let me know if you have any questions.

 

 

namespace GMap.NET.WindowsForms.Markers
{
    using System.Drawing;

#if !PocketPC
    using System.Windows.Forms.Properties;
#else
   using GMap.NET.WindowsMobile.Properties;
#endif

    public class GMapDotMarker : GMapMarker
    {
        private Bitmap Resource;

        public GMapDotMarker(PointLatLng p, Color color)
            : base(p)
        {
            Resource = Resources.Dot;

            for (int x = 0; x < Resource.Width; x++)
            {
                for (int y = 0; y < Resource.Height; y++)
                {
                    if (Resource.GetPixel(x, y).A == 255 && Resource.GetPixel(x, y).B == 0 && Resource.GetPixel(x, y).G == 0 && Resource.GetPixel(x, y).R == 0)
                    {
                        Resource.SetPixel(x, y, color);
                    }
                }
            }
        }

        public override void OnRender(Graphics g)
        {

            if (!IsDragging)
            {
                g.DrawImageUnscaled(Resource, LocalPosition.X, LocalPosition.Y);
            }
            else
            {
           
                g.DrawImageUnscaled(Resource, LocalPosition.X, LocalPosition.Y);
      
            }
        }
    }
}

 

 

Coordinator
Nov 17, 2009 at 4:13 PM

painting by seating pixels is slow ;/

Nov 17, 2009 at 4:25 PM

well it doesn't do it every time it draws to the screen, just when the object is built. Also the dot image I am using maybe only has 10 pixels in it total, as a result I am able to draw around 15000 dots to a map of the united states in under a second.

Coordinator
Nov 17, 2009 at 5:44 PM

mm, quite many