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

Show Composite Control on the Map

2 Answers 36 Views
Map
This is a migrated thread and some comments may be shown as answers.
Simon Störmer
Top achievements
Rank 1
Simon Störmer asked on 22 Mar 2011, 11:51 AM
Hi,

I try to achive the following: I want to display tours on a map. A tour consists of multiple stations which are locations. I do not want to draw a concrete route, but some kind of a sketch route. That means that all the stations are connected with straight lines. So far, this is no problem, I can use the MapPolyline for this. I want the stations itself to be displayed as filled circles. I want to be able to visualize multiple tours in the same map. (See attached picture)

I am working with MVVM apporoach, so I want to have a single Control, lets call it MapTour which I can use like that:

<telerik:RadMap x:Name="radMap"
 
    <telerik:InformationLayer x:Name="TourLayer" ItemsSource="{Binding Tours}" >
        <telerik:InformationLayer.ItemTemplate>
          <DataTemplate>
            <my:MapTour Stations="{Binding Stations}" />
          </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
      </telerik:InformationLayer>
 
</telerik:RadMap>

In the ViewModel I have a property Tours as an ObservableCollection<TourViewModel>. TourViewModel is defined as follows:

public class TourViewModel : INotifyPropertyChanged
{
 
      private String m_TourName;
      private ObservableCollection<LISCoordinate> m_Stations;
 
      public ourViewModel()
      {
        TourName = "Empty";
        Stations = new ObservableCollection<Location>();
      }
 
     public String TourName
      {
        get { return m_TourName; }
        set { m_TourName = value; OnPropertyChanged("TourName"); }
      }
 
      public ObservableCollection<Location> Stations
      {
        get { return m_Stations; }
        set { m_Stations = value; OnPropertyChanged("Stations"); }
      }
 
      // INotifyPropertyChanged implementation omitted.
}

But I can not figure out how to write the MapRoute control. I know that I can add two InformationLayers for one rout, one for the polyline and the other for the points. But how can I encapsulate this into a control? What base class do I have to use? I can not nest InformationLayers, if I could I would derive from this class and add my visuals in code. But nesting Information layers does not seem to work. 

What do I have to fill in for the data template to achive the described behaviour?

Thanks for your help.

Tobias.

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 24 Mar 2011, 12:16 PM
Hi Tobias Richling,

I would recommend that you use two information layers which are bound to two collections. You can create collection of points of all tours using the CollectionChanged event.
I have attached a sample solution. I hope it helps.

Regards,
Andrey Murzov
the Telerik team
0
Simon Störmer
Top achievements
Rank 1
answered on 24 Mar 2011, 12:32 PM
Hi Andrey Murzov,

thanks for the sample. I think I can solve this that way!

Greetings,

Tobias.
Tags
Map
Asked by
Simon Störmer
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Simon Störmer
Top achievements
Rank 1
Share this question
or