ThinkGeo.com    |     Documentation    |     Premium Support

KeyNotFoundException - Given key not present in Dictionary

Using the code below I get the subject error with the error text showind up in the msgbox in the try statement below.  I also get the error when I try to pan the map.  Any idea on what to do?


 



    Private Sub PlotStorm(ByVal storm As clsCurrentCyclones)
        If storm.CycloneData.Count < 2 Then Exit Sub
        Dim lineLayer As InMemoryFeatureLayer = DirectCast(WinformsMap1.FindFeatureLayer("LineLayer"), InMemoryFeatureLayer)
        Dim multiLineShape As MultilineShape = New MultilineShape()

        Dim pointLayer As InMemoryFeatureLayer = DirectCast(WinformsMap1.FindFeatureLayer("PointLayer"), InMemoryFeatureLayer)
        For i As Integer = 1 To storm.CycloneData.Count - 1
            Dim firstPt As PointShape = New PointShape(storm.CycloneData(i - 1).LON, storm.CycloneData(i - 1).LAT)
            Dim secondPt As PointShape = New PointShape(storm.CycloneData(i).LON, storm.CycloneData(i).LAT)
            For Each ls As LineShape In firstPt.GreatCircle(secondPt).Lines
                multiLineShape.Lines.Add(ls)
            Next

            Dim id As String = storm.CycloneData(i).YYYYMMDDHH & storm.CycloneData(i).TAU.ToString
            Dim feature As New Feature(storm.CycloneData(i).LON, storm.CycloneData(i).LAT, id)
            If Not pointLayer.InternalFeatures.Contains(id) Then
                pointLayer.InternalFeatures.Add(id, feature)
            End If

            WinformsMap1.Refresh(WinformsMap1.Overlays("PointOverlay"))
        Next

        Dim multiLineFeat As Feature = New Feature(multiLineShape)
        lineLayer.InternalFeatures.Add(storm.CycloneIdent.ToString, multiLineFeat)
        Try

            WinformsMap1.Refresh(WinformsMap1.Overlays("LineOverlay"))
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub



I fixed the issue… changed: 
 Dim multiLineFeat As Feature = New Feature(multiLineShape)
 
 
 to: 
       Dim multiLineFeat As Feature = New Feature(multiLineShape, New String() {storm.CycloneIdent.ToString}) 

Michael, 
  
 Thanks for your post and sharing on your progress, I appreciate it very much. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale