Click here to Skip to main content
15,887,746 members
Articles / Mobile Apps / Windows Phone 7

Bing Maps in Windows Phone

Rate me:
Please Sign up or sign in to vote.
3.60/5 (6 votes)
9 Nov 2012CPOL1 min read 39.2K   1.5K   7  
Using Bing Maps in Windows Phone 7
<phone:PhoneApplicationPage 
    x:Class="BingMapsDemoV1.MainPage"
    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"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="Bing Maps Demo" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Bing Maps" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <my:Map Mode="AerialWithLabels" Height="543" HorizontalAlignment="Left" Name="map1" VerticalAlignment="Top" Width="480" Margin="-12,0,0,0" />
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity="0.9">
            <shell:ApplicationBarIconButton IconUri="/Icons/plus.png" Text="Zoom In" Click="zoomIn_click"/>
            <shell:ApplicationBarIconButton IconUri="/Icons/minus.png" Text="Zoom out" Click="zoomOut_click"/>
            <shell:ApplicationBarIconButton IconUri="/Icons/A.png" Text="Aerial mode" Click="Aerial_click"/>
            <shell:ApplicationBarIconButton IconUri="/Icons/R.png" Text="Road mode" Click="Road_click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Choose my position" Click="chooseMyPosition_click"/>
                <shell:ApplicationBarMenuItem Text="Locate Me" Click="locateMe_click"/>
                <shell:ApplicationBarMenuItem Text="Set Pushpin" Click="setPin_click"/>
                <shell:ApplicationBarMenuItem Text="Add Pushpin" Click="addPin_click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Microsoft
Tunisia Tunisia
I'm a Software Engineer and MVP (Client Development). I like writing articles and developing open source software in C#, Windows Phone and Windows 8 applications droidcon.tn/speakers.php.
http://houssemdellai.net

Comments and Discussions