Cartographic Modes in Map Control of Windows Phone 8

The Map Control in the Windows Phone 8 supports 4 different Cartographic Modes like Aerial, Hybrid, Terrain, and Road.

What is Cartographic Mode?

The Cartographic Mode is a kind of 2D projection of the object. In the map control, it is the project of the map or the earth.

The Different Cartographic Modes will look like the below screenshot.

Cartographic Modes in Map Control of Windows Phone 8

Cartographic Modes in Map Control of Windows Phone 8

Cartographic Modes in Map Control of Windows Phone 8

The Cartographic Modes for a map control can be set via the CartographicMode property of the Map Control. It takes one of the 4 values

  • Microsoft.Phone.Maps.Controls.MapCartographicMode.Terrain
  • Microsoft.Phone.Maps.Controls.MapCartographicMode.Road
  • Microsoft.Phone.Maps.Controls.MapCartographicMode.Hybrid
  • Microsoft.Phone.Maps.Controls.MapCartographicMode.Aerial

Below is a sample code snippet demonstrating how to set the CartographicMode for a Map Control in windows phone 8.

XAML

<phone:PhoneApplicationPage

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

xmlns:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"

x:Class="MobileOSGeekMaps.MainPage"

mc:Ignorable="d"

FontFamily="{StaticResource PhoneFontFamilyNormal}"

FontSize="{StaticResource PhoneFontSizeNormal}"

Foreground="{StaticResource PhoneForegroundBrush}"

SupportedOrientations="Portrait" Orientation="Portrait"

shell:SystemTray.IsVisible="True">

<Grid x:Name="LayoutRoot" Background="Transparent">

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

<RowDefinition Height="*" />

</Grid.RowDefinitions>

<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

<TextBlock Text="@ISENTHIL" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0" />

<TextBlock Text="MOBILEOSGEEK" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="48" />

</StackPanel>

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

<maps:Map x:Name="Map1" ColorMode="Dark" HorizontalAlignment="Left" Height="563" Margin="0,44,0,0" VerticalAlignment="Top" Width="446" Loaded="Map1_Loaded" />

</Grid>

</Grid>

</phone:PhoneApplicationPage>

C# (Code Behind)

using Microsoft.Phone.Controls;

using Microsoft.Phone.Maps;

using Microsoft.Phone.Shell;

using MobileOSGeekMaps.Resources;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Navigation;

namespace MobileOSGeekMaps

{

public partial class MainPage : PhoneApplicationPage

{

// Constructor

public MainPage()

{

InitializeComponent();

Map1.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road;

}

private void Map1_Loaded(object sender, RoutedEventArgs e)

{

}

}

}

Leave a Reply