using Gmap having errors when overlaying marks.

 private void GMapController_Load(object sender, EventArgs e) { locationList = GetLocationData(); gMapController.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance; GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly; gMapController.Position = new PointLatLng(-42.6352553,167.9541378); gMapController.Zoom = 3; gMapController.ShowCenter = false; GMapOverlay markersOverlay = new GMapOverlay(); foreach (PlaceOfInterest poi in locationList) { GMapMarker marker = new GMarkerGoogle(new PointLatLng(poi.Latitude, poi.Longitude), AssignColor(poi.UserID)); marker.ToolTipText = string.Format("{0} : {1}", poi.UserID.ToString(), poi.Description); marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; markersOverlay.Markers.Add(marker); } gMapController.Overlays.Add(markersOverlay); } 

until I mark it from the foreach loop everything works fine but I get the error from ‘Application.Run(new Form1())’.

The below is error stack.

System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. Source=mscorlib StackTrace: at System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken) at GMap.NET.WindowsForms.Markers.GMarkerGoogle.OnRender(Graphics g) at GMap.NET.WindowsForms.GMapOverlay.OnRender(Graphics g) at GMap.NET.WindowsForms.GMapControl.OnPaintOverlays(Graphics g) at GMap.NET.WindowsForms.GMapControl.DrawGraphics(Graphics g) at GMap.NET.WindowsForms.GMapControl.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

  1. possible cause might be .. I couldn’t get the map using setlocationbykeywords so I used just new latitude and longintude to get it. Probably scaling problem?
  2. Another possible cause might be that I should assign value other than those three values in the foreach loop.

submitted by /u/HeyJOe2
[link] [comments]

Leave a Reply