Share via


Map Class

This documentation is no longer available on MSDN, however it is available as a CHM download.

Represents the default map class.

Namespace: Microsoft.Maps.MapControl
Assembly: Microsoft.Maps.MapControl (in Microsoft.Maps.MapControl.dll)

Usage

Syntax

'Declaration
Public Class Map
    Inherits MapCore
public class Map : MapCore
public ref class Map : public MapCore
public class Map extends MapCore
public class Map extends MapCore

Example

The following example adds four maps with different modes to a Grid called LayoutRoot. This example uses C# code instead of XAML.

<UserControl x:Class="SilverlightTest1.ShowMultipleMaps"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    Width="1024" Height="768">
    <Grid x:Name="LayoutRoot" Background="White">
    </Grid>
</UserControl>
    
using System.Windows;
using System.Windows.Controls;
using Microsoft.Maps.MapControl;

namespace SilverlightTest1
{
    public partial class ShowMultipleMaps : UserControl
    {
        public ShowMultipleMaps()
        {
            InitializeComponent();

            //Loads 2 maps side by side
            initializeMaps();
        }
        
        private void initializeMaps()
        {
            //Create a 2x2 grid
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            LayoutRoot.RowDefinitions.Add(new RowDefinition());
        

            //Add Road view map
            Map leftMap = new Map();
            leftMap.Mode = new RoadMode();
            Grid.SetColumn(leftMap, 0);
            Grid.SetRow(leftMap, 0);
            leftMap.CredentialsProvider = New ApplicationIdCredentialsProvider("Your Key");
            LayoutRoot.Children.Add(leftMap);

            //Add Aerial view map
            Map rightMap = new Map();
            rightMap.Mode = new AerialMode();
            Grid.SetColumn(rightMap, 1);
            Grid.SetRow(rightMap, 0);
            rightMap.CredentialsProvider = New ApplicationIdCredentialsProvider("Your Key");
            LayoutRoot.Children.Add(rightMap);

        }
    }
}
    

Imports Microsoft.Maps.MapControl


    Partial Public Class ShowMultipleMaps
        Inherits UserControl
        Public Sub New()
            InitializeComponent()

            'Loads 2 maps side by side
            initializeMaps()
        End Sub

        Private Sub initializeMaps()
            'Create a 1x2 grid
            LayoutRoot.ColumnDefinitions.Add(New ColumnDefinition())
            LayoutRoot.ColumnDefinitions.Add(New ColumnDefinition())
            LayoutRoot.RowDefinitions.Add(New RowDefinition())

            'Add Road view map
            Dim leftMap As New Map() With {.Mode = New RoadMode()}
            Grid.SetColumn(leftMap, 0)
            Grid.SetRow(leftMap, 0)
                        leftMap.CredentialsProvider = New ApplicationIdCredentialsProvider("Your Key")
            LayoutRoot.Children.Add(leftMap)

            'Add Aerial view map
            Dim rightMap As New Map() With {.Mode = New AerialMode()}
            Grid.SetColumn(rightMap, 1)
            Grid.SetRow(rightMap, 0)
                        rightMap.CredentialsProvider = New ApplicationIdCredentialsProvider("Your Key")
            LayoutRoot.Children.Add(rightMap)


        End Sub
    End Class

    
 

Inheritance Hierarchy

System.Object
   System.Windows.DependencyObject
     System.Windows.UIElement
       System.Windows.FrameworkElement
         System.Windows.Controls.Control
           System.Windows.Controls.UserControl
             Microsoft.Maps.MapControl.Core.MapBase
               Microsoft.Maps.MapControl.Core.MapCore
                Microsoft.Maps.MapControl.Map

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Target Platforms

Change History

See Also

Reference

Map Members
Microsoft.Maps.MapControl Namespace

Other Resources

Creating a Basic Application Using the Silverlight Map Control
Navigating Between Map Views