2017-08-31 33 views
0

显示地图控件我有一个控制文件夹,如下图所示: XAML:C# - 不能使用Bing地图

<Maps:MapControl x:Name="MapControl" Grid.Row="5" Grid.ColumnSpan="2" Margin="20,10,15,15" Visibility="Visible" 
            Height="200" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1"/> 

代码:

MapControl.MapServiceToken = "MyMapToken"; 
         ListingClass listing = new ListingClass(); 
         listing.Latitude = Double.Parse("-7.78183620", CultureInfo.InvariantCulture); 
         listing.Longitude = Double.Parse("110.40856360", CultureInfo.InvariantCulture); 

         // Specify a known location. 
         BasicGeoposition snPosition = new BasicGeoposition() { Latitude = listing.Latitude, Longitude = listing.Longitude }; 
         Geopoint snPoint = new Geopoint(snPosition); 

         // Create a MapIcon. 
         MapIcon mapIcon1 = new MapIcon(); 
         mapIcon1.Image = 
          RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///images/map-pin-red-md1.png")); 
         mapIcon1.Location = snPoint; 
         mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0); 
         mapIcon1.Title = pageTitle.Text; 
         mapIcon1.ZIndex = 0; 

         // Add the MapIcon to the map. 
         MapControl.MapElements.Add(mapIcon1); 

         // Center the map over the POI. 
         MapControl.Center = snPoint; 
         MapControl.ZoomLevel = 14; 
         MapControl.LandmarksVisible = true; 

我有麻烦,即无法显示文件夹(只有白页)。如何处理它?

我想问一个免费的bing开发者许可证,可以使用大地图的应用程序数量是否有限制? 因为在之前的应用程序中可以显示bing map(我根据应用程序的名称使用不同的键)。

回答

0

我遇到了麻烦,即无法显示文件夹(仅限白页)。如何处理它?

这似乎是MapControl没有默认WidthHeight,该建议的方式是不设置任何属性(例如,HeightMargin等),以让它适应父容器。地图将显示。例如,地图位于格一行,你可以定义地图状如下:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="*"/> 
    <RowDefinition Height="*"/> 
    <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <maps:MapControl x:Name="MapControl" Grid.Row="1" Grid.ColumnSpan="2" BorderBrush="Black" BorderThickness="1"/> 
</Grid> 

不推荐是因为没有设置HeightWidth地图可以好心自适应不同UWP设备的原因。如果您确实想要设置height属性,要显示地图,则可能需要设置width属性或HorizontalAlignment="Stretch"以指示宽度。例如:

<maps:MapControl x:Name="MapControl" Height="200" HorizontalAlignment="Stretch" BorderBrush="Black" BorderThickness="1" Grid.Row="1" Grid.ColumnSpan="2"/> 
<maps:MapControl x:Name="MapControl" Height="200" Width="200" BorderBrush="Black" BorderThickness="1"Grid.Row="1" Grid.ColumnSpan="2" /> 

我想问一个免费的冰开发许可证,有没有对可以使用大地图的应用程序的数量是否有限制?

如果您对每个应用程序使用不同的密钥,Bing地图不应限制应用程序数量。但是,当您使用这些密钥时,您可能会遇到可计费的API。