WP8 Emulator is not displaying contents of map

1k Views Asked by At

i am developing a windows phone 8 app, i have placed a map control on the xaml page, while running it in emulator only a blue square box displays in place of map.

Output screen : https://docs.google.com/file/d/0By0Y-Dca1cKjVG1QQUY3MVBQcFk/edit?usp=sharing

MainPage.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="MapTestApp.MainPage"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <!--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 Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="Bing Map" 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">
            <maps:Map />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>

MainPage.xaml.cs

public MainPage()
        {
            InitializeComponent();

            Map MyMap = new Map();
            MyMap.Center = new GeoCoordinate(47.6097, -122.3331);
            MyMap.ZoomLevel = 3;
            MyMap.LandmarksEnabled = true;
            MyMap.PedestrianFeaturesEnabled = true;
            MyMap.CartographicMode = MapCartographicMode.Aerial;
            ContentPanel.Children.Add(MyMap);
        }
3

There are 3 best solutions below

3
On

You haven't added capabilities.

Go to WMAppManifest - Capabilities and Check:

ID_CAP_LOCATION ID_CAP_MAP

1
On

Your code is correct. This is probably caused because the emulator doesn't have network connection. You can check your emulator's network connection by opening a web browser on it and navigating to a page.

If your emulator doesn't have network connection, it can be because of different causes. You may find following documentation on MSDM helpful:

Troubleshooting the Windows Phone 8 Emulator

I have tried your code on a real device with network connection and it appears to work correctly. This is what I see:

enter image description here

0
On

Try to set the map zoom level, it might happen that it is showing you the oceans.

Also check the manifest if you have granted Internet access capability and Positioning capabilities.