Errors of using PolylineData with visualization layer

2 Answers 132 Views
Map
BNM2024
Top achievements
Rank 1
Iron
BNM2024 asked on 10 Mar 2024, 09:41 AM

Hello, 

I'm currently working on a visualization layer to display a trace line of a Location Collection. To achieve this, I have set the ItemsSource of the layer to an Observable Collection. Additionally, I am using PolylineData to visualize the Location Collection. However, during implementation, I encountered some errors.

  • The specified value cannot be assigned. The following type was expected: "DependencyObject".
  • Property 'VisualTree' does not support values of type 'PolylineData'.

Here is the portion of the code

<telerik:VisualizationLayer x:Name="visualizationLayer" ItemsSource="{Binding ObjItems}">
                                    <telerik:VisualizationLayer.ItemTemplate>
                                        <DataTemplate>
                                            <telerik:PolylineData Points="{Binding TrackPoints}">
                                        <telerik:PolylineData.ShapeFill>
                                            <telerik:MapShapeFill Stroke="Blue" 
                                      StrokeThickness="2" />
                                        </telerik:PolylineData.ShapeFill>
                                    </telerik:PolylineData>
                                        </DataTemplate>
                                    </telerik:VisualizationLayer.ItemTemplate>
                                </telerik:VisualizationLayer

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 11 Mar 2024, 10:44 AM

Hello,

PolylineData is not a visual element so you cannot use it in a DataTemplate. Instead, of using ItemSource and ItemTemplate, you can directly populate the Items collection of the VisualizationLayer with PolylineData objects.

Alternatively, you can use the MapPolylineView element in the ItemTemplate. This is not a real visual element, but a wrapper that can be hosted in the ItemTemplate and it will automatically create a PolylineData object.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
BNM2024
Top achievements
Rank 1
Iron
answered on 11 Mar 2024, 11:59 AM

Thank you Martin for the response.

I'm using MVVM , is there any example based on your suggested solutions especially using MapPolylineView ?  

Martin Ivanov
Telerik team
commented on 11 Mar 2024, 12:57 PM

I am afraid that there is no resource on the topic, but the MapPolylineView should share the same main properties like the PolylineData object, so you can replace the PolylineData from your code snippet with MapPolylineView and this should be working.
BNM2024
Top achievements
Rank 1
Iron
commented on 30 Oct 2024, 06:21 PM

Thank you, Martine, for your response. Sorry for the delay in updating you. I went back to implement your suggestions, but I’m not seeing anything drawing on the map.

When I use the information layer, the polyline is drawn, but the performance is very slow because the points list is updated with random locations every second.

What do you suggest to resolve this issue? Below is my implementation for the visualization and information layers.

  <telerik:VisualizationLayer ItemsSource="{Binding ObjItems}" UseBitmapCache="False" >
      <telerik:VisualizationLayer.ItemTemplate>
          <DataTemplate>
              <telerik:MapPolylineView  Points="{Binding TrackPoints}" >
                  <telerik:MapPolylineView.ShapeFill>
                      <telerik:MapShapeFill Stroke="Blue" 
StrokeThickness="2" />
                  </telerik:MapPolylineView.ShapeFill>
              </telerik:MapPolylineView>
          </DataTemplate>
      </telerik:VisualizationLayer.ItemTemplate>
  </telerik:VisualizationLayer>

 

  <telerik:InformationLayer ItemsSource="{Binding ObjItems}">
    <telerik:InformationLayer.ItemTemplate>
        <DataTemplate>
            <telerik:MapPolyline Points="{Binding TrackPoints}" Stroke="Red" StrokeThickness="1"/>
        </DataTemplate>
    </telerik:InformationLayer.ItemTemplate>
</telerik:InformationLayer>
Martin Ivanov
Telerik team
commented on 31 Oct 2024, 10:13 AM

In order for the MapPolylineView to get displayed, the TrackPoints collection should be of type LocationCollection. I have tested the code snippet and the points draw properly in the VisualizationLayer on my side. You can check the attached project and see if I am missing anything.
Tags
Map
Asked by
BNM2024
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
BNM2024
Top achievements
Rank 1
Iron
Share this question
or