-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[google_maps_flutter_platform_interface] Add onPointOfInterestTap support #12752
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -337,6 +337,11 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { | |||||||||||||
| throw UnimplementedError('onCircleTap() has not been implemented.'); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// A point of interest has been tapped. | ||||||||||||||
| Stream<PointOfInterestTapEvent> onPointOfInterestTap({required int mapId}) { | ||||||||||||||
| return const Stream<PointOfInterestTapEvent>.empty(); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+341
to
+343
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To maintain consistency with all other stream methods in this class (such as
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| /// A Map has been tapped at a certain [LatLng]. | ||||||||||||||
| Stream<MapTapEvent> onTap({required int mapId}) { | ||||||||||||||
| throw UnimplementedError('onTap() has not been implemented.'); | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/foundation.dart' show immutable; | ||
|
|
||
| import 'types.dart'; | ||
|
|
||
| /// Uniquely identifies a point of interest on a [GoogleMap]. | ||
| /// | ||
| /// The [value] is the Google Maps place ID for the tapped point of interest. | ||
| @immutable | ||
| class PointOfInterestId extends MapsObjectId<PointOfInterestId> { | ||
| /// Creates an immutable identifier for a point of interest. | ||
| const PointOfInterestId(super.value); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -95,6 +95,12 @@ void main() { | |||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| test('onPointOfInterestTap() returns empty stream', () async { | ||||||||||||||||||||||||
| final Stream<PointOfInterestTapEvent> stream = BuildViewGoogleMapsFlutterPlatform() | ||||||||||||||||||||||||
| .onPointOfInterestTap(mapId: 0); | ||||||||||||||||||||||||
| expect(await stream.isEmpty, isTrue); | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
Comment on lines
+98
to
+102
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update this test to expect an
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| test('default implementation of `getStyleError` returns null', () async { | ||||||||||||||||||||||||
| final GoogleMapsFlutterPlatform platform = BuildViewGoogleMapsFlutterPlatform(); | ||||||||||||||||||||||||
| expect(await platform.getStyleError(mapId: 0), null); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
|
|
||
| void main() { | ||
| test('PointOfInterestId equality', () { | ||
| const id1 = PointOfInterestId('place-123'); | ||
| const id2 = PointOfInterestId('place-123'); | ||
| const id3 = PointOfInterestId('place-456'); | ||
|
|
||
| expect(id1, equals(id2)); | ||
| expect(id1, isNot(equals(id3))); | ||
| expect(id1.hashCode, equals(id2.hashCode)); | ||
| }); | ||
|
|
||
| test('PointOfInterestId toString', () { | ||
| const id = PointOfInterestId('place-123'); | ||
| expect(id.toString(), contains('place-123')); | ||
| }); | ||
| } |
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 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 exposingPointOfInterestId(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 aPointOfInterestclass containingid,name, andlatLng, and havePointOfInterestTapEventwrap that instead of just the ID.