Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    MapSpline Class

    Draws a spline on the map.

    Namespace: DevExpress.XtraMap

    Assembly: DevExpress.XtraMap.v25.1.dll

    NuGet Package: DevExpress.Win.Map

    #Declaration

    public class MapSpline :
        MapPolylineBase

    The following members return MapSpline objects:

    #Remarks

    The Map Control uses vector layers to display vector items such as map splines.

    The following image shows a spline that is plotted based on four geographical points.

    image

    #Create a Map Spline

    The following code creates a MapSpline and adds it to a vector layer’s item storage.

    using DevExpress.XtraMap;
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    //...
    private void Form1_Load(object sender, EventArgs e) {
    
        VectorItemsLayer itemLayer = new VectorItemsLayer();
        mapControl1.Layers.Add(itemLayer);            
    
        MapSpline mapSpline = new MapSpline();
        mapSpline.Points.AddRange ( new GeoPoint[] {
            new GeoPoint(64.1, -40.5),
            new GeoPoint(65.4, -33.8),
            new GeoPoint(64.5, -28.5),
            new GeoPoint(65.5, -24.5)
        });        
    
        MapItemStorage storage = new MapItemStorage();
        storage.Items.Add(mapSpline);            
    
        itemLayer.Data = storage;
        itemLayer.DataLoaded += OnItemLayerDataLoaded;            
    }
    
    private void OnItemLayerDataLoaded(object sender, DataLoadedEventArgs e) {
        // You can call the MapControl.ZoomToFitLayerItems method in the DataLoaded event handler
        // to zoom the map so that it displays all vector items according to their bounding box.
        mapControl1.ZoomToFitLayerItems(new LayerBase[] { mapControl1.Layers[1] });
    }
    

    You can add multiple MapSplines to a vector layer. For more information on how to load vector items to a map, see the Vector Items topic.

    #Customize Spline Appearance

    Use the following properties to specify spline color and style at normal, highlighted and selected states.

    State

    APIs

    Normal

    MapItem.Stroke, MapItem.StrokeWidth

    Highlighted

    MapItem.HighlightedStroke, MapItem.HighlightedStrokeWidth

    Selected

    MapItem.SelectedStroke, MapItem.StrokeWidth

    The following example shows how to create a red spline. When the spline is highlighted or selected, its color is changed to blue/black respectively.

    mapSpline.Stroke = Color.Red;
    mapSpline.StrokeWidth = 4;
    mapSpline.HighlightedStroke = Color.Blue;
    mapSpline.HighlightedStrokeWidth = 4;
    mapSpline.SelectedStroke = Color.Black;
    mapSpline.SelectedStrokeWidth = 4;    
    

    #Add Spline Caps

    You can display shapes at the beginning and at the end of splines. Use the StartLineCap and EndLineCap properties for this purpose.

    The following example specifies the end cap template and shows the default arrow for the spline start cap:

    Map Spline Caps

    MapSpline spline = new MapSpline() { StrokeWidth = 2, Stroke = System.Drawing.Color.Blue };
    spline.Points.AddRange(new GeoPoint[] { new GeoPoint(-6, -4),
                                            new GeoPoint(-3, -10),
                                            new GeoPoint(-6, -20) });
    
    spline.StartLineCap.Visible = true;
    spline.StartLineCap.Length = 20;
    spline.StartLineCap.Width = 10;
    
    spline.EndLineCap.Visible = true;
    spline.EndLineCap.Template = new MapUnit[] { new MapUnit(-0.5, 0),
                                                 new MapUnit(0, 0.5),
                                                 new MapUnit(0.5, 0),
                                                 new MapUnit(0, -0.5)};
    spline.EndLineCap.Length = 10;
    spline.EndLineCap.Width = 10;
    
    mapItemStorage1.Items.Add(spline);
    
    See Also