Skip to content

Commit 93d9079

Browse files
committed
feat: InfoWindow anchor configurable
1 parent cf1093e commit 93d9079

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: apple_maps_flutter
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "0.1.2+3"
10+
version: "0.1.2+4"
1111
async:
1212
dependency: transitive
1313
description:

lib/src/marker.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ part of platform_maps_flutter;
22

33
/// Text labels for a [Marker] info window.
44
class InfoWindow {
5-
const InfoWindow({
6-
this.title,
7-
this.snippet,
8-
this.onTap,
9-
});
5+
const InfoWindow({this.title, this.snippet, this.onTap, this.anchor});
106

117
/// Text labels specifying that no text is to be displayed.
128
static const InfoWindow noText = InfoWindow();
@@ -21,18 +17,26 @@ class InfoWindow {
2117
/// A null value means no additional text.
2218
final String snippet;
2319

20+
/// The icon image point that will be the anchor of the info window when
21+
/// displayed.
22+
///
23+
/// The image point is specified in normalized coordinates: An anchor of
24+
/// (0.0, 0.0) means the top left corner of the image. An anchor
25+
/// of (1.0, 1.0) means the bottom right corner of the image.
26+
final Offset anchor;
27+
2428
/// onTap callback for this [InfoWindow].
2529
final VoidCallback onTap;
2630

2731
appleMaps.InfoWindow get appleMapsInfoWindow => appleMaps.InfoWindow(
28-
anchor: Offset(0, 0),
32+
anchor: this.anchor ?? Offset(0, 0),
2933
onTap: this.onTap,
3034
snippet: this.snippet,
3135
title: this.title,
3236
);
3337

3438
googleMaps.InfoWindow get googleMapsInfoWindow => googleMaps.InfoWindow(
35-
anchor: Offset(0, 0),
39+
anchor: this.anchor ?? Offset(0, 0),
3640
onTap: this.onTap,
3741
snippet: this.snippet,
3842
title: this.title,
@@ -43,11 +47,13 @@ class InfoWindow {
4347
InfoWindow copyWith({
4448
String titleParam,
4549
String snippetParam,
50+
Offset anchorParam,
4651
VoidCallback onTapParam,
4752
}) {
4853
return InfoWindow(
4954
title: titleParam ?? title,
5055
snippet: snippetParam ?? snippet,
56+
anchor: anchorParam ?? anchor,
5157
onTap: onTapParam ?? onTap,
5258
);
5359
}

pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: apple_maps_flutter
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "0.1.2+3"
10+
version: "0.1.2+4"
1111
async:
1212
dependency: transitive
1313
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414

1515
google_maps_flutter: ^0.5.28+1
1616

17-
apple_maps_flutter: ^0.1.2+3
17+
apple_maps_flutter: ^0.1.2+4
1818

1919
dev_dependencies:
2020
flutter_test:

0 commit comments

Comments
 (0)