Search code examples
c#uwparcgisuwp-xamlarcgis-runtime-net

Arcgis UWP Obtain geolocation from pointerpressed event


I am new to working with the Arcgis Runtime SDK for UWP. I was wondering if anybody knewof a way to use the pointerpressed event handler to obtain the latitude and longitude coordinates of that click on the map.


Solution

  • Yup you can use the ScreenToLocation method:

    private void mapView_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        MapPoint location = mapView.ScreenToLocation(e.GetCurrentPoint(mapView).Position);
        Debug.WriteLine($"You pressed at {location.X} , {location.Y}");
    }