如何设置必应地图样式?

问题描述

我想根据我的 Winforms 应用中的用户选择(在空中、鸟瞰、道路和街边之间)设置地图样式。

我有这个代码

using Microsoft.Maps.MapControl.WPF;
. . .

private void aerialToolStripMenuItem_Click(object sender,EventArgs e)
{
    userControl11.myMap.Style = Microsoft.Maps.MapTypeId.aerial;
}

...它不会编译,因为它告诉我:

enter image description here

我的参考资料中有 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 属性,您需要为其分配一个新的 AerialMode 实例:

this.userControl11.myMap.Mode = new Microsoft.Maps.MapControl.WPF.AerialMode();

如果您希望它显示标签,请将 true 传递给 AerialMode 的构造函数。您可以在以下位置了解有关地图视图和模式的更多信息:Understanding Map Views

enter image description here