Topics: Windows Forms
Mar 14, 2012 at 7:56 AM
Edited Mar 14, 2012 at 8:12 AM

Hi Radioman,

Since quit a while i am working on app with the control. In form_Load i have following settings:

        GMap.NET.GMaps.Instance.UseRouteCache = True
        GMap.NET.GMaps.Instance.UseGeocoderCache = True
        GMap.NET.GMaps.Instance.UsePlacemarkCache = True
        GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache
        GMapControl1.MapProvider = MapProviders.GoogleMapProvider.Instance
        GMapControl1.DragButton = Windows.Forms.MouseButtons.Left
        GMapControl1.Width = Me.Width
        GMapControl1.Height = Me.Height - 40
        GMapControl1.MouseWheelZoomType = MouseWheelZoomType.MousePositionAndCenter
        GMapControl1.MaxZoom = 17
        GMapControl1.MinZoom = 2
        GMapControl1.Zoom = 8
        GMapControl1.MarkersEnabled = True
        GMapControl1.CanDragMap = True

In a Button click event is have following code:
 Dim TopOverlay = New GMapOverlay(GMapControl1, "TopOverlay")
        For i As Integer = 0 To arrKlanten.GetUpperBound(0) - 1
            If Not arrKlanten(i, 0) = Nothing Then
                GMapControl1.SetCurrentPositionByKeywords(arrKlanten(i, 1) & "," & arrKlanten(i, 3))
                Dim myPlaats As GMap.NET.PointLatLng
                myPlaats.Lat = GMapControl1.Position.Lat
                myPlaats.Lng = GMapControl1.Position.Lng
                    If Not myPlaats.Lat.ToString = "" Or myPlaats.Lng.ToString = "" Then
                        Dim strLat As String = myPlaats.Lat.ToString.Replace(".", ",")
                        Dim strLong As String = myPlaats.Lng.ToString.Replace(".", ",")
                        Dim myPoint As New GMap.NET.PointLatLng(CDec(strLat), CDec(strLong))
                        Dim myMarker As New GMap.NET.WindowsForms.Markers.GMapMarkerGoogleGreen(New PointLatLng(myPoint.Lat, myPoint.Lng))
                        '  myMarker.ToolTipText = arrKlanten(i, 0) & vbCrLf & arrKlanten(i, 1) & vbCrLf & arrKlanten(i, 2) & vbCrLf & arrKlanten(i, 3)
                    End If

                End Try
            End If


In short i read from a array, the street and city. With that code i place about 150 markers on the map. All in the Netherlands. 

But i have several issues with that code. (So time to change:-) ). The first proble is that it takes about 10 seconds before the map is shown. This is even before i fire the rest of the code. The next problem is that with every SetCurrentPositionByKeywords the map shift to that position (of course). And the last problem is that when all the markers are in place, every click on the map let the app hang.


So , is there a better way to get the lat/lng from the address info, and after that show all the markers. And what can cause the problem with showing the map in the first place?




Mar 14, 2012 at 10:05 AM

Hi Radioman,


One problem is "solved". I have changed the mapprovider to OpenStreetMap. Than map is loaded in few seconds. 



Mar 14, 2012 at 2:04 PM

so whats the problem? ;}

Mar 14, 2012 at 5:14 PM



As i wrote, there were several issues. The first  problem was with just showing a map, with just one marker. With GoogleMap it toke more than 15 seconds. 

But that one is solved by using an other map provider.


That leaves me with the issue that when looping through a list of addresses and show the corresponding markers with SetCurrentPositionByKeywords with every new marker the screen is centered around the new marker. With 150 markers which needs a refresh every 5 minutes is that not an option. Although the function is like that, for me it is not a good solution. So my question is: Is there a way to get the lat/lng which belongs to a address in the background, and when the list is made, than show the markers. 



Mar 14, 2012 at 8:44 PM

happy reading:

Mar 14, 2012 at 9:34 PM

I don't need to read that stuff. I am familiar with multi threading (VB). I hoped that there was a way to not let the map jump with every new marker.

Is there a way to show new markers, just like when having the lat/lng. So actually a combination of the normal way of showing a ,marker and the way with 

SetCurrentPositionByKeywords.  For example SetMarkerByKeywords.