This is a migrated thread and some comments may be shown as answers.

Nested InformationLayer

1 Answer 42 Views
Map
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 26 Jun 2012, 06:28 PM
I have a collection of ScanSessions, each of which contains a collection of Waypoints. I have a RadGridView for displaying a list of the ScanSessions and I have another RadGridView for displaying the list of Waypoints in the selected ScanSession. I am also trying to write the XAML to create a RadMap InformationLayer that displays all the Waypoints for all the ScanSessions on a map. The reason for this is to make it easy to indicate on the map which Waypoint is selected in the grid view and vice versa.

I tried to do this by nesting one InformationLayer inside another as seen in the following XAML:

<UserControl.Resources>
    <local:LocationToTelerikConverter x:Key="LocationToTelerikConverter"/>
    <local:LocationCollectionToTelerikLocationCollectionConverter x:Key="LocationCollectionToTelerikLocationCollectionConverter"/>
 
      <SolidColorBrush x:Key="ControlSubtleForegroundBrush" Color="#004100"/>
 
    <DataTemplate x:Key="MapWaypointsTemplate">
        <Grid Tag="{Binding}" telerik:MapLayer.Location="{Binding Path=Location, Converter={StaticResource LocationToTelerikConverter}}">
            <telerik:MapLayer.HotSpot>
                <telerik:HotSpot ElementName="WaypointEllipse" X="0.5" Y="0.5" XUnits="Fraction" YUnits="Fraction"/>
            </telerik:MapLayer.HotSpot>
            <Ellipse x:Name="WaypointEllipse" Width="20" Height="20" Fill="Blue"/>
        </Grid>
    </DataTemplate>
</UserControl.Resources>
 
<Grid Background="Black">
    <telerik:RadMap x:Name="map" Background="Transparent" UseSpringAnimations="False" DistanceUnit="Kilometer" MouseClickMode="None"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                UseDefaultLayout="False" MaxZoomLevel="24" MinZoomLevel="1" ZoomLevel="1"
                MapMouseClick="OnMapMouseClick" CenterChanged="OnMapCenterChanged" ZoomChanged="OnMapZoomChanged" InitializeCompleted="OnMapInitializeCompleted" PreviewMouseMove="OnMapPreviewMouseMove"
        >
        <telerik:RadMap.Providers>
            <telerik:EmptyProvider/>
            <!-- Provider set programmatically. -->
        </telerik:RadMap.Providers>
 
        <telerik:InformationLayer x:Name="scanSessionSnailTrailLayer" ItemsSource="{Binding ElementName=_this, Path=ScanSessions}">
            <telerik:InformationLayer.ItemTemplate>
                <DataTemplate>
                    <telerik:MapPolyline Stroke="Blue" StrokeThickness="2" Points="{Binding Path=WaypointLocations, Converter={StaticResource LocationCollectionToTelerikLocationCollectionConverter}}"/>
                </DataTemplate>
            </telerik:InformationLayer.ItemTemplate>
        </telerik:InformationLayer>
 
        <telerik:InformationLayer x:Name="scanSessionWaypointsOuter" ItemsSource="{Binding ElementName=_this, Path=ScanSessions}">
            <telerik:InformationLayer.ItemTemplate>
                <DataTemplate>
                    <telerik:InformationLayer x:Name="scanSessionWayPointsInner" ItemsSource="{Binding Path=Waypoints}" ItemTemplate="{StaticResource MapWaypointsTemplate}"/>
                </DataTemplate>
            </telerik:InformationLayer.ItemTemplate>
        </telerik:InformationLayer>
    </telerik:RadMap>
</Grid>

The problem is that none of the Waypoint ellipses are displayed. I have also tried replacing both the outer and inner InformationLayer elements with simple ItemsControl elements, with no success.

Note that the InformationLayer named scanSessionSnailTrailLayer works just fine.

Does anybody have an idea how to get my nested InformationLayers to work?

Thanks,

-- john

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 29 Jun 2012, 07:58 AM
Hi John,

You can't use information layer inside another information layer. The information layer can be child of the RadMap control only. At the first glance there are 2 possible ways to solve the problem:

1. You can fill in second information layer with waypoints from the code when ScanSessions property is changed.
2. You can create additional property which will have collection type (ObservableCollection<Waypoint>, for example) and bind ItemsSource property of the second information layer to it. You will fill in this collection with waypoints from the code when ScanSessions property is changed.

All the best,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Map
Asked by
John
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or