Showing posts with label Bing map on windows phone. Show all posts
Showing posts with label Bing map on windows phone. Show all posts

Thursday, January 19, 2012

Working with Pushpins in the Map Control


To add a basic pushpin, create the pushpin object and add it as a child to the map. The following example allows the user to push a button that adds a pushpin to the center of the current map view.
<phone:PhoneApplicationPage 
    x:Class="WindowsPhoneApplication1.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">

    <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 x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <my:Map Height="427" HorizontalAlignment="Left" Margin="12,6,0,0" Name="map1" VerticalAlignment="Top" Width="438" />            
            <Button Content="Add Center Pushpin" Height="72" HorizontalAlignment="Left" Margin="90,467,0,0" Name="button1" VerticalAlignment="Top" Width="297" Click="button1_Click" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>

Use the Bing Maps Silverlight Control for Windows Phone(Source MSDN)

  1. Make sure you have downloaded and installed the Windows Phone SDK from the App Hub.
  2. Launch Visual Studio 2010 Express for Windows Phone from the Windows Start menu.
  3. Create a new project by clicking the File | New Project menu command.
  4. The New Project window will be displayed. Expand the Visual C# templates, and then select the Silverlight for Windows Phone templates.
  5. Select the Windows Phone Application template. Fill in the project Name as desired.
  6. Click OK. A new project will be created and MainPage.xaml will be opened in the Visual Studio designer window.
The next step is to lay out the controls of the application using the Visual Studio designer. After adding the controls, the final layout will look similar to the following screenshot:
MapLayout

To add the controls of the application


Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...