How to attach a MapPolygon to an InformationLayer with C# -- not XAML?

2 posts, 0 answers
  1. Yan Moura
    Yan Moura avatar
    33 posts
    Member since:
    Feb 2010

    Posted 16 Nov 2011 Link to this post

    Hi,

    I am trying to reproduce the demo existing on Map Shapes page (in XAML format) to C# code. Mostly wasn't so hard, but now I am stuck on getting the MapPolygon added to the Information Layer.

    Here it is the original XAML sample (I supressed the CaptionTemplate part as I don't need it):

    <telerik:RadMap x:Name="radMap" Width="600" Height="480">
        <telerik:InformationLayer>
            <telerik:MapPolygon Points="56,-100 56,-108 48,-108 48,-100" Fill="Green" Stroke="Red"
                      StrokeThickness="4" >
            </telerik:MapPolygon>
        </telerik:InformationLayer>
    </telerik:RadMap>

    And here my C# code:

    InformationLayer MyInformationLayer = new InformationLayer();
     
    LocationCollection MyLocationCollection = new LocationCollection();
    MyLocationCollection.Add(new Location(56, -100));
    MyLocationCollection.Add(new Location(56, -108));
    MyLocationCollection.Add(new Location(48, -108));
    MyLocationCollection.Add(new Location(48, -100));
     
    MapPolygon MyMapPolygon = new MapPolygon();
    MyMapPolygon.Points = MyLocationCollection;
    MyMapPolygon.Fill = new SolidColorBrush(Colors.Green);
    MyMapPolygon.Stroke = new SolidColorBrush(Colors.Red);
    MyMapPolygon.StrokeThickness = 4;
     
    // Now -- how to attach MyMapPolygon to MyInformationLayer?

    Thanks!
  2. Yan Moura
    Yan Moura avatar
    33 posts
    Member since:
    Feb 2010

    Posted 16 Nov 2011 Link to this post

    OK, I figured it out. For whose may have interest, it is:

    MyInformationLayer.Items.Add(MyMapPolygon);
  3. DevCraft banner
Back to Top