Search code examples
uwpbing-mapswindows-10-universaluwp-maps

What is the best way to draw a route as user traveled location using UWP Maps


I am working on UWP application and facing a challenge to draw a path on the map as user travel from source to destination location.

I have already plotted a route as per the given source to destination location now i want to draw a line as user travels from source to destination. What is the best way to draw a route on the Map.

I am using a latest windows 10 version 1803 (10.0; Build 17134) for the development.


Solution

  • Just add a MapPolyline to the map control see: https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.Maps.MapPolyline As the user position updates, update the .Path property of the polyline by adding the new points from the user's position. The map will be updated with the new path geometry.