Skip to content

Conversation

@jokerttu
Copy link
Contributor

@jokerttu jokerttu commented Nov 7, 2025

This PR adds Advanced markers support to the Android implementation of google_maps_flutter.
Approved combined PR: #7882
Approved and merged platform interface PR: #9737
Issue: flutter/flutter#155526

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Advanced Markers in the Android implementation of google_maps_flutter. The changes are comprehensive, including dependency updates, new logic for handling AdvancedMarkerOptions like PinConfig and collisionBehavior, and the addition of AdvancedMarkerClusterRenderer for clustering. A new API, isAdvancedMarkersAvailable, is also included. The example app has been updated with new pages to demonstrate these features. The implementation is solid and well-tested. I have a couple of minor suggestions to improve code quality and maintainability.

@stuartmorgan-g stuartmorgan-g added the triage-android Should be looked at in Android triage label Nov 18, 2025
@jokerttu jokerttu force-pushed the feature/advanced_markers_google_maps_flutter_android branch from 44e6b7a to 3cfb6f4 Compare November 24, 2025 09:11
Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

Java code reviewed. Sorry this took so long but thank you so much for your contribution.

*/
private void initializeRenderer(ClusterManager<MarkerBuilder> clusterManager) {
final ClusterRenderer<MarkerBuilder> clusterRenderer =
markerType == PlatformMarkerType.ADVANCED_MARKER
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you make this a switch instead of a turnary for readability?

getPinConfigFromPlatformPinConfig(
pinConfigBitmap, assetManager, density, bitmapDescriptorFactory);
return bitmapDescriptorFactory.fromPinConfig(pinConfig);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pick a more specific set of exceptions here?

? toInt(pinConfigBitmap.getBackgroundColor())
: null;
final Integer borderColor =
pinConfigBitmap.getBorderColor() != null ? toInt(pinConfigBitmap.getBorderColor()) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a lot of null handling in this code. Each line is easy enough to understand but i think it would be more readable if you made helper methods.

return JointType.DEFAULT;
}

static int collisionBehaviorFromPigeon(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a javadoc for this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

if (googleMap == null) {
throw new FlutterError(
"GoogleMap uninitialized",
"getMapCapabilities() called prior to map initialization",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this say isAdvancedMarkersAvailable somewhere in the error?

this.markerOptions = new MarkerOptions();
MarkerBuilder(String markerId, String clusterManagerId, PlatformMarkerType markerType) {
this.markerOptions =
markerType == PlatformMarkerType.ADVANCED_MARKER
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here can you make this a switch instead of a turnary?


@Override
public void setCollisionBehavior(@AdvancedMarkerOptions.CollisionBehavior int collisionBehavior) {
if (markerOptions.getClass() == AdvancedMarkerOptions.class) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you write this to not use getClass? In general we dont like having to use getClass or instanceOf they are are code smells.

.setIcon(icon)
.setInfoWindow(infoWindow);
.setInfoWindow(infoWindow)
.setCollisionBehavior(PlatformMarkerCollisionBehavior.REQUIRED_DISPLAY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a test for the behavior if someone passes an invalid version? if not can you add one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think It's possible to pass an invalid value nor test it here.

@reidbaker reidbaker requested a review from camsim99 December 4, 2025 18:24
@jokerttu jokerttu force-pushed the feature/advanced_markers_google_maps_flutter_android branch 2 times, most recently from 304d11c to 4e3e0e9 Compare December 9, 2025 14:11
@jokerttu jokerttu requested a review from reidbaker December 9, 2025 14:12
@jokerttu jokerttu force-pushed the feature/advanced_markers_google_maps_flutter_android branch from 4e3e0e9 to 82fa871 Compare December 12, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants