-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_maps_flutter] Add Advanced Markers support #7882
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?
[google_maps_flutter] Add Advanced Markers support #7882
Conversation
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.
High level android code review. I am concerned by having to runtime type check class.
That said thank you for opening this pull request.
packages/google_maps_flutter/google_maps_flutter/example/android/app/build.gradle
Outdated
Show resolved
Hide resolved
...r_android/android/src/main/java/io/flutter/plugins/googlemaps/ClusterManagersController.java
Outdated
Show resolved
Hide resolved
...r_android/android/src/main/java/io/flutter/plugins/googlemaps/ClusterManagersController.java
Show resolved
Hide resolved
...flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java
Show resolved
Hide resolved
...ps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java
Show resolved
Hide resolved
...ps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/MarkerController.java
Outdated
Show resolved
Hide resolved
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.
I've only looked at the app-facing and platform interface packages so far, but there are some fundamental structure questions at the interface layer.
...ages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample_advanced_markers.dart
Outdated
Show resolved
Hide resolved
...ages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample_advanced_markers.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/glyph.dart
Outdated
Show resolved
Hide resolved
...gle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart
Outdated
Show resolved
Hide resolved
...gle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart
Outdated
Show resolved
Hide resolved
...s_flutter/google_maps_flutter_platform_interface/lib/src/types/map_widget_configuration.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart
Outdated
Show resolved
Hide resolved
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.
App-facing and platform interface look good, so once the platform reviews are in this can be split apart.
...ps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart
Outdated
Show resolved
Hide resolved
...oogle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/advanced_marker.dart
Outdated
Show resolved
Hide resolved
...oogle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/advanced_marker.dart
Show resolved
Hide resolved
@reidbaker @vashworth could you please give this another round of review? All comments should be resolved now |
@aednlaxer this has to do with (possible) differences in implementation of those types in JS vs WASM (the failing tests are WASM ones, it seems). Have you tried compiling your demo app with I can't take a look right now, but will try to figure out a patch later this week. (PS: I suspect this needs a strategic |
style: config.style, | ||
); | ||
} | ||
|
||
PlatformMarkerType? _platformMarkerTypeFromMarkerType(MarkerType? markerType) { |
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.
Github won't let me add a comment on the line, but collisionBehavior
needs to be added to _platformMarkerFromMarker
function above. Currently collisionBehavior
is always being set to null. There should also probably be a test that should have caught this.
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.
Great catch, thanks! I've added a test for updateMarkers
that works with AdvancedMarker
s and a check for collisionBehavior
there. Do you think it's worth adding a test just for _platformMarkerTypeFromMarkerType
?
….com:CodemateLtd/packages into feature/google-maps-advanced-markers-support
packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart
Outdated
Show resolved
Hide resolved
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.
Overall, the Android implementation looks good to me! Left some questions regarding testing.
final String backgroundColorKey = "backgroundColor"; | ||
final String borderColorKey = "borderColor"; | ||
final String glyphTextKey = "glyphText"; | ||
final String glyphTextColorKey = "glyphTextColor"; | ||
final String glyphColorKey = "glyphColor"; | ||
final String glyphBitmapDescriptorKey = "glyphBitmapDescriptor"; |
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.
Are these used?
@@ -327,6 +328,20 @@ public void GetBitmapFromBytesThrowsErrorIfInvalidImageData() { | |||
fail("Expected an IllegalArgumentException to be thrown"); | |||
} | |||
|
|||
@Test | |||
public void GetBitmapFromPinConfig() { |
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.
Can this test be modified to ensure that PinConfig
s are created as expected?
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.
Can you add a test for isAdvancedMarkersAvailable
?
@@ -115,6 +120,13 @@ public void setZIndex(float zIndex) { | |||
markerOptions.zIndex(zIndex); | |||
} | |||
|
|||
@Override | |||
public void setCollisionBehavior(@AdvancedMarkerOptions.CollisionBehavior int collisionBehavior) { |
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.
I think it may be nice to add setCollisionBehavior
tests for the two implementation in this PR.
@@ -1949,6 +2040,33 @@ void googleMapsTests() { | |||
// https://github.com/flutter/flutter/issues/131071 | |||
skip: true, | |||
); | |||
|
|||
testWidgets('markerWithPinConfig', (WidgetTester tester) async { |
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.
Is this testing anything? Can we remove it?
This PR adds Advanced Markers support to
google_maps_flutter
as discussed in #155526. The document from the issue offers several options to implement Advanced Markers support, this PR uses option 1 (Advanced Marker Dart class is a subclass Marker class).Summary of changes:
AdvancedMarker
classMarkerCollisionBehavior
enum to control Advanced Marker's behavior when it collides with another markerPinConfig
bitmap descriptor for customizing Advanced Marker's pin and iconmarkerType
parameter to indicate that Advanced Markers should be usedcloudMapId
tomapId
Notes:
markerType
option when creating aGoogleMap
(could bemarker
oradvancedMarker
). Default option ismarker
cloudMapId
is deprecated in favor ofmapId
. New name follows SDKs, documentation and Cloud Console naming.gmaps.Marker
andgmaps.AdvancedMarkerElement
are not related to each other and should be handled differentlygoogle_maps_flutter
still uses them by default in this PR because of backward-compatibility. #130472 is related, package users will be able to use Advanced Markers to fix the deprecation warningResolves #155526
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.