Magnus Jansson
Magnus Jansson

Reputation: 23

UWP Mapcontrol show distance ruler

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??

Upvotes: 0

Views: 61

Answers (1)

Duncan Lawler
Duncan Lawler

Reputation: 1772

You can use the TryGetLocationFromOffset API https://learn.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

Upvotes: 0

Related Questions