Skip to content

[google_maps_flutter_platform_interface] Add onPointOfInterestTap support - #12752

Open
tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-poi-platform-interface
Open

[google_maps_flutter_platform_interface] Add onPointOfInterestTap support#12752
tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-poi-platform-interface

Conversation

@tenninebt

@tenninebt tenninebt commented Sep 4, 2026

Copy link
Copy Markdown

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the AI contribution guidelines and understand my responsibilities, or I am not using AI tools.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter.
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I linked to at least one issue that this PR fixes in the description above.
  • I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style.
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.

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

@google-cla

google-cla Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 by introducing PointOfInterestId, PointOfInterestTapEvent, and the onPointOfInterestTap stream. Feedback suggests enhancing the API by creating a PointOfInterest class that includes the POI's name and coordinates, rather than just its ID. Additionally, it is recommended to throw an UnimplementedError in the default implementation of onPointOfInterestTap to maintain consistency with other platform interface methods, and to update the corresponding tests accordingly.

Comment on lines +163 to +170
/// An event fired when a point of interest is tapped.
class PointOfInterestTapEvent extends MapEvent<PointOfInterestId> {
/// Build a PointOfInterestTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [PointOfInterestId] object that represents the
/// tapped point of interest.
PointOfInterestTapEvent(super.mapId, super.pointOfInterestId);
}

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.

high

The native Google Maps SDKs on both Android (OnPoiClickListener) and iOS (mapView:didTapPOIWithPlaceID:name:location:) provide the name and location (LatLng) of the tapped point of interest, in addition to the place ID. \n\nBy only exposing PointOfInterestId (which only wraps the place ID string), developers will not be able to know the name or coordinates of the tapped POI without performing a separate, paid Google Places API lookup. \n\nTo make this API fully functional and useful, please consider defining a PointOfInterest class containing id, name, and latLng, and have PointOfInterestTapEvent wrap that instead of just the ID.

Comment on lines +341 to +343
Stream<PointOfInterestTapEvent> onPointOfInterestTap({required int mapId}) {
return const Stream<PointOfInterestTapEvent>.empty();
}

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

To maintain consistency with all other stream methods in this class (such as onClusterTap, onGroundOverlayTap, onMarkerTap, etc.) and to adhere to the class's documented design principle (which states that default implementations of new methods should throw at runtime to signal unimplemented status), this method should throw an UnimplementedError instead of returning an empty stream.

Suggested change
Stream<PointOfInterestTapEvent> onPointOfInterestTap({required int mapId}) {
return const Stream<PointOfInterestTapEvent>.empty();
}
Stream<PointOfInterestTapEvent> onPointOfInterestTap({required int mapId}) {
throw UnimplementedError('onPointOfInterestTap() has not been implemented.');
}

Comment on lines +98 to +102
test('onPointOfInterestTap() returns empty stream', () async {
final Stream<PointOfInterestTapEvent> stream = BuildViewGoogleMapsFlutterPlatform()
.onPointOfInterestTap(mapId: 0);
expect(await stream.isEmpty, isTrue);
});

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

Update this test to expect an UnimplementedError to match the corrected default implementation of onPointOfInterestTap.

Suggested change
test('onPointOfInterestTap() returns empty stream', () async {
final Stream<PointOfInterestTapEvent> stream = BuildViewGoogleMapsFlutterPlatform()
.onPointOfInterestTap(mapId: 0);
expect(await stream.isEmpty, isTrue);
});
test('onPointOfInterestTap() throws UnimplementedError', () {
expect(
() => BuildViewGoogleMapsFlutterPlatform().onPointOfInterestTap(mapId: 0),
throwsUnimplementedError,
);
});

…port

Add PointOfInterestId, PointOfInterestTapEvent, and a default empty
onPointOfInterestTap stream so implementations can opt in without a
breaking platform-interface change.
@tenninebt
tenninebt force-pushed the google-maps-poi-platform-interface branch from 4b55349 to a0bb5d2 Compare September 4, 2026 16:08
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.

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

1 participant