simple problem with gmap basic functions

Topics: Windows Forms
Jun 14, 2013 at 5:14 PM
Hi,
Thank you very much for this great job!
I'm trying to do a test wf application reading your tutorial.
i've add one simple marker and a basic route in one overlay.
there are some problems:
1)first click on button1
the route doesn't appear untill i resize the map
Image
2)Resize form
marker disappear and route appear
Image
3)scroll map,resize map, re-click on button1
marker appear in a different position.
Image

whats'wrong?thank you.
this is my simple code
namespace TestMap {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void gMapControl1_Load(object sender, EventArgs e) {
            // Initialize map:
            gmap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gmap.Position = new PointLatLng(44.731532, 11.290816);
            gmap.CanDragMap = true;
        }

        private void simpleButton1_Click(object sender, EventArgs e) {
            PointLatLng start2 = new PointLatLng(44.731532, 11.290816); ;
            PointLatLng end2 = new PointLatLng(44.755298, 11.308620);
            MapRoute route2 = GMap.NET.MapProviders.GoogleMapProvider.Instance.GetRoute(
              start2, end2, false, false, 15);
            GMapRoute r2 = new GMapRoute(route2.Points, "My route");
            GMapOverlay routesOverlay = new GMapOverlay("routes");
            routesOverlay.Routes.Add(r2);
            GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528),GMarkerGoogleType.blue_pushpin);
            marker.ToolTipText = "Test Marker";
            routesOverlay.Markers.Add(marker);
            gmap.Overlays.Add(routesOverlay);
        }

    }
}
Jun 17, 2013 at 7:34 AM
Edited Jun 17, 2013 at 7:34 AM
remove: gMapControl1_Load

then
GMapOverlay routesOverlay = new GMapOverlay("routes");

public Form1()
 {
            InitializeComponent();

           gmap.MapProvider = GMapProviders.GoogleMap;
           gmap.Overlays.Add(routesOverlay);  
 }
Jun 18, 2013 at 4:03 PM
Thanks a lot! it works!