Home > Back-end >  UWP Mapcontrol show distance ruler
UWP Mapcontrol show distance ruler

Time:05-20

I'm building an UWP application and uses the "Windows.UI.Xaml.Controls.Maps.MapControl" from MS.

I would like to show some sort of "ruler" somewhere in the map that gives the user an idea of distance, like in the Bing maps screepclip below:

enter image description here

Any ideas how to achieve this in an UWP app that uses MapControl??

CodePudding user response:

You can use the TryGetLocationFromOffset API https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.maps.mapcontrol.trygetlocationfromoffset?view=winrt-22000 for a couple of screen points to get the lat/long, then use the haversine formula to calculate the great circle distance between the two lat/long https://en.wikipedia.org/wiki/Haversine_formula

  • Related