When I add many markers >250 from a SQL DB , the map becomes unresponsive. -Why ?

Topics: Windows Forms
Nov 29, 2012 at 11:29 AM
Edited Nov 29, 2012 at 11:30 AM


The map becomes very SLOW. What do I do different ? 


        Dim lat As String = Nothing
        Dim lng As String = Nothing
        Dim layer_name As String = Nothing
        Dim info_1 As String = Nothing
        Dim info_2 As String = Nothing
        Dim mimage As String = Nothing
        GMap1.HoldInvalidation = True

            OBJCONN.Close() : OBJCONN.Open()
            Dim Q As New SqlCommand("SELECT * FROM LAYERS WHERE LAYER_NAME='" & L & "'", OBJCONN)
            Dim req As System.Net.WebRequest = System.Net.WebRequest.Create("http://expressen.se/img/MapIcons/Events/Natural disaster/flood.png")
            Dim response As System.Net.WebResponse = req.GetResponse()
            Dim stream As Stream = response.GetResponseStream()
            Dim imgX As System.Drawing.Image = System.Drawing.Image.FromStream(stream)

            Dim R As SqlDataReader = Q.ExecuteReader
            While R.Read
                lat = R("LATITUDE").ToString
                lng = R("LONGITUDE").ToString()
                layer_name = R("Layer_name").ToString()
                info_1 = R("info_1").ToString()
                info_2 = R("info_2").ToString()
                mimage = R("MAP_MARKER_IMAGE")
                Dim m = New GMapMarkerImage(New PointLatLng(lat, lng), New Bitmap(imgX))
                m.ToolTipMode = MarkerTooltipMode.OnMouseOver
                m.ToolTipText = layer_name & vbCrLf & info_1 & vbCrLf & info_2

            End While

        End Try
    End Sub
Nov 29, 2012 at 11:52 AM

for each marker you add the same layer: GMap1.Overlays.Add(Layer_GPSmarker)

you only need to do this once at the startup

Nov 29, 2012 at 12:28 PM

Thank you Mr. Radioman , that did the trick.. The mapcontrol is now smooth and 'fluid' again !!