Can't access to map control from other class

Topics: Windows Forms
Sep 9, 2012 at 9:39 AM

Hi

I use this code to access to map control and change position of it, i change map control modifier to public, no error happend but map not move,

private static void explorerBar_ItemClick(object sender, Janus.Windows.ExplorerBar.ItemEventArgs e)
{
    UI.MainForm main = new UI.MainForm();
    main.ResetMarkerSize();
    try
    {
        main.SelectedPoint = Convert.ToInt32(e.Item.Key);

        double[] Position = DAL.DataAccessClass.PointPosition.GetPointPosition(Convert.ToInt32(e.Item.Key));
        PointLatLng ItemPosition = new PointLatLng(Position[0], Position[1]);

        MapLayers.CreateLayerMapInDifferentZoom(main.MainMapControl, main.Pointslayer);

        foreach (GMapMarker marker in main.AllPointslayer.Markers)
        {
            if (marker.Tag.ToString() == e.Item.Key.ToString())
            {
                marker.Size = new Size(main.MapMarkerBiggerSize, main.MapMarkerBiggerSize);
                break;
            }
        }

        main.MainMapControl.Zoom = 18;
        main.MainMapControl.Position = ItemPosition;
    }
    catch (Exception ex)
    {
        BLL.FunctionsClass.LogExceptions.WriteLogException(ex);
    }
    main.GetSelectedPointExtraInfo();
}

I Create janus explorer bar in class and when i want to click on item map move.

Thanks.

Sep 9, 2012 at 11:56 AM

it doen't matter from what class you access other classes ;}

Sep 9, 2012 at 1:44 PM

so why map control not change position? this is bug? or what?

Thanks

Sep 9, 2012 at 2:04 PM

map.Position = ..., and it changes position, always worked, works today too ;}