change in position of custom marker image while zooming in and out

Topics: General, Windows Forms
Apr 21, 2013 at 3:20 PM

I have created a custom marker image.

however when i zoom out, image is displayed somewhere else on the map away from the original position


the figure on the left shows actual position of image, and right shows the shifting of image after zoom out.

what is the solution for this??
Apr 22, 2013 at 7:10 AM
probably you set marker.Offset ?
Apr 22, 2013 at 8:44 AM
no...i have not set any offset
Apr 22, 2013 at 11:02 AM
so why default markers don't have this issue?
Apr 22, 2013 at 11:36 AM
I don't know the reason.

This is my custom marker code,

public class GMapImage : GMapMarker
    private Image image;
    public Image Image
            return image;
            image = value;
            if (image != null)
                this.Size = new Size(image.Width, image.Height);

    public GMapImage(GMap.NET.PointLatLng p) : base(p)
        DisableRegionCheck = true;
        IsHitTestVisible = false;

    public override void OnRender(Graphics g)
        if (image == null)

        g.DrawImage(image,  LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
and this is how i place an image over map,
GMapImage gmimage;
gmimage = new GMapImage(new PointLatLng(latitude, longitude));
gmimage.Size = gMapControl1.Size;
var TL= gMapControl1.FromLocalToLatLng(gMapControl1.Location.X,gMapControl1.Location.Y);
gmimage.Position = TL;

gmimage.Image = bMap; // bmap is my image

Please let me know if i am doing something wrong over here
Apr 22, 2013 at 1:05 PM
gmimage.Size = gMapControl1.Size;
var TL= gMapControl1.FromLocalToLatLng(gMapControl1.Location.X,gMapControl1.Location.Y);
gmimage.Position = TL;


thats beyond strange...
Apr 22, 2013 at 4:43 PM
My application is based on visualization of radio waves over the geographical area. This is connection with database. i had to convert geographical coordinates to local coordinates to generate a colored image, hence i don have any fixed size for the image and fixed position for it. It would change randomly according to my data and would be placed anywhere according to coordinates i receive from data, so i selected the size as my gmapcontrol size, and i noticed that if i don't use gmimage.Position = TL; my image is not placed on correct position on map.
Apr 22, 2013 at 4:47 PM
i took this idea from mike_mankus

// Assign the bitmap
gmImage.Image = (your bitmap here);

// Passing PointLatLng of top left (TL) corner of where to plot image
var tl = MainMap.FromLatLngToLocal(gmImageTL);

// Passing PointLatLng of bottom right (BR) corner of where to plot image
var br = MainMap.FromLatLngToLocal(gmImageBR);

// Setting the GMapImage position based on the top left corner
gmImage.Position = gmImageTL;

// Setting the GMapImage size based on the top left and bottom right corner
gmImage.Size = new System.Drawing.Size(br.X - tl.X, br.Y - tl.Y);

// Telling the map to redraw

but i donno what am i doing wrong.
Apr 22, 2013 at 5:55 PM
you have to repeat these actions on zoom changed event