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

How to style a line in RadMap

4 Answers 106 Views
Map
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Iron
Curt asked on 02 Apr 2012, 11:44 PM
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.

4 Answers, 1 is accepted

Sort by
0
Curt
Top achievements
Rank 1
Iron
answered on 03 Apr 2012, 04:34 PM
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.
0
Andrey
Telerik team
answered on 05 Apr 2012, 08:33 AM
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 >>
0
Curt
Top achievements
Rank 1
Iron
answered on 07 Apr 2012, 12:44 AM
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.
0
Andrey
Telerik team
answered on 11 Apr 2012, 09:28 AM
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 >>

Tags
Map
Asked by
Curt
Top achievements
Rank 1
Iron
Answers by
Curt
Top achievements
Rank 1
Iron
Andrey
Telerik team
Share this question
or