MindFusion.Wpf Pack Programmer's Guide
Map Layers

The MapView control can display several map and decoration layers. In order to add a new layer, create a MapLayer or DecorationLayer instance and add it to the Layers collection of the view. Assigning a map to the BaseMap property is a shortcut to creating a MapLayer, setting it as the first layer in the view and setting its Map property to the specified value.

Visibility of individual layers can be set through their Visible property. In addition, you can turn on or off interactive selection and highlighting in a layer by setting the EnableHighlight and EnableSelection properties. Even if interactive support is disabled, map elements can still be selected or highlighted programmatically by calling the Select or Highlight methods of the Layer class.

The following excerpt from the Layers sample project shows how to add several map layers displaying different maps:

C#  Copy Code

// load base map
var layer0 = new MapLayer();
layer0.Visible = true;
layer0.Map = new Map();
layer0.Map.LoadFromFile(FindMap("ne_50m_admin_0_countries.shp"));

mapView.Layers.Add(layer0);

// load urban areas map
var layer1 = new MapLayer();
layer1.Visible = false;
layer1.LineColor = Color.Yellow;
layer1.FillColors[0] = Color.Yellow;
layer1.Map = new Map();
layer1.Map.LoadFromFile(FindMap("ne_50m_urban_areas.shp"));

mapView.Layers.Add(layer1);

// load rivers map
var layer2 = new MapLayer();
layer2.Visible = false;
layer2.LineColor = Color.Blue;
layer2.Map = new Map();
layer2.Map.LoadFromFile(FindMap("50m_rivers_lake_centerlines.shp"));

mapView.Layers.Add(layer2);

Visual Basic  Copy Code

' load base map
Dim layer0 As New MapLayer()
layer0.Visible = True
layer0.Map = New Map()
layer0.Map.LoadFromFile(FindMap("ne_50m_admin_0_countries.shp"))

mapView.Layers.Add(layer0)

' load urban areas map
Dim layer1 As New MapLayer()
layer1.Visible = False
layer1.LineColor = Color.Yellow
layer1.FillColors(0) = Color.Yellow
layer1.Map = New Map()
layer1.Map.LoadFromFile(FindMap("ne_50m_urban_areas.shp"))

mapView.Layers.Add(layer1)

' load rivers map
Dim layer2 As New MapLayer()
layer2.Visible = False
layer2.LineColor = Color.Blue
layer2.Map = New Map()
layer2.Map.LoadFromFile(FindMap("50m_rivers_lake_centerlines.shp"))

mapView.Layers.Add(layer2)