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

ClusterTemplateSelector or ItemTemplateSelector of a Visualization layer with a Clustered Data Sourse

3 Answers 75 Views
Map
This is a migrated thread and some comments may be shown as answers.
vinutha
Top achievements
Rank 1
vinutha asked on 19 Dec 2014, 12:07 PM
Hi,

  I want to have 2 types of clusters to be displayed on My Map . 

 <telerik:VisualizationLayer x:Name="visualizationLayer"
ClusteringEnabled="True"
ClusterTemplateSelector="{StaticResource predictionPinsDataTemplateSelector}"  
ItemTemplate="{StaticResource ClusteredItemTemplate}"
GenerateClustersOnZoom="True"
 ItemsSource="{StaticResource MassiveDataSource}">
            </telerik:VisualizationLayer>


Inside the template selector call I am making my decision of which template to be displayed. But i and not able to find the datatemplate . Below is the exception i get .  I have also attached the Sample project . Could you please help me out in this.ClusterSample    

3 Answers, 1 is accepted

Sort by
0
vinutha
Top achievements
Rank 1
answered on 23 Dec 2014, 08:54 AM
Can any one help me out on this. 
0
Accepted
Petar Mladenov
Telerik team
answered on 24 Dec 2014, 08:24 AM
Hi Vinutha,

Generally, looking up a resource in code behind is bad idea - it will be slower and far away from MVVM pattern. The DataTemplateSelector should be usually used with properties which you use both in XAML - to set them and in code behind (in SelectTemplate method) to select them. 

For example you can check the RadTreeView ItemTemplateSelector help article.

In your scenario you can add DataTemplate properties in your PredictionPinsDataTemplateSelector, for example "FirstClusterTemplate" and "SecondClusterTemplate". In SelectTemplate method you need to return for example this.FirstClusterTemplate based on some logic. In XAML, you must first define the FirstClusterTemplate and SecondClusterTemplate and below them you need to have:
<clusteredDataSorceSample: PredictionPinsDataTemplateSelector
                         FirstClusterTemplate={StaticResource firstDataTemplate}
                          SecondClusterTemplate={StaticResource secondClusterTemplate} ...


Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
vinutha
Top achievements
Rank 1
answered on 29 Dec 2014, 06:49 AM
Thank you so much this resolved my issue.
Tags
Map
Asked by
vinutha
Top achievements
Rank 1
Answers by
vinutha
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or