Skip to content

[google_maps_flutter] Add onPointOfInterestTap - #11872

Open
tenninebt wants to merge 2 commits into
flutter:mainfrom
tenninebt:google-maps-on-poi-tap
Open

tenninebt wants to merge 2 commits into
flutter:mainfrom
tenninebt:google-maps-on-poi-tap

Conversation

@tenninebt

@tenninebt tenninebt commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds GoogleMap.onPointOfInterestTap, a callback that fires when the user taps a built-in map point of interest. The callback receives a PointOfInterestId containing the place ID only, matching maintainer feedback on #4052 and #10963.

The change is wired through the federated plugin stack: platform_interface (type + event stream), Android (OnPoiClickListener), iOS including sdk9/sdk10/shared (didTapPOIWithPlaceID), web (IconMouseEvent.placeId on map click), and the app-facing google_maps_flutter package. Tests cover Dart unit tests, Android Robolectric, iOS native, and web integration tests in the web example.

Fixes flutter/flutter#60695

Pre-Review Checklist

@tenninebt
tenninebt force-pushed the google-maps-on-poi-tap branch 9 times, most recently from 336fb13 to e125948 Compare June 13, 2026 07:30
@tenninebt
tenninebt marked this pull request as ready for review June 13, 2026 07:31

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

Copy link
Copy Markdown
Contributor

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 adds support for tapping points of interest (POIs) on the map across Android, iOS, and Web platforms in the google_maps_flutter plugin. It introduces the PointOfInterestId type and PointOfInterestTapEvent in the platform interface, exposes the onPointOfInterestTap callback on the GoogleMap widget, and implements the platform-specific event handling and Pigeon messaging. The review feedback suggests adding a defensive null check for the PointOfInterest parameter in the Android onPoiClick handler to prevent a potential NullPointerException.

Comment on lines +390 to +395
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Defensively checking pointOfInterest for null before accessing its properties is a good practice to prevent potential NullPointerExceptions, especially since the parameter is not annotated with @NonNull.

Suggested change
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest != null && pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The placeId null guard is the important part, and it’s already there. The Maps SDK only calls onPoiClick with a non-null PointOfInterest when a POI is tapped, and the other click handlers in this class don’t null-check their parameters either. We already have a test for the realistic case (placeId == null), which matches iOS. An extra pointOfInterest != null check would be harmless but unnecessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough.

@stuartmorgan-g
stuartmorgan-g self-requested a review June 23, 2026 18:26
@tenninebt

Copy link
Copy Markdown
Contributor Author

Hi @stuartmorgan-g when you're ready to review ping me and I'll do it right away. I'd rather fix the conflicts onces and for all instead of doing it every commit on that part of the code ;).

@stuartmorgan-g

stuartmorgan-g commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

No need to resolve changelog/pubspec comments until the whole review process is essentially complete (per the FAQ) since the conflicts in those files don't affect the ability to review the changes.

Comment thread packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart Outdated
Comment thread packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
- (void)didLongPressAtPosition:(FGMPlatformLatLng *)position;

/// Called when a point of interest is tapped.
- (void)didTapPointOfInterestWithPlaceId:(NSString *)placeId;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

...WithPlaceIdentifier:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed. I also moved the declaration up so it sits in the same spot as the matching method in MapsCallbackApi.

void onCircleTap(String circleId);

/// Called when a point of interest is tapped.
@ObjCSelector('didTapPointOfInterestWithPlaceId:')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

...PlaceIdentifier:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, it's didTapPointOfInterestWithPlaceIdentifier: now.

@tenninebt
tenninebt force-pushed the google-maps-on-poi-tap branch 4 times, most recently from 2247d7a to 1215581 Compare July 30, 2026 16:33
@tenninebt
tenninebt requested a review from stuartmorgan-g July 30, 2026 16:36
@stuartmorgan-g stuartmorgan-g added triage-ios Should be looked at in iOS triage triage-android Should be looked at in Android triage labels Aug 10, 2026
@stuartmorgan-g stuartmorgan-g added the federated: all_changes PR that contains changes for all packages for a federated plugin change label Aug 10, 2026
@tenninebt
tenninebt force-pushed the google-maps-on-poi-tap branch from 62ef656 to 954c841 Compare September 4, 2026 16:06
auto-submit Bot pushed a commit that referenced this pull request Sep 15, 2026
…port (#12752)

This is the platform interface portion of #11872

Adds `PointOfInterestId`, `PointOfInterestTapEvent`, and `GoogleMapsFlutterPlatform.onPointOfInterestTap`. The default implementation returns an empty stream so existing platform implementations are not broken.

Fixes flutter/flutter#60695 (platform interface only; app-facing and implementation packages land in follow-up PRs per the federated plugin contribution process).

## Pre-Review Checklist

@stuartmorgan-g — this is the first sub-PR from #11872 as requested.
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

The platform interface change should publish shortly, at which point you can update this PR to use it (and resolve conflicts from the Swift migration), then split out the PR with the platform implementation packages.

@mboetger mboetger added the CICD Run CI/CD label Sep 15, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@tenninebt

Copy link
Copy Markdown
Contributor Author

Opened the Android implementation sub-PR: #12880

Web implementation branch is ready at tenninebt:google-maps-poi-web (opening the PR next).

@tenninebt

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Implementations didn't need to each be separate PRs from each other, but since you've opened them already we can proceed that way.

@tenninebt

Copy link
Copy Markdown
Contributor Author

Implementations didn't need to each be separate PRs from each other, but since you've opened them already we can proceed that way.

Would rather have me update this PR? (I can still close the others if it is more convenient for you guys.)

@stuartmorgan-g

stuartmorgan-g commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins. This PR contains both implementation packages and the app-facing package, so cannot land this way. The flow we recommend for a change like this is the one described there, which involves three total PRs.

@tenninebt

tenninebt commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins. This PR contains both implementation packages and the app-facing package, so cannot land this way. The flow we recommend for a change like this is the one described there, which involves three total PRs.

Got it, I closed the 2 draft PRs and used the following for the implementations: #12880

auto-submit Bot pushed a commit that referenced this pull request Sep 24, 2026
…ns (#12880)

## Summary

- Platform implementations of `onPointOfInterestTap` for **Android**, **iOS** (`sdk9` / `sdk10` + shared source), and **web**
- Depends on published `google_maps_flutter_platform_interface` 2.17.0 from #12752
- Federated implementations PR (per [Changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins)); app-facing package will follow in a separate PR

**Notes**
- Frozen `google_maps_flutter_ios` is intentionally unchanged (no new features per that package’s README); iOS support is in `google_maps_flutter_ios_sdk9` / `google_maps_flutter_ios_sdk10`
- iOS DI follows the Swift controller conventions (required `callbackHandler` on the designated initializer)

Supersedes the separate drafts #12881 (web) and #12882 (iOS).

Part of #11872 / flutter/flutter#60695.

## Pre-Review Checklist
@hellohuanlin

Copy link
Copy Markdown
Contributor

@tenninebt could you resolved the conflict and rebase? thanks

Expose the POI tap callback on GoogleMap now that platform
implementations from flutter#12880 are published.
@tenninebt
tenninebt force-pushed the google-maps-on-poi-tap branch from 954c841 to f71e8e8 Compare September 26, 2026 17:34
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 26, 2026
@tenninebt tenninebt changed the title [google_maps_flutter] Add onPointOfInterestTap callback [google_maps_flutter] Add onPointOfInterestTap Sep 26, 2026
/// Called when a point of interest on the map is tapped.
///
/// Supported on Android and web, and on iOS when using
/// `google_maps_flutter_ios_sdk9` or `google_maps_flutter_ios_sdk10`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment does not belong in this package; it will become incorrect when, inevitably, new _sdk* variants are introduced that also support this feature.

It should simply say that it may not be supported on all implementations. A note about google_maps_flutter_ios not supporting a feature belongs in the google_maps_flutter_ios README, not here.

///
/// Supported on Android and web, and on iOS when using
/// `google_maps_flutter_ios_sdk9` or `google_maps_flutter_ios_sdk10`.
/// The default `google_maps_flutter_ios` package does not receive new

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When the endorsed implementation is changed, there is essentially no chance that the person making that change would remember the existence of this comment, so this also does not belong here.

* Adds support for tapping points of interest on the map.
On iOS, this requires `google_maps_flutter_ios_sdk9` or
`google_maps_flutter_ios_sdk10` (the default `google_maps_flutter_ios`
package does not receive new features).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(This is fine, since CHANGELOG entries are not expected to be evergreen.)

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Sep 28, 2026
Keep app-facing dartdoc generic, and document that the frozen iOS
implementation does not support the callback in its own README.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

federated: all_changes PR that contains changes for all packages for a federated plugin change p: google_maps_flutter platform-ios triage-android Should be looked at in Android triage triage-ios Should be looked at in iOS triage triage-web Should be looked at in web triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_maps_flutter] Add callback for click on google poi's on the map

7 participants