-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_maps_flutter] Support Google Maps onMapLoaded #10714
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
base: main
Are you sure you want to change the base?
Conversation
Implements the GoogleMap.OnMapLoadedCallback interface and triggers the onMapLoaded event in the platform channels for both Android and iOS. Updates generated Pigeon message files and platform interface to support the new event, enabling Flutter apps to listen for when the map has fully loaded.
Introduces a new test in both Android and iOS Google Maps Flutter plugins to verify that the onMapLoaded event is sent to the correct stream for a given mapId. This ensures proper event delivery from the native side to Dart.
Updates package versions and changelogs to reflect the new feature.
There was a problem hiding this 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 the onMapLoaded callback in the google_maps_flutter plugin for both Android and iOS. The changes are well-implemented across the platform interface, Android, and iOS packages. The platform interface is correctly extended with the new MapLoadedEvent and onMapLoaded stream. The native implementations use the appropriate platform-specific callbacks (OnMapLoadedCallback for Android and mapViewDidFinishTileRendering: for iOS) and communicate with the Dart side via updated Pigeon message definitions. New tests have been added to verify the functionality on both platforms, and all relevant package versions and changelogs have been updated accordingly. The code is clean, consistent, and follows existing patterns.
|
Thanks for the contribution! Two initial high-level notes while this waits for review:
|
Introduces an onMapLoaded callback to the GoogleMap widget, allowing clients to be notified when map tiles have finished loading. Updates the controller and web implementation to support the new event, adds related tests, and demonstrates usage in the example app.
Added dependency_overrides to various pubspec.yaml files across google_maps_flutter packages to enable local development and testing of federated plugins. These changes are for testing and initial review only and should not be merged into the main branch, as indicated by the included comments and reference to the Flutter contributing guidelines.
|
Thanks for the notes! Both points have been fully addressed:
Please let me know if there’s anything else to adjust while this is under review. |
|
The CI failures all look like real failures now, which will need to be resolved (other than the expected |
Implements the onMapLoaded and onGroundOverlayTap event streams in MethodChannelGoogleMapsFlutter. Updates the changelog to reflect these additions.
Updated the test to exclude WebMapReadyEvent from the capturedEvents stream, ensuring only relevant events are considered during testing.
|
Thanks for the heads up. All CI failures have now been resolved, except for the expected federated safety check. |
vashworth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS side LGTM
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iOS implementation lgtm (modulo a potentially broken link).
| } | ||
|
|
||
| @override | ||
| Stream<MapLoadedEvent> onMapLoaded({required int mapId}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the API conventions of this package, but each event in the Stream basically carries no information so it might as well be Void. It looks to me that the MapLoadedEvent type only exists so that this implementation can use it to filter the event stream and extract the relevant events, and MapLoadedEvent is not useful to the caller of this API at all. If that's indeed the case, would it be possible to hide the MapLoadedEvent type? Or is it made public for subclassing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume with the current interface, to provide a "start loading" event stream in the future would require adding a new onMapLoading method to this interface. I would expect a lot of use cases of this API would also involve listening to the "Map started loading" event stream and combining the two streams (e.g., I want to perform asynchronous work on map load, and cancel that work if the map starts loading again).
IMO it might be a bit more ergonomic to return a Stream that gives you both start and finish events (so something like Stream<bool>, or the boolean flag can be added to MapLoadEvent), or even a ValueNotifier<bool> (but now the caller would have to manage the lifespan of the ValueNotifier so I'm not sure about that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it looks like this is a low-level interface and most app developers don't have to use this directly. Feel free to ignore the comments then.
packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart
Outdated
Show resolved
Hide resolved
Corrected the documentation link for GMSMapViewDelegate.mapViewDidFinishTileRendering in the GoogleMap widget to point to the updated iOS SDK reference.
Implements the GoogleMap.OnMapLoadedCallback interface and triggers the onMapLoaded event via platform channels on Android and iOS, with corresponding handling on Web. Updates the generated Pigeon message files and platform interface to support the new event, enabling Flutter apps to listen for when the map has fully loaded across all supported platforms.
Fixes flutter/flutter#99610
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).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-assistbot 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
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