【发布时间】:2018-05-17 15:27:51
【问题描述】:
我正在尝试根据其地理点放置图像。但是,图像不会显示在地图上。我想确保当我们放大/缩小地图时,图像将保持原位并根据其固定坐标调整其大小。我还必须在 xaml 页面中插入图像吗?目前我只是在cs页面上添加图片。
谁能告诉我如何解决这个问题? MapView 在这段代码中就是 MapControl。
namespace HelpMe
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
addImage();
}
//adding image
public void addImage()
{
Image img = new Image();
img.Height = 100;
img.Width = 100;
img.Source = new BitmapImage(new Uri("ms-appx:///Assets/Unknown.jpg"));
img.RenderTransform = new CompositeTransform() { Rotation = 0 };
MapControl.SetNormalizedAnchorPoint(img, new Point(0.5, 0.5));
MapControl.SetLocation(img, new Geopoint(new BasicGeoposition() { Latitude = 0, Longitude = 0, Altitude = 0 }));
MapView.Children.Add(img);
}
}
}
【问题讨论】:
-
您的问题解决了吗?看来您的代码也可以正常工作。另外,你也可以关注docs.microsoft.com/en-us/windows/uwp/maps-and-location/…。
标签: c# uwp geolocation uwp-maps