Show Composite Control on the Map

3 posts, 1 answers
  1. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 22 Mar 2011 Link to this post

    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. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 24 Mar 2011 Link to this post

    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
  3. DevCraft banner
  4. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 24 Mar 2011 Link to this post

    Hi Andrey Murzov,

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

    Greetings,

    Tobias.
Back to Top