C# 如何在UWP中获取用户单击地图对象的坐标?

C# 如何在UWP中获取用户单击地图对象的坐标?,c#,xaml,uwp,gps,C#,Xaml,Uwp,Gps,我正在UWP中创建一个应用程序,它大量使用内置的MapControl对象来显示图标和图像。我在应用程序中的下一个功能将需要提取用户在地图上单击的位置的gps位置,以编辑地图图标的位置。因此,用户使用鼠标(或手指)点击地图上的某个位置,我需要触发一个点击事件,它知道点击的地理位置。我不知道应该研究哪种API 我知道这是可能的,Windows10附带的地图应用程序决定了你点击的任何位置的地址。如何实现类似的功能 模拟代码 xaml: 尝试使用获取用户在MapUserTapped事件中单击的位置。我已

我正在UWP中创建一个应用程序,它大量使用内置的MapControl对象来显示图标和图像。我在应用程序中的下一个功能将需要提取用户在地图上单击的位置的gps位置,以编辑地图图标的位置。因此,用户使用鼠标(或手指)点击地图上的某个位置,我需要触发一个点击事件,它知道点击的地理位置。我不知道应该研究哪种API

我知道这是可能的,Windows10附带的地图应用程序决定了你点击的任何位置的地址。如何实现类似的功能

模拟代码

xaml:


尝试使用获取用户在MapUserTapped事件中单击的位置。

我已经找到了答案。似乎我只是需要对MapTapped事件及其提供的参数进行一些挖掘。代码非常简单,如下所示

private void MapUserTapped(MapControl sender, MapInputEventArgs args)
{
    if (!edit_mode) { return; }

    //to get a basicgeoposition of wherever the user clicks on the map
    BasicGeoposition basgeo_edit_position = args.Location.Position;

    //just checking to make sure it works
    Debug.WriteLine("tapped - lat: " + basgeo_edit_position.Latitude.ToString() + "  lon: " + basgeo_edit_position.Longitude.ToString());

    EditMapIconPosition(basgeo_edit_position);
}

这不就是应用程序中光标的像素位置吗?我想要地图上对应的gps位置。
private void MapUserTapped(MapControl sender, MapInputEventArgs args)
{
    if (!edit_mode) { return; }

    //no idea how to do this part, are there any api's for this?
    Geoposition geopos_edit_position = map_main.TapLocation;

    EditMapIconPosition(geopos_edit_position);
}

private void EditMapIconPosition(Geoposition geopos_edit_position)
{
    ...
}
private void MapUserTapped(MapControl sender, MapInputEventArgs args)
{
    if (!edit_mode) { return; }

    //to get a basicgeoposition of wherever the user clicks on the map
    BasicGeoposition basgeo_edit_position = args.Location.Position;

    //just checking to make sure it works
    Debug.WriteLine("tapped - lat: " + basgeo_edit_position.Latitude.ToString() + "  lon: " + basgeo_edit_position.Longitude.ToString());

    EditMapIconPosition(basgeo_edit_position);
}