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

Binding multiple visualisation layers

3 Answers 237 Views
Map
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Veteran
Peter asked on 01 Nov 2016, 04:22 PM

We have a data model which has the notion of "layers" where each layer has a collection of entities that I want to plot on the map. Each layer has properties to control layer visibility (and hence visibility of entities on that layer) on/off and also by zoom range (which differs for each layer). My thought is that I should be able to add a visualisation layer to the map control for each of the layers in my data model, but I can't see how to bind to a collection of layers. 

Is what I describe possible and/or the best approach to the problem I'm trying to solve?

Thanks.

 

 

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 04 Nov 2016, 08:32 AM
Hello Peter,

The RadMap is an ItemsControl and has ItemsSource property , however, binding to collection which would lead to generating a layers is not supported out of the box. In PrepareContainerForItemOevrride we expect ILayer coming and pass some events to it. 

To databind multiple layers we suggest the following:
         - list the layers in XAML in the Items collction of the RadMap
         - bind the ItemsSource and / or DataContex of every layer to collection / ViewModel
         - follow MVVM approach described in our documentation

<RadMap>
      <VisualizationLayer DataContext={binding Model1} ItemsSource ={bindingg POIcollection1}
       <VisualizationLayer DataContext={binding Model2} ItemsSource ={bindingg POIcollection2}
       .....

Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Peter
Top achievements
Rank 1
Veteran
answered on 04 Nov 2016, 11:12 AM

Hi Peter,

Thanks for the reply. Adding multiple layers in the XAML is inconvenient for me since it is not predictable how many layers I would need to add. At the time I set the data context for the map I know how many layers are required i.e. no additional layers will be added after the initial bind. Would this allow me to safely bind to the ItemsSource property of RadMap (either in XAML or code-behind)?

If not, I could change my data model so that all my entities are in a single VisualizationLayer and control the visibility of each entity when the zoom of the map changes. Would this be a better approach?

Thanks,

Pete

 

 

 

 

0
Petar Mladenov
Telerik team
answered on 08 Nov 2016, 08:14 AM
Hi Peter,

As previously stated, you can consider binding the ItemsSource of the RadMap to collection of ViewModels not supported because we expect ILayers in PrepareContainerForItemOverride method.

Since you have moment in code behind when you know all the possible layers you will use, simple add a function which adds VisualizationLayers directly in the Items property (collection) of the RadMap.

It's hard to determine simply which one is better - using single Layer with constant playing with item's visibility or using multiple layers. I would personally test both of these and decide which one has better overall performance. As for hiding items on particular zoom levels, I hope you know the attached property 
telerik:MapLayer.ZoomRange. You can see it used in the following help article:

VisualizationLayer Introduction

Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
Map
Asked by
Peter
Top achievements
Rank 1
Veteran
Answers by
Petar Mladenov
Telerik team
Peter
Top achievements
Rank 1
Veteran
Share this question
or