本文介绍了添加到图钉在地图控件UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一个图钉添加到Windows 10的应用程序将MapControl,但似乎因为Windows 8.1控制已经一去不复返了。
的
这是如此简单:
图钉locationPushpin =新图钉();
locationPushpin.Background =新的SolidColorBrush(Colors.Purple);
locationPushpin.Content =你在这里;
locationPushpin.Tag =locationPushpin;
locationPushpin.Location = watcher.Position.Location;
this.map.Children.Add(locationPushpin);
this.map.SetView(watcher.Position.Location,18.0);
但图钉型,不再被认可的。
解决方案
地图控件已经变化不大UWP - 看看的。
由于添加图钉(兴趣点),可以。例如:
//获取位置
的GeoPoint myPoint =新的GeoPoint(新BasicGeoposition (){纬度= 51,经度= 0});
//创建POI
MapIcon myPOI =新MapIcon {位置= myPoint,NormalizedAnchorPoint =新的点(0.5,1.0),标题=我的位置,zIndex的= 0};
//添加到地图和居中
myMap.MapElements.Add(myPOI);
myMap.Center = myPoint;
myMap.ZoomLevel = 10;
有关更多指引的。
I'd like to add a Pushpin to a MapControl in a Windows 10 app, but it seems the control is gone since Windows 8.1.
It was as simple as that:
Pushpin locationPushpin = new Pushpin();
locationPushpin.Background = new SolidColorBrush(Colors.Purple);
locationPushpin.Content = "You are here";
locationPushpin.Tag = "locationPushpin";
locationPushpin.Location = watcher.Position.Location;
this.map.Children.Add(locationPushpin);
this.map.SetView(watcher.Position.Location, 18.0);
But Pushpin type is not recognized anymore...
解决方案
Map control has changed little in UWP - take a look at Windows.UI.Xaml.Controls.Maps namespace.
As for adding Pushpins (POIs), you can do it in couple of ways. For example:
// get position
Geopoint myPoint = new Geopoint(new BasicGeoposition() { Latitude = 51, Longitude = 0 });
//create POI
MapIcon myPOI = new MapIcon { Location = myPoint, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "My position", ZIndex = 0 };
// add to map and center it
myMap.MapElements.Add(myPOI);
myMap.Center = myPoint;
myMap.ZoomLevel = 10;
For more guidelines visit MSDN.
这篇关于添加到图钉在地图控件UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!