Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add support for new google maps renderer #4055

Conversation

isidoro98
Copy link
Contributor

@isidoro98 isidoro98 commented Jan 3, 2022

Does any other open PR do the same thing?

Yes, #4045. But this PR takes a different approach. On #4045 The new renderer is set using a prop of MapView. This approach might be misleading as the renderer can only be set once in our application. Thus changing the value of this prop doesn't modify the renderer that our application will continue to use.

Instead this PR allows the user to opt in to the new renderer by calling enableLatestRenderer on the entry file of their application.

This function can also be called at any other point to return the renderer that is being used, but it won't change it after the first map has been rendered.

What issue is this PR fixing?

#3991

How did you test this PR?

Tested on a Samsung Galaxy Note 9

@christopherdro
Copy link
Collaborator

@isidoro98 Thank you for this. I definitely like this approach much better. I was gonna suggest to exposing the option on the native side but this might be a better approach since some users might be using this within a managed Expo workflow.

@christopherdro christopherdro changed the title [android]: Maps SDK 18.0.0 [android]: Google Maps SDK 18.0.0 - New SDK Renderer Jan 6, 2022
Copy link
Collaborator

@salah-ghanim salah-ghanim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @isidoro98 this approach definitely have some advantages. and better than the old suggestion.

with that being said an environment variable or a javascript config (in package.json if possible) would be a better implementation. since it's awkward to add such a function call at the top of the project / main and to expect other contributers to understand the need for it.

but it's a decent solution, and hopefully google will provide better apis in the future releases.

salah-ghanim
salah-ghanim previously approved these changes Jan 16, 2022
@salah-ghanim
Copy link
Collaborator

salah-ghanim commented Jan 16, 2022

@@christopherdro looks good to me and can be merged :)

@fakeheal
Copy link

fakeheal commented Jan 27, 2022

I would suggest renaming useLatestRenderer to enableLatestRenderer or something else that doesn't start with use..., because in React context it can be a bit misleading (mainly to IDEs).

Edit: Or maybe preferLatestRenderer is more suitable, since according to Google Maps SDK docs:

Renderer requests are not guaranteed, and the latest renderer may not always be returned. This can occur for many reasons, most commonly because the target device is using an unsupported version of Android, or does not have enough storage space.

Edit: Maybe on iOS useLatestRenderer should also return a promise?

@salah-ghanim
Copy link
Collaborator

I agree with @fakeheal improvements suggestions

  1. preferLatestRenderer is a much better name
  2. on iOS a resolved promise should be returned, that way we have consistent API regardless of the platform.

@isidoro98
Copy link
Contributor Author

isidoro98 commented Jan 28, 2022

I agree with @fakeheal improvements suggestions

  1. preferLatestRenderer is a much better name
  2. on iOS a resolved promise should be returned, that way we have consistent API regardless of the platform.

Regarding 2, at the moment iOS would return undefined, what would you want it to return? Undefined makes the most sense imo. @fakeheal @salah-ghanim

@gillpeacegood
Copy link

I am trying this and had to change the android build.gradle

android {
  compileSdkVersion safeExtGet('compileSdkVersion', 28)

   compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

@Mhd-Emad
Copy link

Hi @isidoro98
Thank you so much for your effort on this,
I tried your code and I got this error:

error: lambda expressions are not supported in -source 7
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, (MapsInitializer.Renderer renderer) -> {
(use -source 8 or higher to enable lambda expressions)

Can you advise, please?

@isidoro98
Copy link
Contributor Author

Hi @isidoro98

Thank you so much for your effort on this,

I tried your code and I got this error:

error: lambda expressions are not supported in -source 7

     MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, (MapsInitializer.Renderer renderer) -> {

(use -source 8 or higher to enable lambda expressions)

Can you advise, please?

Could you check your Java version? Looks like you're using Java 7, but need Java 8

@botondus
Copy link

Any ETA on getting this merged in and released?

satya-imaginea
satya-imaginea previously approved these changes Feb 22, 2022
@satya-imaginea
Copy link

satya-imaginea commented Feb 22, 2022

Would someone please merge this PR, which needs to be used by June 22 as per recent mails?

Some of your projects use Maps SDK for Android. Try the new upgrade to test the improved renderer and other features.Hello Google Maps Platform Customer,We're writing to remind you that a major update of Maps SDK for Android (version 18.0.x), available via Google Play services, features a new map renderer that will become the default renderer for Android devices* through a progressive rollout, starting in June 2022 at the earliest.Once the new renderer becomes the default, your apps will use the new renderer whether or not they were built against Maps SDK for Android version 18.0.x.Update to the new map renderer (SDK latest version: 18.0.2) now to test and deploy the new SDK and renderer with your apps before the new renderer becomes the default for Android devices*.We’ve improved how we serve tiles to your apps and render the map on client devices with the new SDK. Therefore, Android devices will benefit from:Reduced network load, processing demand, and memory consumption.Improved gesture handling for better animations, plus smoother panning and zooming.More fluid transitions and clearly positioned map labels.A more stable and improved user experience for future map innovations on Android.The new SDK also includes the general availability of Cloud-based maps styling on mobile. Usage of Cloud-based maps styling for a map in Maps SDK for Android is billed with the Dynamic Maps SKU. For more information on pricing and included features, see our Cloud Customization documentation.*All devices on Android 5.0 (Lollipop) or later with 2 GB or more of data storage will use the new renderer. All other devices will continue to use the legacy renderer until further notice.What do I need to do?To anticipate and avoid issues with your apps we advise you to:Specify version 18.0.x in your dependencies (example).Specify the new renderer in your code (instructions).Test, build, and release a new version of your app based on the new renderer, before the beginning of the new SDK progressive rollout in June 2022. See our New Map Renderer documentation for instructions on how to use the new renderer.If you encounter any issues in your apps with the new SDK or the new renderer, please check our Support Options for Maps SDK for Android, and consider pausing the apps’ deployment to users until the issues are resolved.

@ruanblimaig
Copy link

Does this PR lack something to be approved?

I tested this update, but I had problems using it on android. It gave an error related to the java version, even with a version greater than 8. To fix it I needed to add the following code snippet in android/build.gradlew:

compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

monholm added a commit to monholm/react-native-maps that referenced this pull request Mar 7, 2022
@monholm
Copy link
Collaborator

monholm commented Mar 9, 2022

We experienced a couple of things while testing the new renderer (would love to hear feedback from anybody else regarding this):

  • Labels on the map (e.g. city names) are POI's and triggers the onPoiClick callback.
  • The onPoiClick callback takes precedence over onMapClick and doesn't propagate.
  • The onPoiClick callback takes precedence over onMarkerClick (At least for customMarkerViews) and doesn't propagate.

These are breaking changes (for us) as some markers are practically unpressable when rendered on top of labels and onMapClick isn't triggered when clicking the map on top of labels.
Not registrering the onPoiClickListener (natively) seems to allow the event to propagate to onMapClick and onMarkerClick.

Whether expected behaviour or not, this should most likely be documented in the PR.

@phinfqasia
Copy link

Are there any concerns that we need to do for the testing? I'm quite sure that PR needs to merge for anyone that currently using this library.

@monholm
Copy link
Collaborator

monholm commented Mar 16, 2022

@phinfqasia Could you test if you experience the same as I mentioned in the comment just above yours? :)

@monholm
Copy link
Collaborator

monholm commented Mar 16, 2022

@isidoro98 @christopherdro I'm happy with this approach of enabling the renderer as well, and enabling it seems to be working as expected. I'm okay merging this, if we can do the following:

  • Update the play services dependencies to the latest versions as of today (there's been a couple of releases since this PR)
  • Update the doc with the new rollout date, which has been changed to June instead of March
  • Update docs to include a warning that there’s a risk that enabling the new renderer might cause behavioural changes and maybe link to the comment I made above? Or even better, rephrase and include the comments directly in the docs

@isidoro98 would you be willing/able to update the PR with these changes?

@monholm monholm changed the base branch from master to beta March 19, 2022 20:16
@monholm monholm changed the title [android]: Google Maps SDK 18.0.0 - New SDK Renderer feat(android): add support for new google maps renderer Mar 25, 2022
@monholm monholm merged commit bb08557 into react-native-maps:beta Mar 25, 2022
@github-actions
Copy link

🎉 This PR is included in version 0.31.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@monholm
Copy link
Collaborator

monholm commented Mar 25, 2022

@isidoro98 I took the liberty of committing the changes I suggested above, to help move this into a beta release. I hope you are okay with that :) Thank you very much for your help!

@dishantwalia
Copy link

@Simon-TechForm when it will be available as an official release, any tentative date?

@stockhuman
Copy link

I tested this update, but I had problems using it on android. It gave an error related to the java version, even with a version greater than 8. To fix it I needed to add the following code snippet in android/build.gradlew:

android {
  compileSdkVersion safeExtGet('compileSdkVersion', 28)

  defaultConfig {
    minSdkVersion safeExtGet('minSdkVersion', 21)
    targetSdkVersion safeExtGet('targetSdkVersion', 27)
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

I too had to hack in this to lib/android/build.gradle, perhaps it's worth including?

@github-actions
Copy link

🎉 This PR is included in version 0.31.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@fullstack0103
Copy link

hi, everyone
How can I implement new renderer in react native project?
Thanks

@dishantwalia
Copy link

hi, everyone How can I implement new renderer in react native project? Thanks

To opt in to the new renderer add the following code in your entry file (e.g. App.js):

import { enableLatestRenderer } from 'react-native-maps';

enableLatestRenderer();

https://github.com/react-native-maps/react-native-maps/blob/4a9fdf5f0d52519ce8b17f15fd35b81cde197701/docs/installation.md#using-the-new-google-maps-renderer

salah-ghanim pushed a commit to GET-A-WAY/react-native-maps that referenced this pull request Apr 5, 2023
…-maps#4055)

* Maps SDK 18.0.0

* Update installation.md

* Update installation.md

* Update debug log

* Update opt in function name

* feat(android): bump play services

* docs: update new renderer rollout date

* docs: add warning for new renderer

* fix: eslint warning

Co-authored-by: Simon-TechForm <73996878+Simon-TechForm@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet