Skip to main content
A newer version of this page is available. .

MapSpline Class

Draws a spline on the map.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v20.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.

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 Providing Data 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;    
See Also