Binding multiple visualisation layers

4 posts, 0 answers
  1. Peter
    Peter avatar
    8 posts
    Member since:
    Oct 2016

    Posted 01 Nov Link to this post

    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.

     

     

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 04 Nov Link to this post

    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!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    8 posts
    Member since:
    Oct 2016

    Posted 04 Nov in reply to Petar Mladenov Link to this post

    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

     

     

     

     

  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 08 Nov Link to this post

    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!
Back to Top