-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[google_maps_flutter] Support for Ground Overlay #8432
base: main
Are you sure you want to change the base?
[google_maps_flutter] Support for Ground Overlay #8432
Conversation
Co-Authored-By: Ville Välimaa <[email protected]>
Co-Authored-By: Ville Välimaa <[email protected]>
c94285d
to
19a7808
Compare
@@ -22,7 +21,7 @@ void main() { | |||
} | |||
|
|||
void runTests() { | |||
const double floatTolerance = 1e-8; | |||
const double floatTolerance = 1e-6; |
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.
Added bigger tolerance as on Android and iOS tests failed as diff was bigger than 1e-8
Color.fromARGB(255, 0, 0, 191), | ||
0.6, | ||
); | ||
await tester.pumpAndSettle(const Duration(seconds: 3)); |
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.
Without this line tests timeouted on Web platform, and we were not able to test ground overlay below.
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.
Were they timing out in all tests, or wasm specifically? I know I had to revisit a bunch of plugins and add a few pump
s and pumpAndSettle
when enabling the wasm tests. See:
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.
@ditman
Note that google_maps_flutter
tests are currently excluded for web platform because failing tests:
https://github.com/flutter/packages/blob/main/script/configs/exclude_integration_web.yaml
New implemented tests pass with and without wasm
enabled, but only if I disable other test sets (that fail because other reasons). The new tests are located in tiles_inspector.dart
and I just run this set, which includes tests for tiles, heatmaps, and ground overlays. This file should probably be renamed or split?
Fixing other tests is out of scope of this PR, but this must include working integration tests for web for new features and functionality.
So when only tiles_inspector.dart tests are enabled tests pass with following commands:
Without wasm
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --web --run-chromedriver --packages=google_maps_flutter/google_maps_flutter
and with wasm
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --web --wasm --run-chromedriver --packages=google_maps_flutter/google_maps_flutter
...es/google_maps_flutter/google_maps_flutter/example/integration_test/src/tiles_inspector.dart
Show resolved
Hide resolved
expect(wll1.weight, wll2.weight); | ||
expect(wll1.point.latitude, moreOrLessEquals(wll2.point.latitude)); | ||
expect(wll1.point.longitude, moreOrLessEquals(wll2.point.longitude)); | ||
group('Heatmaps', () { |
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.
Added Heatmap tests to own group, like tile overlay tests and ground overlay tests.
...ps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart
Show resolved
Hide resolved
...ps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart
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.
This looks really good! I did a pass over everything from web, and mostly just have minor comments and questions.
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Outdated
Show resolved
Hide resolved
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Outdated
Show resolved
Hide resolved
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Outdated
Show resolved
Hide resolved
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Show resolved
Hide resolved
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Outdated
Show resolved
Hide resolved
} | ||
|
||
- (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier { | ||
if (!identifier) { |
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.
Here and in the next method: the identifier params were annotated as non-nullable in the interface, so the implementation code shouldn't be handling nil.
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.
Good catch. Removed the null check.
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.
It's still here in this method.
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.h
Outdated
Show resolved
Hide resolved
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface FGMUtils : NSObject | ||
+ (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap |
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.
These new APIs need declaration comments.
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.
Added.
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 be given a more specific name? It's already the case that this plugin has at least one other file of utils (the conversion function file).
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 renamed it FGMImageUtils
.
final PlatformBitmap image; | ||
final PlatformLatLng? position; | ||
final PlatformLatLngBounds? bounds; | ||
final PlatformDoublePair? anchor; |
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.
Isn't this conceptually a point? We already have PlatformPoint
, so shouldn't need a new PlatformDoublePair
for this unless there's a conceptual difference in meaning here.
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.
Changed this to PlatformPoint.
* refactor: ios groundoverlay improvements * refactor: switch anchor to platformpoint on ios * refactor: refactor global functions * Format ios code --------- Co-authored-by: Joonas Kerttula <[email protected]>
- Add missing NonNull annotations for java - Change zIndex type from double to int for groundOverlays to avoid future issues on iOS platform - Documentation improvements
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.
Just some scattered minor issues remaining. Feel free to split out the first sub-PR at this point!
...google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart
Show resolved
Hide resolved
if (west <= east) { | ||
longitudeOffset = position.longitude - west; | ||
} else { | ||
longitudeOffset = position.longitude - west; |
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.
This is the same in both branches; is that a copy/paste mistake?
If not, it should be factored out of the if/else.
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.
(And if so, that suggests missing test coverage for the behavior in these branches.)
@import GoogleMaps; | ||
|
||
#import <OCMock/OCMock.h> | ||
#import <google_maps_flutter_ios/FGMGroundOverlayController_Test.h> |
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.
It should be before all other imports; see https://google.github.io/styleguide/objcguide.html#order-of-includes
|
||
#import <google_maps_flutter_ios/FGMGroundOverlayController_Test.h> | ||
|
||
#import <OCMock/OCMock.h> |
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.
This should be grouped with the other framework imports. Grouping is by type of thing import, not by @
vs #
.
/// Returns true if a ground overlay with the given identifier exists on the map. | ||
- (bool)hasGroundOverlaysWithIdentifier:(NSString *)identifier; | ||
|
||
/// Returns FGMPlatformGroundOverlay for identifier. |
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.
"Returns the ground overlay with the given identifier."
registrar:(NSObject<FlutterPluginRegistrar> *)registrar | ||
screenScale:(CGFloat)screenScale { | ||
[self setConsumeTapEvents:groundOverlay.clickable]; | ||
[self setVisible:groundOverlay.visible]; |
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.
Based on investigation of similar methods in a recent PR (which hasn't landed), this needs to be last to avoid potential flickering (likely due to Google Maps using its own render thread), so should be at the end of the method, and have a comment saying that nothing should be added after it.
} | ||
|
||
- (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier { | ||
if (!identifier) { |
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.
It's still here in this method.
static UIImage *scaleImage(UIImage *image, double scale); | ||
static UIImage *scaledImageWithScale(UIImage *image, CGFloat scale); | ||
static UIImage *scaledImageWithSize(UIImage *image, CGSize size); | ||
static UIImage *scaledImage(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale); |
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.
The declaration comments for all of these functions should be here, on the declarations, rather than on the definitions below.
#import "FGMImageUtils.h" | ||
#import "Foundation/Foundation.h" | ||
|
||
static UIImage *scaleImage(UIImage *image, double scale); |
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.
This should be scaled
, not scale
, for consistency in naming.
NSNumber *zoomLevel) { | ||
/// Dummy image is used as image is required field of FGMPlatformGroundOverlay and converting | ||
/// image back to bitmap image is not currently supported. | ||
FGMPlatformBitmap *mockImage = |
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.
This should be called placeholderImage
rather than mockImage
, as "mock" generally refers to a specific test construct.
Adds Ground Overlay support for google_maps_flutter plugin.
Fixes flutter/flutter#26479
Android:
iOS:
Web:
Documentation for groundOverlays parameter on app-facing plugin:
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.