Skip to content

v6.0 Upgrade Guide

SkiaSharp compatibility

Mapsui is compiled against SkiaSharp 3.119.4. MAUI applications may resolve the supported SkiaSharp 4.151.2 release instead; this combination is covered by a packaged-consumer test, including native loading and the RichTextKit/HarfBuzz callout path. Keep explicit SkiaSharp, SkiaSharp.Views.*, SkiaSharp.HarfBuzz, and HarfBuzzSharp references on the same release train selected by the SkiaSharp release in such applications.

Avalonia 12.1 depends on SkiaSharp 3.119.4 but also supports SkiaSharp 4 when the application references it explicitly (see AvaloniaUI/Avalonia#21696). The Avalonia 12 samples run this way on SkiaSharp 4.151.2. Keep SkiaSharp.HarfBuzz, HarfBuzzSharp, and HarfBuzzSharp.NativeAssets.Linux on the matching release train; Avalonia still pulls in the 8.x Linux native asset, which does not match the 14.x managed HarfBuzzSharp.

On Windows, Avalonia 12.1's Vulkan rendering mode crashes with SkiaSharp 4 (an access violation in VulkanDevice.Create), while ANGLE works. If you use SkiaSharp 4, leave Win32RenderingMode.Vulkan out of Win32PlatformOptions.RenderingMode. Mapsui will target SkiaSharp 4 directly in Mapsui 5.4; see Coming in Mapsui 5.4.

Changes in Mapsui 5.3

Uno Platform 7

Mapsui.Uno.WinUI is built for Uno Platform 7 and requires Uno.Sdk 7.0.5 or later; Uno Platform 6 apps can't restore it, so they stay on Mapsui 5.2. Uno Platform 7 brings SkiaSharp 4.151.1, so keep explicit SkiaSharp.HarfBuzz and HarfBuzzSharp references on that release train.

Coming in Mapsui 5.4: SkiaSharp 4, and no more Avalonia 11 support

Mapsui 5.4 will move from SkiaSharp 3 to SkiaSharp 4. SkiaSharp 4 is where development now happens, and we want to use it.

Only one platform blocks this upgrade: Avalonia 11, which only works with SkiaSharp 3. All other platforms work with SkiaSharp 4, including Avalonia 12. So in 5.4 we will remove the Mapsui.Avalonia package (for Avalonia 11). Please use Mapsui.Avalonia12 instead. We will also remove Mapsui.Maui8, because .NET 8 is no longer supported.

We don't like making a change like this in a minor version. But waiting would keep all users on SkiaSharp 3 for about another year, because Avalonia only plans to require SkiaSharp 4 in Avalonia 13.

If you cannot move to Avalonia 12 yet, you can stay on Mapsui 5.3.

Questions or concerns? Please reply in this discussion.

By compile error

No compile errors are listed yet. This list will grow once v6 is released. If you run into a compile error while upgrading, please report it so we can add it here.

API added in Mapsui 5.1

These APIs were added in Mapsui 5.1, so they are already available before upgrading to v6. The callout alignment properties work with both renderers. LabelStyle.TextAlignment and Font.FontSource are only rendered by the experimental renderer.

LabelStyle.TextAlignment

A new TextAlignment property (type: Alignment) controls how text lines are aligned within the label box. This is separate from HorizontalAlignment, which positions the label box relative to the feature point.

new LabelStyle
{
    TextAlignment = Alignment.Right, // text content alignment within the box
    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center, // box position relative to point
}

Default: Alignment.Left. See also the Breaking changes in the experimental renderer section below.

CalloutStyle.TitleTextAlignment and CalloutStyle.SubtitleTextAlignment

New Alignment properties on CalloutStyle let you align title and subtitle text independently within the callout balloon. Both default to Alignment.Left.

new CalloutStyle
{
    TitleTextAlignment = Alignment.Right,
    SubtitleTextAlignment = Alignment.Center,
}

Font.FontSource

A new FontSource property on Font lets you load a custom typeface from a URI or embedded resource instead of relying on a system-installed font family.

new LabelStyle
{
    Font = new Font
    {
        FontSource = "embedded://MyAssembly.Fonts.NotoSansArabic.ttf",
        Size = 16
    }
}

The font bytes are fetched once per unique source and cached in RenderService.FontSourceCache for the lifetime of the map. See the FontSource documentation for details.

Note: Font.FontSource is only rendered by Mapsui.Experimental.Rendering.Skia. The standard renderer (Mapsui.Rendering.Skia) ignores it and falls back to the system font.

API added in Mapsui 5.2

This API was added in Mapsui 5.2, so it is already available before upgrading to v6.

MAUI backend selection

MAUI adds RenderBackend, MapControl.Backend, MapControl.ActiveBackend and a MapControl(RenderBackend) constructor. Existing UseGPU and parameterless-constructor code continues to work, with GPU still the default. Backend selection is fixed for each control at construction; changing a static setting affects future controls only. The Android navigation workaround now follows the instance's host rather than the current static setting. See rendering options for configuration and manual comparison.

Changed defaults

CalloutStyle.TitleFontColor and CalloutStyle.SubtitleFontColor

Both now default to Color.Black instead of null. A null font color is converted to a fully transparent color, so a callout that set Title but left TitleFontColor unset used to draw invisible text with no indication of why. The properties stay nullable, and the renderers now log a warning when text is set while its color is null.

If you relied on the old default to hide callout text, set the color explicitly to one with an alpha of zero:

new CalloutStyle
{
    Title = "Hidden",
    TitleFontColor = new Color(0, 0, 0, 0),
}

Animations are updated on the draw thread

Map.UpdateAnimations and Navigator.UpdateAnimations are now called by RenderController.Render, on the thread that draws, instead of on the render loop's background thread. A layer that overrides UpdateAnimations therefore runs it on the UI thread (on Android's GL surface: the GL thread). A redraw requested from inside UpdateAnimations is drawn in the same frame.

MyLocationLayer applies changes on the next frame

MyLocationLayer can now be updated from any thread, for example directly from a GPS callback. Its public members no longer change the styles and the feature themselves; they record the requested state, and the render pipeline applies it in UpdateAnimations() on the next frame. Getters such as MyLocation, Direction and IsMoving return the requested state immediately, so set-then-read code keeps working. Code that inspects the layer's feature or styles right after an update, outside the render pipeline, sees the change one frame later.

Smaller differences: UpdateMyViewDirection hides the direction image for any negative direction (it used to compare the direction minus the viewport rotation with -1, which hid or showed it at the wrong moments); a non-animated update to the current target snaps a running animation to its end; the first location of a layer created without a start location is never animated from (0, 0); and finished animations no longer run their final step on every frame.

Also new: StillImage, MovingImage, DirectionImage and DirectionScale, and Scale now works after construction.

New capabilities in the experimental renderer

The experimental renderer (Mapsui.Experimental.Rendering.Skia) adds the following rendering capabilities that are not available in the standard renderer.

Right-to-left and bidirectional text

The experimental renderer correctly shapes and visually orders RTL text (Arabic, Hebrew, etc.) using HarfBuzz glyph shaping and UAX#9 bidi reordering via RichTextKit. The standard renderer does not support RTL.

To render Arabic text correctly:

new LabelStyle
{
    Text = "مرحبا بالعالم",
    Font = new Font { FontSource = "embedded://MyAssembly.Fonts.NotoSansArabic.ttf", Size = 16 },
    TextAlignment = Alignment.Right,
}

Unicode line breaking (UAX#14)

Word wrapping in the experimental renderer uses the Unicode Line Break Algorithm (UAX#14) for correct break-point detection across CJK, Arabic, and other scripts. The standard renderer uses a simpler space/character-based split.

Custom fonts (Font.FontSource)

As described above, Font.FontSource is only applied when using the experimental renderer.

Breaking changes in the experimental renderer

The experimental renderer (Mapsui.Experimental.Rendering.Skia) introduces stricter separation between two concerns that were previously conflated in LabelStyle.HorizontalAlignment:

  1. Box anchor — where the label box is positioned relative to the feature point.
  2. Text alignment — how text lines are aligned inside the label box.

Before 5.1, HorizontalAlignment controlled both. Since 5.1 the experimental renderer separates these into two properties:

Purpose Property Type
Box anchor (position relative to point) LabelStyle.HorizontalAlignment HorizontalAlignmentEnum
Text alignment within the box LabelStyle.TextAlignment Alignment

What to do

If you were using the experimental renderer and relied on HorizontalAlignment to also center or right-align text inside a multi-line label box, add an explicit TextAlignment setting:

// Before 5.1 (experimental renderer): HorizontalAlignment controlled both box anchor and text alignment
new LabelStyle
{
    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
}

// Since 5.1: set TextAlignment explicitly for within-box text alignment
new LabelStyle
{
    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
    TextAlignment = Alignment.Center,
}

Default value

TextAlignment defaults to Alignment.Left. For RTL scripts (Arabic, Hebrew, etc.) set it to Alignment.Right, or use Alignment.Auto to have the renderer detect direction from the text content automatically.

Non-experimental renderer

The non-experimental renderer (Mapsui.Rendering.Skia) is unchanged — HorizontalAlignment continues to control both box anchor and within-box text alignment.