如何设置 Bing 地图样式?
How can I set the Bing Map style?
我想在我的 Winforms 应用程序中根据用户选择(在航拍、鸟瞰图、道路和街边之间)设置地图样式。
我有这个代码:
using Microsoft.Maps.MapControl.WPF;
. . .
private void aerialToolStripMenuItem_Click(object sender, EventArgs e)
{
userControl11.myMap.Style = Microsoft.Maps.MapTypeId.aerial;
}
...无法编译,因为它告诉我:
我的参考文献中确实有 Microsoft.Maps.MapControl.WPF。
此外,当我尝试此代码时:
this.userControl11.myMap.Style = Microsoft.Maps.MapControl.WPF.AerialMode;
...我得到,“AerialMode 是一种类型,在给定的上下文中无效”
顺便说一句,我有这个用于渲染地图控件:
<UserControl x:Class="MyMaps.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF">
<Grid>
<m:Map CredentialsProvider="gr8GooglyMoogly" x:Name="myMap" />
</Grid>
</UserControl>
更新
根据回答和评论,我现在成功地将它们用于三种可用的“模式”:
this.userControl11.myMap.Mode = new AerialMode(); // Aerial
this.userControl11.myMap.Mode = new AerialMode(true); // Aerial with Labels
this.userControl11.myMap.Mode = new RoadMode(); // Road
您正在寻找Mode property and you need to assign a new instance of AerialMode给它:
this.userControl11.myMap.Mode = new Microsoft.Maps.MapControl.WPF.AerialMode();
如果您希望它显示标签,请将 true
传递给 AerialMode
的构造函数。您可以在以下位置了解有关地图视图和模式的更多信息:Understanding Map Views.
我想在我的 Winforms 应用程序中根据用户选择(在航拍、鸟瞰图、道路和街边之间)设置地图样式。
我有这个代码:
using Microsoft.Maps.MapControl.WPF;
. . .
private void aerialToolStripMenuItem_Click(object sender, EventArgs e)
{
userControl11.myMap.Style = Microsoft.Maps.MapTypeId.aerial;
}
...无法编译,因为它告诉我:
我的参考文献中确实有 Microsoft.Maps.MapControl.WPF。
此外,当我尝试此代码时:
this.userControl11.myMap.Style = Microsoft.Maps.MapControl.WPF.AerialMode;
...我得到,“AerialMode 是一种类型,在给定的上下文中无效”
顺便说一句,我有这个用于渲染地图控件:
<UserControl x:Class="MyMaps.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF">
<Grid>
<m:Map CredentialsProvider="gr8GooglyMoogly" x:Name="myMap" />
</Grid>
</UserControl>
更新
根据回答和评论,我现在成功地将它们用于三种可用的“模式”:
this.userControl11.myMap.Mode = new AerialMode(); // Aerial
this.userControl11.myMap.Mode = new AerialMode(true); // Aerial with Labels
this.userControl11.myMap.Mode = new RoadMode(); // Road
您正在寻找Mode property and you need to assign a new instance of AerialMode给它:
this.userControl11.myMap.Mode = new Microsoft.Maps.MapControl.WPF.AerialMode();
如果您希望它显示标签,请将 true
传递给 AerialMode
的构造函数。您可以在以下位置了解有关地图视图和模式的更多信息:Understanding Map Views.