dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.97k stars 1.72k forks source link

Support for latest renderer in Google Map #20740

Open BierDav opened 6 months ago

BierDav commented 6 months ago

Description

Google announced that by March 3, 2025 the legacy renderer of Google Map will be decommissioned. We need a way to use the latest renderer in MAUI

See more: https://developers.google.com/maps/documentation/android-sdk/renderer

Public API Changes

I'm not experienced enough to suggest where this setting to toggle between latest and legacy should be implemented, but we need the option somewhere.

Intended Use-Case

.

jfversluis commented 6 months ago

We use the Xamarin.GooglePlayServices.Maps package for this which is part of this repository: https://github.com/xamarin/GooglePlayServicesComponents on said repository there is a note about the version number as seen below.

The major/minor/patch version numbers are the GPS/FB/MLKit library version prefixed with a 1. For example, the NuGet Xamarin.GooglePlayServices.Maps 117.0.1 binds version 17.0.1 of the GPS library com.google.android.gms:play-services-maps.

For Maps we currently use 118.1.0.3 as seen here. So that means 18.1.0.3 for the Android version.

In your linked doc it says

An upgraded map renderer is available as of version 18.2.0 of the Maps SDK for Android.

And

With the release of version 18.2.0 of the Maps SDK for Android, Google switched the default renderer from the legacy renderer to the upgraded map renderer. With version 18.2.0, the map renderer used when you build a new app or rebuild an existing app becomes the upgraded map renderer.

~So I don't think there is any work for us to be done here. I don't see any code that sets our renderer back to the legacy mode manually, so our library is prepared for this. Thanks for raising this!~

edit: And then I noticed I mixed up the numbers, sorry about that. We in fact DO need to do something here, because we're not on version 18.2 yet 😄 so again, thank you for raising this!

jfversluis commented 6 months ago

@moljac do we know if there are plans underway for updating the bindings on this one?

kcrg commented 6 months ago

@jfversluis I think problem with ViewPager2 is blocking AndroidX upgrade. See https://github.com/dotnet/maui/pull/17793#issuecomment-1753689058

I tried to bump map nuget in my app but shell top bar stopped working and start throwing.

java.lang.IllegalStateException: Design assumption violated.

moljac commented 6 months ago

@moljac do we know if there are plans underway for updating the bindings on this one?

Well

https://www.nuget.org/packages/Xamarin.GooglePlayServices.Maps/118.2.0.1

jfversluis commented 6 months ago

@moljac aaaah see! That's why I mixed up the numbers probably. I did see we had the bindings, we just didn't update them for MAUI yet. Thank you!

Should we include this update in https://github.com/dotnet/maui/pull/17318?

jyotsnar commented 6 months ago

@BierDav I was able to use the latest renderer in my Maui app by calling this method

MapsInitializer.Initialize(Platform.AppContext, MapsInitializer.Renderer.Latest, null);

before the call to

MauiProgram.CreateMauiApp();

in my Android Application (inheriting MauiApplication). See the guidance here.

Note: will not work on an emulator, only on a physical device

mfeingol commented 6 months ago

@jyotsnar: how can you tell it's using the latest renderer?

jyotsnar commented 6 months ago

@jyotsnar: how can you tell it's using the latest renderer?

By looking at the device logs:

[MapsInitializer] preferredRenderer: LATEST
[zzcb] preferredRenderer: LATEST
[zzcb] Making Creator dynamically
[DynamiteModule] Considering local module com.google.android.gms.maps_core_dynamite:0 and remote module com.google.android.gms.maps_core_dynamite:234910200
[DynamiteModule] Selected remote version of com.google.android.gms.maps_core_dynamite, version >= 234910200
[DynamiteModule] Dynamite loader version >= 2, using loadModule2NoCrashUtils
[Google Android Maps SDK] Google Play services client version: 12451000
[Google Android Maps SDK] Google Play services package version: 240515038
[Google Android Maps SDK] Google Play services maps renderer version(maps_core): 234910200
[MapsInitializer] loadedRenderer: LATEST 
awasilik commented 2 months ago

Hey, any progress on this matter. I see that Maui uses Xamarin.GooglePlayServices.Maps in version 118.1.0.3 and latest available is 118.2.0.4.

Do you have any estimation when can we expect an update?