Export (0) Print
Expand All

Understanding Map Views

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

When working with the Bing Maps Silverlight Control, the first thing your users will likely do is to try to change the map view using an input device or the navigation control.

By default the Silverlight map control animates all movements, which means that map view changes are smooth. However, you can use the AnimationLevel property of the map to set the behavior of view changes. The available animation settings are found in the AnimationLevel enumeration. Fully animated view changes are the default. If the animation level is set to None, then the map snaps to a new view instead of animating the view change.

A new map view is defined any time the position of the map is changed by panning, zooming, rotating, or tilting. The SetView method is used to define a map view, which can include the center point of the view, zoom level, heading, and pitch.

  • Center: This property represents the center point of a map view and is defined by a Location coordinate.

  • Zoom Level: This property represents different levels of detail available on the map. The maximum level of available detail is determined by the location you are zooming into; some areas can be zoomed in further than other areas. Higher zoom levels represent more zoomed in views of the map, while a zoom level of 1 is the most zoomed out view of the entire world.

  • Heading: This property specifies the directional heading that is pointing “up” on the map. It is represented by a value between 0 and 360, indicating the number of degrees to rotate the map. For example, if the heading was changed from 0 to 180, the map is rotated 180 degrees and the resulting map has South facing “up” on the map instead of North. The diagram below illustrates heading.

  • Pitch: This property specifies the “look direction” of the map. It is represented by a value between -90 and 90, indicating the number of degrees to tilt the map. The diagram below illustrates pitch.


The following example navigates to different locations on the map by clicking a button. This is a simple example that demonstrates how the Bing Maps Silverlight Control animates between different map views. It navigates between these locations: Vancouver, Canada, New York, Los Angeles and North America. As the map moves from location to location, the center point of the current frame’s map view is updated in the Latitude and Longitude text boxes.


A Map View

<UserControl x:Class="SilverlightTest1.SwitchMapViews"
    Width="1024" Height="768">
    <Grid x:Name="LayoutRoot" Background="White">
            <RowDefinition Height="*" />
            <RowDefinition Height="40" />
      <RowDefinition Height="20" />
        <m:Map x:Name="viewMap" CredentialsProvider="your key" Mode="AerialWithLabels"  Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Padding="5"
               Center="39.3683,-95.2734,0.0000" ZoomLevel="4.000"/>
        <StackPanel Orientation="Horizontal" Opacity="0.7" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center">
            <Button x:Name="btnNorthAmerica" Click="ChangeMapView_Click" Tag="39.3683,-95.2734,0.0000 4.0000"
                <TextBlock>North America</TextBlock>
            <Button x:Name="btnNewYork" Click="ChangeMapView_Click" Tag="40.7199,-74.0030,0.0000 12.0000" Margin="5">
                <TextBlock>New York</TextBlock>
            <Button x:Name="btnSanFrancisco" Click="ChangeMapView_Click" Tag="37.6801,-122.3395,0.0000 11.0000" Margin="5">
                <TextBlock>San Francisco</TextBlock>
            <Button x:Name="btnVancouver" Click="ChangeMapView_Click" Tag="49.2765,-123.1030,0.0000 14.0000" Margin="5">
        <StackPanel Orientation="Horizontal" Opacity="0.9" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center">
            <TextBlock Text="Latitude: " Padding="5" Foreground="White"/>
            <TextBox x:Name="txtLatitude" Text="" IsReadOnly="True" Background="LightGray"/>
            <TextBlock Text="Longitude: " Padding="5" Foreground="White" />
            <TextBox x:Name="txtLongitude" Text="" IsReadOnly="True" Background="LightGray"/>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Globalization;
using Microsoft.Maps.MapControl;
using Microsoft.Maps.MapControl.Design;

namespace SilverlightTest1
    public partial class SwitchMapViews : UserControl
        LocationConverter locConverter = new LocationConverter();
        public SwitchMapViews()

            // Displays the current latitude and longitude as the map animates.
            viewMap.ViewChangeOnFrame += new EventHandler<MapEventArgs>(viewMap_ViewChangeOnFrame);
            // The default animation level: navigate between different map locations.
            viewMap.AnimationLevel = AnimationLevel.Full;

        private void viewMap_ViewChangeOnFrame(object sender, MapEventArgs e)
            // Gets the map object that raised this event.
            Map map = sender as Map;
            // Determine if we have a valid map object.
            if (map != null)
                // Gets the center of the current map view for this particular frame.
                Location mapCenter = map.Center;

                // Updates the latitude and longitude values, in real time,
                // as the map animates to the new location.
                txtLatitude.Text = string.Format(CultureInfo.InvariantCulture, 
                    "{0:F5}", mapCenter.Latitude);
                txtLongitude.Text = string.Format(CultureInfo.InvariantCulture, 
                    "{0:F5}", mapCenter.Longitude);

        private void ChangeMapView_Click(object sender, RoutedEventArgs e)
            // Parse the information of the button's Tag property
            string[] tagInfo = ((Button)sender).Tag.ToString().Split(' ');
            Location  center = (Location)locConverter.ConvertFrom(tagInfo[0]);
            double zoom = System.Convert.ToDouble(tagInfo[1]);
            // Set the map view
            viewMap.SetView(center, zoom);

© 2014 Microsoft