ThinkGeo.com    |     Documentation    |     Premium Support

SimpleMarkerOverlay overlapping the baseOverlay

Hi
I have the baseOverlay which contains NativeImageRasterLayer and on top of that overlay is the SimpleMarkerOverlay which contains Draggable Markers. The problem I am having is that when I add a marker, it is not plotted in the correct location. And the other problem is that when I zoom in and out, Markers lose their relative location. Is there a way I can fix this problem. I am new to ThinkGeo Mapsuite so I don’t know much about how it works. I am still learning it. Any help would be much appreciated. Below is the code I have so far:
public Form1()
{
InitializeComponent();

    }

    private void Form1_Load(object sender, EventArgs e)
    {
        	winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

      	Proj4Projection proj4 = new Proj4Projection();
       
	proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
        
	proj4.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
        
	proj4.Open();
        
	RectangleShape rect = new RectangleShape(-135, 70, -56, 7);
        
	RectangleShape rectShape = proj4.ConvertToInternalProjection(rect);
        
	NativeImageRasterLayer drawingImage = new NativeImageRasterLayer(@"..\..\App_Data\bravoscan_drawing.jpg", rect);
        
        	LayerOverlay overlay = new LayerOverlay();
        
	SimpleMarkerOverlay markerOverLay = new SimpleMarkerOverlay();
        
	markerOverLay.MapControl = winformsMap1;
        
	overlay.Layers.Add(drawingImage);
        
	winformsMap1.Overlays.Add("drawing",overlay);
        
	winformsMap1.Overlays.Add("markers", markerOverLay);
       
	winformsMap1.RestrictedExtent = rectShape;
        	winformsMap1.CurrentExtent = rectShape;
        
	winformsMap1.Refresh();
    }

    private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
    {
        if (e.MouseButton != MapMouseButton.Left)
        {
            return;
        }
        SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["markers"];
        markerOverlay.DragMode = MarkerDragMode.Drag;
        PointShape position = new PointShape(-99.2353515625, 50.3212890625);
        Marker marker = new Marker(position);
        Image icon= Image.FromFile(@"..\..\App_Data\marker_custom.png");
        Bitmap item = new Bitmap(icon, new Size(20, 35));
        marker.Image = item;
        markerOverlay.Markers.Add(marker);
        winformsMap1.Refresh();
    }
}

Thanks

Hi Sanele,

I build a very simple sample based on your code: 8655.zip (69.9 KB)

In this sample, you can add marker on map, pan or zoom the map to view the marker, it looks everything works well and the marker keep its relative position.

Please notice, our marker keep the upperleft point on map, if you want to adjust its position please set the Xoffset and Yoffset.

You can get more samples here: https://github.com/thinkgeo

Regards,

Ethan