是否有适用于Winforms(或其类似物)的Geopoint类? [英] Is there a Geopoint class available for Winforms (or an Analogue thereof)?
问题描述
在我的UWP应用中,我使用Geopoint类:
使用Windows.Devices.Geolocation;...List< Geopoint>位置;
在Winforms应用程序中,此功能不可用-无法识别Geopoint.Winforms应用程序有类似的类吗?
BasicGeoposition 对象也是如此-无法识别.
更新
我想要GeoPoint和BasicGeoposition类,以便可以执行以下操作:
BasicGeoposition location =新的BasicGeoposition();location.Latitude = 36.59894360222391;//蒙特雷== 36.6002°Nlocation.Longitude = -121.8616426604813;//蒙特雷== 121.8947°W(西为负)Geopoint geop =新的Geopoint(位置);等待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(混淆了Bing Maps的键):
< 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-命名空间:Microsoft.Maps.MapControl.WPF; assembly = Microsoft.Maps.MapControl.WPF".<网格>< m:Map CredentialsProvider ="Gr8GooglyMoogly";x:Name =" myMap" ;;/></Grid></UserControl>
设置
更多信息:
您可能希望查看以下链接以获取更多信息:
To set the view of the Bing Maps WPF control, you can use SetView
method. The method have different overloads, for example you can pass a Location
(which you create based on the latitude and longitude of your desired location) and a zoom-level to the method like this:
var location = new Location(47.604, -122.329);
this.userControl11.myMap.SetView(location, 12);
Same can be achieved by setting Center
and ZoomLevel
.
Download or Clone the example
You can download or close the working example from here:
- Clone r-aghaei/WinFormsWpfBingMaps
- Download master.zip
Step by Step Example - Zoom into Seattle as initial view
Follow instructions in this post to create a Windows Forms project which uses WPF Bing Maps Control.
Handle the Load event of the
Form
and use the following code:private void Form1_Load(object sender, EventArgs e) { this.userControl11.myMap.AnimationLevel = AnimationLevel.Full; this.userControl11.myMap.Loaded += MyMap_Loaded; } private void MyMap_Loaded(object sender, System.Windows.RoutedEventArgs e) { var location = new Location(47.604, -122.329); this.userControl11.myMap.SetView(location, 12); }
Make sure you use
using Microsoft.Maps.MapControl.WPF;
.
As a result, the map zooms in Seattle as center location:
More information:
You may want to take a look at the following links for more information:
- How can I add a Bing Maps Component to my C# Winforms app?
- Bing Maps WPF Control
- Developing with the Bing Maps WPF Control
- Bing Maps WPF Control API Reference
这篇关于是否有适用于Winforms(或其类似物)的Geopoint类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!