Errors of using PolylineData with visualization layer

2 Answers 33 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.
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