1

I'm currently migrating a WPF app from .Net Framework to .Net Core (3.1). This application currently uses the MapControl from the Microsoft.Maps.MapControl.WPF assembly. The goal is to migrate this control to a UWP MapControl from the Microsoft.Toolkit.Wpf.UI.Controls assembly. One of the requirements, is the ability to draw Routes/Polylines on the map.

Following Microsoft's documentation (present in https://learn.microsoft.com/en-us/windows/uwp/maps-and-location/display-poi) I was able to draw lines on the map. However, the end result is not as desired (visually): the lines appear pixelated, as seen in the image bellow:

Current Result

How can I give a smooth look to this lines? Is there any way to apply anti-aliasing to them? After an extensive search online I was not able to find any function or property that allows for smooth rendering of this elements. What can I do to achieve this?

EDIT:

The .Net Framework way (using Microsoft.Maps.MapControl.WPF) of creating the MapPolyLine:

            MapPolyline routeLine = new MapPolyline();
            routeLine.Locations = myLocationCollection;
            routeLine.Stroke = MY_COLOR;
            routeLine.StrokeThickness = 5.0;
            routeLine.StrokeLineJoin = PenLineJoin.Round;

The .Net Core way (using Microsoft.Toolkit.Wpf.UI.Controls) of creating the MapPolyLine:

        var myPolyLine = new MapPolyline
        {
            Path = myPath,
            FillColor = MY_COLOR,
            StrokeColor = MY_STROKE_COLOR,
            StrokeThickness = 6,
            ZIndex = 1
        };

        myMap.MapElements.Add(myPolyLine);
whatthe
  • 11
  • 2
  • Could you mind share how to draw the line on the map currently ? – Nico Zhu May 20 '21 at 03:17
  • Do you mean using the Microsoft.Maps.MapControl.WPF's MapControl? I'm not sure I can post the actual code, I will get back to you on that, but it uses the MapPolyLine class from Microsoft.Maps.MapControl.WPF. It is basically the same code as the example given in the link of my question, but using the "old" assembly. – whatthe May 20 '21 at 07:58
  • If you are using MapPolyLine to draw map route, I'm afraid you can't edit the appearance of the line. – Nico Zhu May 20 '21 at 07:59
  • I find this odd since the MapPolyLine from the Microsoft.Maps.MapControl.WPF assembly does not have the visual issue seen in the pictures, it only exists in the new assembly (Microsoft.Toolkit.Wpf.UI.Controls). Do you know if there exists any alternative to draw a polyline on the map, that gives me better control of the graphics? Maybe using XAML? Thanks for the help btw. – whatthe May 20 '21 at 08:08
  • Could you mind share how to generate MapPolyLine instance ? – Nico Zhu May 20 '21 at 08:15
  • For the example seen in the image, the path (List) has 4340 entries. – whatthe May 20 '21 at 08:16
  • Have you tried set StrokeThickness of mapPolyline with a bigger value? – Nico Zhu May 20 '21 at 08:21
  • or try to remove one half of BasicGeopositions? – Nico Zhu May 20 '21 at 08:22
  • Yes, I tried both and the visual aspect of the line is still pixelated. – whatthe May 20 '21 at 08:24
  • I edited the question to show how the lines are being drawn in both aproaches. – whatthe May 20 '21 at 08:30
  • Even the MapPolyLine present in the MapControlSample (https://learn.microsoft.com/pt-pt/samples/microsoft/windows-universal-samples/mapcontrol/) is pixelated. Was the MapControl downgraded, when it comes to visual aspects? The old MapControl's MapPolyLine had more properties for visual customization (Such as Effect and StrokeLineJoin). – whatthe May 20 '21 at 08:35

0 Answers0