How to style a line in RadMap

5 posts, 0 answers
  1. Curt
    Curt avatar
    14 posts
    Member since:
    Jan 2012

    Posted 02 Apr 2012 Link to this post

    Hello

    How can I style a line on the map? I have a single InformationLayer with a 

    SqlGeospatialDataReader

    that contains point, areas, and lines.

    I copied one of the demos to style my polygons:
    <telerik:InformationLayer.ShapeFill>
        <telerik:MapShapeFill Fill="#7FFFFFFF"
                              Stroke="Red"
                              StrokeThickness="2" />
    </telerik:InformationLayer.ShapeFill>
    <telerik:InformationLayer.HighlightFill>
        <telerik:MapShapeFill Fill="#B2FFFFFF"
                              Stroke="Red"
                              StrokeThickness="2" />
    </telerik:InformationLayer.HighlightFill>



    However I can't figure out what properties are used for lines.
    Thank you.
  2. Curt
    Curt avatar
    14 posts
    Member since:
    Jan 2012

    Posted 03 Apr 2012 Link to this post

    I looked some more at this. It appears that lines use the styles from "MapShapeFill".

    However, each end of a line is connected and then a fill is applied, so they appear as un-closed polygons. Please see attached pictures.

    I would like the polygons to have a fill, but the lines (poly lines) to not have a fill.
  3. DevCraft banner
  4. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 05 Apr 2012 Link to this post

    Hello Curt,

    The map shape objects use regular Silverlight shapes for visualization. The map shapes provide the same set of the painting properties as the regular Silverlight shapes provide (Fill, Stroke, StrokeThikness and so on). These properties are combined in the MapShapeFill object. So you always can refer to the MSDN as well as to the Telerik documentation for detailed information about painting properties:

    http://msdn.microsoft.com/en-us/library/cc189073(v=vs.95).aspx
    http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape(v=vs.95).aspx
    http://www.telerik.com/help/silverlight/allmembers_t_telerik_windows_controls_map_mapshapefill.html

    For example, the MapLine shape uses Stroke and StrokeThikness properties.

    Greetings,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Curt
    Curt avatar
    14 posts
    Member since:
    Jan 2012

    Posted 06 Apr 2012 Link to this post

    Andrey

    If I have a single information layer, and this information layer contains both lines and polygons, is it possible to apply different fills/strokes to the lines and polygons? For instance, all the polygons have a red stroke with a white fill, and the lines have a blue stroke with no fill.


    Thank you.
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 11 Apr 2012 Link to this post

    Hi Curt,

    You can use the PreviewReadCompleted event of the SqlGeospatialDataReader. In the event handler you can walk though all elements that have been read and colorize them per type of the shape. For example:

    private void Reader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
    {
        if (eventArgs.Error == null)
        {
            foreach (FrameworkElement item in eventArgs.Items)
            {
                MapPolyline polyline = item as MapPolyline;
                MapPolygon polygon = item as MapPolygon;
                if (polyline != null)
                {
                    // Colorize polyline.
                    polyline.Stroke = new SolidColorBrush(Colors.Blue);
                    polyline.StrokeThickness = 2;
                }
                else if(polygon != null)
                {
                    polygon.Fill = new SolidColorBrush(Colors.White);
                    polygon.Stroke = new SolidColorBrush(Colors.Red);
                    polygon.StrokeThickness = 2;
                }
            }
        }
    }


    Kind regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner