Skip to content

Commit bebbb57

Browse files
authored
[google_maps_flutter_platform_interface] Add onPointOfInterestTap support (#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.
1 parent a3ffe32 commit bebbb57

8 files changed

Lines changed: 65 additions & 1 deletion

File tree

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.17.0
2+
3+
* Adds support for tapping points of interest on the map.
4+
15
## 2.16.1
26

37
* Fixes the `PinConfig` code sample in the `BitmapDescriptor` documentation.

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ class GroundOverlayTapEvent extends MapEvent<GroundOverlayId> {
160160
GroundOverlayTapEvent(super.mapId, super.croundOverlayId);
161161
}
162162

163+
/// An event fired when a point of interest is tapped.
164+
class PointOfInterestTapEvent extends MapEvent<PointOfInterestId> {
165+
/// Build a PointOfInterestTap Event triggered from the map represented by `mapId`.
166+
///
167+
/// The `value` of this event is a [PointOfInterestId] object that represents the
168+
/// tapped point of interest.
169+
PointOfInterestTapEvent(super.mapId, super.pointOfInterestId);
170+
}
171+
163172
/// An event fired when a Map is tapped.
164173
class MapTapEvent extends _PositionedMapEvent<void> {
165174
/// Build an MapTap Event triggered from the map represented by `mapId`.

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
337337
throw UnimplementedError('onCircleTap() has not been implemented.');
338338
}
339339

340+
/// A point of interest has been tapped.
341+
Stream<PointOfInterestTapEvent> onPointOfInterestTap({required int mapId}) {
342+
return const Stream<PointOfInterestTapEvent>.empty();
343+
}
344+
340345
/// A Map has been tapped at a certain [LatLng].
341346
Stream<MapTapEvent> onTap({required int mapId}) {
342347
throw UnimplementedError('onTap() has not been implemented.');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/foundation.dart' show immutable;
6+
7+
import 'types.dart';
8+
9+
/// Uniquely identifies a point of interest on a [GoogleMap].
10+
///
11+
/// The [value] is the Google Maps place ID for the tapped point of interest.
12+
@immutable
13+
class PointOfInterestId extends MapsObjectId<PointOfInterestId> {
14+
/// Creates an immutable identifier for a point of interest.
15+
const PointOfInterestId(super.value);
16+
}

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/types.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export 'maps_object_updates.dart';
2828
export 'marker.dart';
2929
export 'marker_updates.dart';
3030
export 'pattern_item.dart';
31+
export 'point_of_interest_id.dart';
3132
export 'polygon.dart';
3233
export 'polygon_updates.dart';
3334
export 'polyline.dart';

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.16.1
7+
version: 2.17.0
88

99
environment:
1010
sdk: ^3.10.0

‎packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ void main() {
9595
);
9696
});
9797

98+
test('onPointOfInterestTap() returns empty stream', () async {
99+
final Stream<PointOfInterestTapEvent> stream = BuildViewGoogleMapsFlutterPlatform()
100+
.onPointOfInterestTap(mapId: 0);
101+
expect(await stream.isEmpty, isTrue);
102+
});
103+
98104
test('default implementation of `getStyleError` returns null', () async {
99105
final GoogleMapsFlutterPlatform platform = BuildViewGoogleMapsFlutterPlatform();
100106
expect(await platform.getStyleError(mapId: 0), null);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
7+
8+
void main() {
9+
test('PointOfInterestId equality', () {
10+
const id1 = PointOfInterestId('place-123');
11+
const id2 = PointOfInterestId('place-123');
12+
const id3 = PointOfInterestId('place-456');
13+
14+
expect(id1, equals(id2));
15+
expect(id1, isNot(equals(id3)));
16+
expect(id1.hashCode, equals(id2.hashCode));
17+
});
18+
19+
test('PointOfInterestId toString', () {
20+
const id = PointOfInterestId('place-123');
21+
expect(id.toString(), contains('place-123'));
22+
});
23+
}

0 commit comments

Comments
 (0)