MapView stays empty on latest .NET MAUI on Android

1517
9
Jump to solution
05-02-2023 09:31 AM
Labels (3)
SokoFromNZ
Occasional Contributor

Hi,

This took me a day to figure out 😞

It seems with the latest version of your Runtime (<PackageReference Include="Esri.ArcGISRuntime.Maui" Version="200.1.0" />) and the latest Visual Studio 2022 Version (Enterprise v17.5.5, .NET MAUI to 7.0.81 (SR4)) maps are not shown anymore.

I've reproduced this on an emulator an two real world devices.

I've created a simple/default .NET MAUI app for your convenience (see zip attached).

The core issue is in the xaml:

 

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="ArcGISTry1.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">

    <!-- With "*, Auto" no map is displayed!
    Only this works, but is layout-wise not what I want: <Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
    -->
    <Grid ColumnDefinitions="*, Auto" RowDefinitions="*, Auto">
        <esriUI:MapView
            x:Name="MyMapView"
            Grid.Row="0"
            Grid.RowSpan="2"
            Grid.Column="0"
            Grid.ColumnSpan="2" />
        <Button
            Grid.Row="1"
            Grid.Column="1"
            Text="..." />
    </Grid>
</ContentPage>

 

If I put the MapView into a Grid with Auto-Columns/Rows the page stays empty:

nomap.png

 

If I use just Star-Columns/Rows everything works fine:

map.png

Please investigate as I need this to work asap for a upcoming release

0 Kudos
1 Solution

Accepted Solutions
SokoFromNZ
Occasional Contributor

With the newest ArcGIS Runtime 200.3 and .NET8/MAUI8 this issue is solved

View solution in original post

0 Kudos
9 Replies
dotMorten_esri
Esri Notable Contributor

I've been able to reproduce this, and while I don't have a fix/explanation  right at this moment, I was able to get the behavior you're looking for with a slightly different layout:

    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Grid ColumnDefinitions="*, Auto" RowDefinitions="*, Auto">
            <Button Grid.Row="1" Grid.Column="1" Text="..." />
        </Grid>
    </Grid>
0 Kudos
SokoFromNZ
Occasional Contributor

Hi,

Good to hear you can reproduce it. Is there an official way for me to report real bugs in the runtime? Or do you create a bug report to your developers about this issue now?

After creating this ticket I came up with the exact same workaround as you did 🙂

Anyhow...I'm looking forward to an explanation for this. Please keep me up to date 

Soko

0 Kudos
dotMorten_esri
Esri Notable Contributor

Sorry for the slow follow-up. I've been spending some time debugging this, and I'm 99.9% sure this is a layout bug in .NET MAUI, and not in the ArcGIS Maps SDK. It's sending some weird layout parameters when you use the specific configuration you have above, causing the map to size itself to 0.
However I did find numerous other ways to get the layout you want without triggering this bug, so you should be able to move forward.

0 Kudos
MatveiStefarov
Esri Contributor

I think you're right, Morten.  The bug disappears when building the reproducer with latest Visual Studio Preview.  There have been many layout bugs fixed in MAUI recently, perhaps this has already been taken care of by Microsoft.

Screenshot_20230531_181251.jpg

0 Kudos
SokoFromNZ
Occasional Contributor

Hi guys...and thanks for the effort.

So whats the plan here? I reckon to wait for the next VS version?

@MatveiStefarov: which version exactly did you test? Was it a v17.6.3 or a 17.7.0?

Thanks

Soko

0 Kudos
dotMorten_esri
Esri Notable Contributor

So whats the plan here?

Since this is a layout bug outside the Maps SDK, you have a few choices:

  1. Work around it (as mentioned above it fixes itself quite easily by not relying on auto-sizing or rearranging layout layered instead of gridded.
  2. Wait for .NET 8 to ship with the fix (and/or use the preview for now).
  3. Push Microsoft to backport the fix to .NET 7.
0 Kudos
SokoFromNZ
Occasional Contributor

Heya,

I've ment actually _your_ plan 😉

I've implemented the work around already so I have no urgend need for a fix here.

But you are certian MatveiStefavor tested with a .NET8 preview here?

0 Kudos
dotMorten_esri
Esri Notable Contributor

I trust the testing the team-members do. In addition it is backed up by numerous layout fixes in the .NET MAUI previews.

0 Kudos
SokoFromNZ
Occasional Contributor

With the newest ArcGIS Runtime 200.3 and .NET8/MAUI8 this issue is solved

0 Kudos