I'm trying to run a simple UWP application on my PC to test the Map Control, using the guidelines in:
I have obtained a map key from Bing Maps Dev Center and assigned it to the map control.
However, in the designer the control is shown up with a "This element is enabled only when the application is running" message.
When I run the application, nothing is displayed on the application screen.
To check if the map is loaded, I added a handler for the Loaded event of the map to display a message on the output pane, and the message was displayed fine.
public MainPage()
{
this.InitializeComponent();
MapMain.Loaded += MapMain_Loaded;
}
private void MapMain_Loaded(object sender, RoutedEventArgs e)
{
Debug.WriteLine("Map is loaded!");
}
Here is my XAML Code:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestMap"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps"
x:Class="TestMap.MainPage"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Maps:MapControl HorizontalAlignment="Left" Margin="404,86,0,0" VerticalAlignment="Top"
x:Name="MapMain"
MapServiceToken="<My Map Key Is Here!>"
ZoomInteractionMode="GestureAndControl"
TiltInteractionMode="GestureAndControl" CacheMode="BitmapCache" CanDrag="True"/>
</Grid>
</Page>
Any thoughts on what could be the issue and how it can be fixed? Thanks
<<< UPDATE (Jan 25 2017) >>>
I changed width and height attributes of the map as per answers by @Sunteen and @Aditya. However, I only see a blank map frame, as shown in the below picture. I only see the map background.
<<< UPDATE (Jan 27 2017) >>>
As per Aditya's suggestion, I added my XAML code below to including the changes I made:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestMap"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps"
x:Class="TestMap.MainPage"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Maps:MapControl HorizontalAlignment="Left" Margin="92,53,0,0" VerticalAlignment="Top"
x:Name="MapMain"
MapServiceToken="<<<My Map Key>>>"
Height="400"
Width="400"
ZoomInteractionMode="GestureAndControl"
TiltInteractionMode="GestureAndControl" Background="#FF3BCFCF" ZoomLevel="2"/>
</Grid>
</Page>