C# - 无法使用 Bing 地图显示 MapControl
C# - Cannot display MapControl using Bing Map
我有一个如下所示的控件文件夹:
XAML:
<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可以显示地图(我根据应用的名字使用了不同的key)
I'm having trouble, ie can not display folder (only white pages only). How to handle it?
好像MapControl没有默认的Width
和Height
,推荐的方法是不设置任何属性(例如Height
, Margin
等等)让它适合父容器。并且将显示地图。比如你的地图位于Grid的一行,你可以这样定义地图:
<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>
不推荐的原因是不设置Height
和Width
地图可以适配不同的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" />
I want to ask for a free bing developer license, is there a limit on the number of applications that can use big map?
Bing 如果您为每个应用程序使用不同的密钥,地图不应该限制应用程序的数量。但是您在使用这些密钥时可能会遇到收费 API。
我有一个如下所示的控件文件夹: XAML:
<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可以显示地图(我根据应用的名字使用了不同的key)
I'm having trouble, ie can not display folder (only white pages only). How to handle it?
好像MapControl没有默认的Width
和Height
,推荐的方法是不设置任何属性(例如Height
, Margin
等等)让它适合父容器。并且将显示地图。比如你的地图位于Grid的一行,你可以这样定义地图:
<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>
不推荐的原因是不设置Height
和Width
地图可以适配不同的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" />
I want to ask for a free bing developer license, is there a limit on the number of applications that can use big map?
Bing 如果您为每个应用程序使用不同的密钥,地图不应该限制应用程序的数量。但是您在使用这些密钥时可能会遇到收费 API。