Skip to content

Commit

Permalink
feat: InfoWindow anchor configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisThein committed Oct 25, 2020
1 parent cf1093e commit 93d9079
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: apple_maps_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+3"
version: "0.1.2+4"
async:
dependency: transitive
description:
Expand Down
20 changes: 13 additions & 7 deletions lib/src/marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ part of platform_maps_flutter;

/// Text labels for a [Marker] info window.
class InfoWindow {
const InfoWindow({
this.title,
this.snippet,
this.onTap,
});
const InfoWindow({this.title, this.snippet, this.onTap, this.anchor});

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

/// The icon image point that will be the anchor of the info window when
/// displayed.
///
/// The image point is specified in normalized coordinates: An anchor of
/// (0.0, 0.0) means the top left corner of the image. An anchor
/// of (1.0, 1.0) means the bottom right corner of the image.
final Offset anchor;

/// onTap callback for this [InfoWindow].
final VoidCallback onTap;

appleMaps.InfoWindow get appleMapsInfoWindow => appleMaps.InfoWindow(
anchor: Offset(0, 0),
anchor: this.anchor ?? Offset(0, 0),
onTap: this.onTap,
snippet: this.snippet,
title: this.title,
);

googleMaps.InfoWindow get googleMapsInfoWindow => googleMaps.InfoWindow(
anchor: Offset(0, 0),
anchor: this.anchor ?? Offset(0, 0),
onTap: this.onTap,
snippet: this.snippet,
title: this.title,
Expand All @@ -43,11 +47,13 @@ class InfoWindow {
InfoWindow copyWith({
String titleParam,
String snippetParam,
Offset anchorParam,
VoidCallback onTapParam,
}) {
return InfoWindow(
title: titleParam ?? title,
snippet: snippetParam ?? snippet,
anchor: anchorParam ?? anchor,
onTap: onTapParam ?? onTap,
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: apple_maps_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+3"
version: "0.1.2+4"
async:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:

google_maps_flutter: ^0.5.28+1

apple_maps_flutter: ^0.1.2+3
apple_maps_flutter: ^0.1.2+4

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 93d9079

Please sign in to comment.