Hi,
I am attempting to set the best view on radmap but I am getting a type conversion error when setting the rectangle to the information layer.
I am setting the information layer item source to records within a radgrid using:
Me.informationLayer.ItemsSource = Nothing
items = New ObservableCollection(Of MapItem)
Dim Item As PendingClass = TryCast(Me.PendingGrid.SelectedItem, PendingClass)
Dim LatLon() As String
If Not Item.LatLon Is Nothing Then
LatLon = Item.LatLon.Split(",")
Me.Vehtn.Visibility = Windows.Visibility.Visible
Dim foreground As Brush = New SolidColorBrush(Colors.Yellow)
Dim background As Brush = New SolidColorBrush(Colors.Red)
Dim Vtext As New TextBlock() With { _
.Text = Item.DelRegistration, _
.Background = background, _
.Foreground = foreground _
}
Me.items.Add(New MapItem(LatLon(0), LatLon(1), background, Vtext, Item.DateOfFix))
End If
Background = New SolidColorBrush(Colors.Green)
Dim text As New TextBlock() With { _
.Text = Item.DelName, _
.Background = Background, _
.Foreground = Foreground _
}
If Not Item.DelLatLon Is Nothing Then
Me.Locbtn.Visibility = Windows.Visibility.Visible
If Me.Vehtn.Visibility = Windows.Visibility.Visible Then Me.Distancebtn.Visibility = Windows.Visibility.Visible
LatLon = Item.DelLatLon.Split(",")
Me.items.Add(New MapItem(LatLon(0), LatLon(1), Background, text, Item.DelDate))
End If
Me.informationLayer.ItemsSource = items
I then attempt to set the map best view and I get the error:
‘+ ex {"Unable to cast object of type 'System.Windows.Controls.ItemCollection' to type 'System.Collections.Generic.IEnumerable`1[System.Object]'."} System.Exception’
If Me.informationLayer.Items.Count > 0 Then
Dim rect As LocationRect = Me.informationLayer.GetBestView(Me.GetIEnumerable(Me.informationLayer))
rect.MapControl = Me.radMap
Me.radMap.Center = rect.Center
Me.radMap.ZoomLevel = rect.ZoomLevel
End If
Regards,
Joe