【发布时间】:2020-12-28 16:53:42
【问题描述】:
在我的 UWP 应用中,我使用 Geopoint 类:
using Windows.Devices.Geolocation;
. . .
List<Geopoint> locations;
在 Winforms 应用程序中,此功能不可用 - 无法识别 Geopoint。是否有可用于 Winforms 应用程序的类似类?
BasicGeoposition 对象也是如此 - 无法识别。
更新
我想要 GeoPoint 和 BasicGeoposition 类,所以我可以这样做:
BasicGeoposition location = new BasicGeoposition();
location.Latitude = 36.59894360222391; // Monterey == 36.6002° N
location.Longitude = -121.8616426604813; // Monterey == 121.8947° W (West is negative)
Geopoint geop = new Geopoint(location);
await map.TrySetSceneAsync(MapScene.CreateFromLocation(geop));
cmbxZoomLevels.SelectedIndex = Convert.ToInt32(map.ZoomLevel - 1);
map.Style = MapStyle.Aerial3DWithRoads;
更新 2
我尝试了答案中提供的代码:
this.UserControl1.myMap.AnimationLevel = AnimationLevel.Full;
this.userControl11.myMap.Loaded += MyMap_Loaded;
...但它不会编译。我没有 UserControl11(这是答案的代码所具有的),但我有一个 UserControl1,但无法识别:
这是有问题的 XAML(必应地图密钥已混淆):
<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>
【问题讨论】:
-
类似的课程对你有用吗?虽然创建一个具有相似类型的 properties 的类非常简单,但我不确定它是否有很大帮助。您的确切要求/问题是什么? (另外请指定 .NET 版本、操作系统,以及是否要使用 WPF 必应地图或 UWP 必应地图)
-
WPF Map 没有
TrySetSceneAsync方法。你可以看看它的方法here。TrySetSceneAsync属于 Windows Community Toolkit Map Control。 -
您是否可以选择使用 Windows Community ToolKit Map Control?
-
酷,所以你现在有了一个可行的解决方案。 WPF Bing Maps 已经足够好了,我只是问一下你要使用哪一个,看看我是否可以帮助解决这个问题。
-
你试过
SetVeiw或者设置Center和ZoomLevel吗?
标签: winforms bing-maps geopoints uwp-maps