Skip to content

Commit 8ba9cd0

Browse files
committed
feat: Marker rework
- The Annotation rework of [commit](fluttercommunity/apple_maps_flutter@01e3ea4) from apple_maps_flutter was implemented - The methods showMarkerInfoWindow, hideMarkerInfoWindow and isMarkerInfoWindowShown were added - Scaling of custom markers now works the same way for ios and android - The method BitmapDescriptor.fromBytes was added
1 parent e22eb65 commit 8ba9cd0

File tree

11 files changed

+156
-54
lines changed

11 files changed

+156
-54
lines changed

example/android/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@
1414
<natures>
1515
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
1616
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1602529678411</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
1728
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
15
connection.project.dir=
26
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

example/android/app/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@
2020
<nature>org.eclipse.jdt.core.javanature</nature>
2121
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
2222
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1602529678416</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
2334
</projectDescription>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
eclipse.preferences.version=1
2-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
3-
org.eclipse.jdt.core.compiler.compliance=13
4-
org.eclipse.jdt.core.compiler.source=13
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=12
3+
org.eclipse.jdt.core.compiler.compliance=12
4+
org.eclipse.jdt.core.compiler.source=12

example/pubspec.lock

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@ packages:
77
name: apple_maps_flutter
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "0.1.1+2"
10+
version: "0.1.2+1"
1111
async:
1212
dependency: transitive
1313
description:
1414
name: async
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.4.2"
17+
version: "2.5.0-nullsafety.1"
1818
boolean_selector:
1919
dependency: transitive
2020
description:
2121
name: boolean_selector
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "2.0.0"
24+
version: "2.1.0-nullsafety.1"
2525
characters:
2626
dependency: transitive
2727
description:
2828
name: characters
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.0.0"
31+
version: "1.1.0-nullsafety.3"
3232
charcode:
3333
dependency: transitive
3434
description:
3535
name: charcode
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "1.1.3"
38+
version: "1.2.0-nullsafety.1"
3939
clock:
4040
dependency: transitive
4141
description:
4242
name: clock
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.0.1"
45+
version: "1.1.0-nullsafety.1"
4646
collection:
4747
dependency: transitive
4848
description:
4949
name: collection
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.14.13"
52+
version: "1.15.0-nullsafety.3"
5353
cupertino_icons:
5454
dependency: "direct main"
5555
description:
@@ -63,7 +63,7 @@ packages:
6363
name: fake_async
6464
url: "https://pub.dartlang.org"
6565
source: hosted
66-
version: "1.1.0"
66+
version: "1.2.0-nullsafety.1"
6767
flutter:
6868
dependency: "direct main"
6969
description: flutter
@@ -75,7 +75,7 @@ packages:
7575
name: flutter_plugin_android_lifecycle
7676
url: "https://pub.dartlang.org"
7777
source: hosted
78-
version: "1.0.7"
78+
version: "1.0.11"
7979
flutter_test:
8080
dependency: "direct dev"
8181
description: flutter
@@ -87,35 +87,35 @@ packages:
8787
name: google_maps_flutter
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "0.5.28+1"
90+
version: "0.5.33"
9191
google_maps_flutter_platform_interface:
9292
dependency: transitive
9393
description:
9494
name: google_maps_flutter_platform_interface
9595
url: "https://pub.dartlang.org"
9696
source: hosted
97-
version: "1.0.2"
97+
version: "1.0.4"
9898
matcher:
9999
dependency: transitive
100100
description:
101101
name: matcher
102102
url: "https://pub.dartlang.org"
103103
source: hosted
104-
version: "0.12.8"
104+
version: "0.12.10-nullsafety.1"
105105
meta:
106106
dependency: transitive
107107
description:
108108
name: meta
109109
url: "https://pub.dartlang.org"
110110
source: hosted
111-
version: "1.1.8"
111+
version: "1.3.0-nullsafety.3"
112112
path:
113113
dependency: transitive
114114
description:
115115
name: path
116116
url: "https://pub.dartlang.org"
117117
source: hosted
118-
version: "1.7.0"
118+
version: "1.8.0-nullsafety.1"
119119
platform_maps_flutter:
120120
dependency: "direct main"
121121
description:
@@ -129,7 +129,7 @@ packages:
129129
name: plugin_platform_interface
130130
url: "https://pub.dartlang.org"
131131
source: hosted
132-
version: "1.0.2"
132+
version: "1.0.3"
133133
sky_engine:
134134
dependency: transitive
135135
description: flutter
@@ -141,21 +141,21 @@ packages:
141141
name: source_span
142142
url: "https://pub.dartlang.org"
143143
source: hosted
144-
version: "1.7.0"
144+
version: "1.8.0-nullsafety.2"
145145
stack_trace:
146146
dependency: transitive
147147
description:
148148
name: stack_trace
149149
url: "https://pub.dartlang.org"
150150
source: hosted
151-
version: "1.9.5"
151+
version: "1.10.0-nullsafety.1"
152152
stream_channel:
153153
dependency: transitive
154154
description:
155155
name: stream_channel
156156
url: "https://pub.dartlang.org"
157157
source: hosted
158-
version: "2.0.0"
158+
version: "2.1.0-nullsafety.1"
159159
stream_transform:
160160
dependency: transitive
161161
description:
@@ -169,35 +169,35 @@ packages:
169169
name: string_scanner
170170
url: "https://pub.dartlang.org"
171171
source: hosted
172-
version: "1.0.5"
172+
version: "1.1.0-nullsafety.1"
173173
term_glyph:
174174
dependency: transitive
175175
description:
176176
name: term_glyph
177177
url: "https://pub.dartlang.org"
178178
source: hosted
179-
version: "1.1.0"
179+
version: "1.2.0-nullsafety.1"
180180
test_api:
181181
dependency: transitive
182182
description:
183183
name: test_api
184184
url: "https://pub.dartlang.org"
185185
source: hosted
186-
version: "0.2.17"
186+
version: "0.2.19-nullsafety.2"
187187
typed_data:
188188
dependency: transitive
189189
description:
190190
name: typed_data
191191
url: "https://pub.dartlang.org"
192192
source: hosted
193-
version: "1.2.0"
193+
version: "1.3.0-nullsafety.3"
194194
vector_math:
195195
dependency: transitive
196196
description:
197197
name: vector_math
198198
url: "https://pub.dartlang.org"
199199
source: hosted
200-
version: "2.0.8"
200+
version: "2.1.0-nullsafety.3"
201201
sdks:
202-
dart: ">=2.9.0-14.0.dev <3.0.0"
202+
dart: ">=2.10.0-110 <2.11.0"
203203
flutter: ">=1.16.3 <2.0.0"

lib/platform_maps_flutter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library platform_maps_flutter;
22

33
import 'dart:io';
4+
import 'dart:typed_data';
45

56
import 'package:flutter/cupertino.dart';
67
import 'package:flutter/foundation.dart';

lib/src/bitmap.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,13 @@ class BitmapDescriptor {
4949
}
5050
return BitmapDescriptor._(bitmap);
5151
}
52+
53+
/// Creates a BitmapDescriptor using an array of bytes that must be encoded
54+
/// as PNG.
55+
static BitmapDescriptor fromBytes(Uint8List byteData) {
56+
var bitmap = Platform.isAndroid
57+
? googleMaps.BitmapDescriptor.fromBytes(byteData)
58+
: appleMaps.BitmapDescriptor.fromBytes(byteData);
59+
return BitmapDescriptor._(bitmap);
60+
}
5261
}

lib/src/controller.dart

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,64 @@ class PlatformMapController {
1212
}
1313
}
1414

15+
/// Programmatically show the Info Window for a [Marker].
16+
///
17+
/// The `markerId` must match one of the markers on the map.
18+
/// An invalid `markerId` triggers an "Invalid markerId" error.
19+
///
20+
/// * See also:
21+
/// * [hideMarkerInfoWindow] to hide the Info Window.
22+
/// * [isMarkerInfoWindowShown] to check if the Info Window is showing.
23+
Future<void> showMarkerInfoWindow(MarkerId markerId) {
24+
assert(markerId != null);
25+
if (Platform.isAndroid) {
26+
return googleController.showMarkerInfoWindow(markerId.googleMapsMarkerId);
27+
} else if (Platform.isIOS) {
28+
return appleController
29+
.showMarkerInfoWindow(markerId.appleMapsAnnoationId);
30+
}
31+
throw ('Platform not supported.');
32+
}
33+
34+
/// Programmatically hide the Info Window for a [Marker].
35+
///
36+
/// The `markerId` must match one of the markers on the map.
37+
/// An invalid `markerId` triggers an "Invalid markerId" error.
38+
///
39+
/// * See also:
40+
/// * [showMarkerInfoWindow] to show the Info Window.
41+
/// * [isMarkerInfoWindowShown] to check if the Info Window is showing.
42+
Future<void> hideMarkerInfoWindow(MarkerId markerId) {
43+
assert(markerId != null);
44+
if (Platform.isAndroid) {
45+
return googleController.hideMarkerInfoWindow(markerId.googleMapsMarkerId);
46+
} else if (Platform.isIOS) {
47+
return appleController
48+
.hideMarkerInfoWindow(markerId.appleMapsAnnoationId);
49+
}
50+
throw ('Platform not supported.');
51+
}
52+
53+
/// Returns `true` when the [InfoWindow] is showing, `false` otherwise.
54+
///
55+
/// The `markerId` must match one of the markers on the map.
56+
/// An invalid `markerId` triggers an "Invalid markerId" error.
57+
///
58+
/// * See also:
59+
/// * [showMarkerInfoWindow] to show the Info Window.
60+
/// * [hideMarkerInfoWindow] to hide the Info Window.
61+
Future<bool> isMarkerInfoWindowShown(MarkerId markerId) {
62+
assert(markerId != null);
63+
if (Platform.isAndroid) {
64+
return googleController
65+
.isMarkerInfoWindowShown(markerId.googleMapsMarkerId);
66+
} else if (Platform.isIOS) {
67+
return appleController
68+
.isMarkerInfoWindowShown(markerId.appleMapsAnnoationId);
69+
}
70+
throw ('Platform not supported.');
71+
}
72+
1573
/// Starts an animated change of the map camera position.
1674
///
1775
/// The returned [Future] completes after the change has been started on the
@@ -22,6 +80,7 @@ class PlatformMapController {
2280
} else if (Platform.isAndroid) {
2381
return this.googleController.animateCamera(cameraUpdate);
2482
}
83+
throw ('Platform not supported.');
2584
}
2685

2786
/// Changes the map camera position.

lib/src/marker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class InfoWindow {
5353
}
5454
}
5555

56-
/// Uniquely identifies a [Marker] among [GoogleMap] markers.
56+
/// Uniquely identifies a [Marker] among [PlatformMaps] markers.
5757
///
5858
/// This does not have to be globally unique, only unique among the list.
5959
@immutable

0 commit comments

Comments
 (0)