Skip to content

v5.0 Upgrade Guide

By compile error

Below is a list of compile error that you could encounter when upgrading van Mapsui V4 to V5. Please inform us if you run into compile errors that are not in this list.

Compile error: 'Layer' does not contain a definition for 'IsMapInfoLayer'

The IsMapInfoLayer field was deprecated. The caller is now responsible for which layers should be queried by passing the list of layers as argument to the GetMapInfo call. The GetMapInfo method is available on the EventArgs of all pointer events. Here is the documentation on MapInfo.

Straightforward port of IsMapInfoLayer

There are many ways to specify which layers to query, but if you are already using IsMapInfoLayer in v4 then you could use this straightforward port. The idea is to store the IsMapInfoField inside an object in the ILayer.Tag field.

Create a new class with an IsMapInfoLayer field:

public class LayerData
{
    public bool IsMapInfoLayer { get; set; }
}

Assign an instance to the ILayer.Tag field when you create the layer:

var layer = new Layer(layerName) { Tag = new LayerData { IsMapInfoLayer = true }};

Use that IsMapInfoLayer field to filter the e.Map.Layers in the GetMapInfo call:

private void MapTapped(object? s, MapEventArgs e)
{
    var mapInfo = e.GetMapInfo(e.Map.Layers.Where(l => l.Tag is LayerData { IsMapInfoLayer: true }));
}

Compile error: 'Map' does not contain a definition for 'Home'

In V5 you can call the Navigator methods to specify the startup view, for instance: Map.Navigator.ZoomToBox(startupBox). The Home method solved a problem where you could not use the Navigator when the Map size was not initialized. In V5 this problem is solved within the Navigator by postponing the call until it is initialized.

Compile error: The type or namespace name 'RectFeature' could not be found

RectFeature was removed to simplify our code. Use new GeometryFeature(myRect.ToPolygon()) instead.

Compile error: 'SymbolStyle' does not contain a definition for 'BitmapId'

In V4 you had to register a bitmap and then assign the id to the SymbolStyle. In V5 you can directly specifify the path to the image source. See is the documentation on ImageSource

Compile error: The name 'BitmapRegistry' does not exist in the current context

See the item above.

Compile error: 'MapControl' does not contain a definition for 'ScreenWidth' and no accessible extension method 'ScreenWidth' accepting a first argument of type 'MapControl' could be found

Use MapControl.Map.Navigator.Viewport.Width instead.

Compile error: 'MapControl' does not contain a definition for 'ScreenHeight' and no accessible extension method 'ScreenHeight' accepting a first argument of type 'MapControl' could be found

Use MapControl.Map.Navigator.Viewport.Height instead.

Compile error: 'IRenderer' does not contain a definition for 'StyleRenderers' and no accessible extension method 'StyleRenderers' accepting a first argument of type 'IRenderer' could be found

Use the static MapRenderer.RegisterStyleRenderer(...) method for registering and the mapControl.Renderer.TryGetStyleRenderer method when drawing.

Compile error: 'IRenderer' does not contain a definition for 'WidgetRenders' and no accessible extension method 'WidgetRenders' accepting a first argument of type 'IRenderer' could be found

Use the static MapRenderer.RegisterWidgetRenderer(...) method for registering and the mapControl.Renderer.TryGetWidgetRenderer method when drawing.

List of changes in the order that they were applied.

  • Removed RectFeature. Instead of new RectFeature(myRect) use new GeometryFeature(myRect.ToPolygon())
  • Removed the existing events that were specific to the MAUI MapControl. Alternatives: Use the shared MapControl events: MapTapped, MapPointerPressed, MapPointerMoved, MapPointerReleased, or the events on the Map: Tapped, PointerPressed, PointerMoved, PointerReleased.
  • Introduced PinchState to replace separate center, radius and angle fields and used in o.a. the Map.Navigator.Pinch method.
  • Moved UnSnapRotationDegrees and UnSnapRotationDegrees properties from MapControl to MapControl.Map.Navigator.
  • Rename Microsoft.Maui.Graphics.Color ToNative(this Styles.Color color) to ToMaui.
  • Because BaseFeature is now derived from IFeature and the previously not-implemented methods and fields had to be defined as abstract, these now need the override keyword in the derived classes.
  • The logic around MapInfo was rewritten. In V4 the Info event returned a MapInfo object which contained the features on the tap location for those layers for which IsMapInfoLayer was set to true. In V5 IsMapInfoLayer is removed. The Info event args do not contain a MapInfo object but a GetMapInfo method to retrieve it. That method needs a list of layers to query. There is also a GetRemoteMapInfo for layers that get the feature info from the server, like WMS.