Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Google maps marker drag events impl #2838

Merged

Conversation

JamesMcIntosh
Copy link
Contributor

Description

Add events to track start of drag and position during drag

Related Issues

flutter/flutter#26117
#2653

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the [Flutter Style Guide].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the [CLA].
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

Copy link
Contributor

@ened ened left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good.

@JamesMcIntosh JamesMcIntosh force-pushed the google-maps-marker-drag-events-impl branch 4 times, most recently from 51e1faf to f80d45d Compare July 26, 2021 05:09
@stuartmorgan-g stuartmorgan-g requested a review from ditman July 26, 2021 17:46
@ditman
Copy link
Member

ditman commented Jul 26, 2021

@stuartmorgan this is part 2 of #2653, which is blocked in "needs tests" status. I'll try to add some tests to 2653 so this one can be reviewed+merged too!

@JamesMcIntosh
Copy link
Contributor Author

@stuartmorgan this is part 2 of #2653, which is blocked in "needs tests" status. I'll try to add some tests to 2653 so this one can be reviewed+merged too!

Hi @ditman, did you have any suggestions for what tests would be suitable for the platform interface to get this finally merged?

@stuartmorgan-g
Copy link
Contributor

Hi @ditman, did you have any suggestions for what tests would be suitable for the platform interface to get this finally merged?

You should add tests that cover all of the new code you're adding in that PR:

@JamesMcIntosh JamesMcIntosh force-pushed the google-maps-marker-drag-events-impl branch 2 times, most recently from 65741b8 to dceda4d Compare September 22, 2021 11:33
@ditman
Copy link
Member

ditman commented Sep 24, 2021

(Apologies, I didn't mean to do a full review of this, but I got carried away with a bunch of "single comments" :/)

@JamesMcIntosh JamesMcIntosh force-pushed the google-maps-marker-drag-events-impl branch 2 times, most recently from 8f0623c to 693adf9 Compare September 24, 2021 04:18
@JamesMcIntosh
Copy link
Contributor Author

@ditman I've made those changes, it looks like the build is currently failing the submit-queue with test failures in webview_flutter/webview_flutter:
example/integration_test/webview_flutter_test.dart failed tests

@ditman
Copy link
Member

ditman commented Sep 24, 2021

@JamesMcIntosh yes, we suspect those tests are flaky, and most likely don't have anything to do with the changes in this branch. I can restart them to get them to pass!

@ditman
Copy link
Member

ditman commented Sep 24, 2021

I'm more concerned about the web-platform_tests, I suspect they're breaking because of forcing the platform interface to be ^2.1 before implementing the marker events in web. I'm trying to reproduce the issue, but it happens only on this branch, not in the current master (good :P)

@JamesMcIntosh
Copy link
Contributor Author

JamesMcIntosh commented Sep 24, 2021

@ditman You are correct the test is failing because these are not implemented on web. From CI logs:

The following UnimplementedError was thrown running a test:
onMarkerDragEnd() has not been implemented.

I don't think this should stop this PR from being merged as implementing these methods for web need to be done in a separate PR.

@JamesMcIntosh
Copy link
Contributor Author

@ditman I've fixed up the web version and submitted a PR #4385, could you please review it also?

@JamesMcIntosh
Copy link
Contributor Author

JamesMcIntosh commented Sep 29, 2021

@ditman Where are we at now with getting this merged?
Were you able to get a better understanding of the issue which is causing the web-platform to fail?
Can this branch be published with the failing checks?
Will the new PR which I have submitted for the web-platform be enough to fix these failing checks, maybe if it is published first and this branch then rebased on top of it?

@stuartmorgan-g
Copy link
Contributor

Can this branch be published with the failing checks?

No. If something is deliberately being left un-implemented, that un-implemented behavior must not break our automated tests.

Will the new PR which I have submitted for the web-platform be enough to fix these failing checks, maybe if it is published first and this branch then rebased on top of it?

If there's a web implementation already ready to review and land, then landing that first such that this works on all platforms when enabled is much preferable.

@ditman
Copy link
Member

ditman commented Sep 29, 2021

I'm sorry @JamesMcIntosh, I took a couple of days off, but forgot to update my github status before leaving. I'll work on getting this feature merged this week. Thanks for your patience!

@ditman
Copy link
Member

ditman commented Sep 29, 2021

I wanted to understand better this failure, because adding methods to a platform interface should be supported without adding it to all platforms at the same time.

The issue is that google_maps_flutter_web uses google_maps_flutter in one of its integration tests. Since this change inconditionally calls the new methods here when initializing a Maps Controller, the web implementation breaks.

New methods need to be either called conditionally, wrapped in try/catch or avoided (in cross-platform code paths) until the web implementation (actually: all other platforms) land.

(I'll take a look at the web implementation PR mentioned above!)

@ditman ditman self-assigned this Sep 29, 2021
@JamesMcIntosh JamesMcIntosh force-pushed the google-maps-marker-drag-events-impl branch from 693adf9 to 5f527e3 Compare September 29, 2021 20:16
@ditman
Copy link
Member

ditman commented Sep 30, 2021

Will the new PR which I have submitted for the web-platform be enough to fix these failing checks, maybe if it is published first and this branch then rebased on top of it?

Yes, the web PR seems to be enough to fix the tests that are failing in this PR (verified by cloning this branch, and running the web tests, then cherry-picking the web PR and running the tests again).

The only change required to this branch for tests to pass after the web branch is merged is one final rebase with master, since the dependency on the test app is by path, not a download from pub.dev.

@ditman
Copy link
Member

ditman commented Sep 30, 2021

(I've landed the web PR: 90b2844)

@ditman
Copy link
Member

ditman commented Sep 30, 2021

(Pushing the merge with master to see if it makes the tests here green)

@google-cla

This comment has been minimized.

@google-cla google-cla bot added cla: no and removed cla: yes labels Sep 30, 2021
@ditman

This comment has been minimized.

@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 30, 2021
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, a little bit light on the testing front, but at least we're checking that things are being initialized as needed. Let's go!

final GoogleMap googleMap = mock(GoogleMap.class);
controller.setGoogleMap(googleMap);

final zzt z = mock(zzt.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is class zzt? It's being imported from internal, will it keep its name in the future?

Why not mock Marker instead of zzt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may actually be very fragile if it's actually obfuscated code (with a name like that it could very well be).
I think that zzt might be something to do with the map projection but don't quote me, it's been a year and a half since I wrote that so I'm not totally sure without digging back into the source code as creation of Markers is hidden behind a factory pattern.
I just tested mocking only Marker and the test work fine, I'm not not sure why I didn't do that in the first place.
I'll create a new PR with this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for coming back to this one, I'll take a look at the new PR!!

@@ -34,6 +35,7 @@ final List<GoogleMapExampleAppPage> _allPages = <GoogleMapExampleAppPage>[
PlacePolylinePage(),
PlacePolygonPage(),
PlaceCirclePage(),
DragMarkerPage(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another demo that deals with dragging markers, maybe this one can be merged into the PlaceMarkerPage (or the dragging demo of the PlaceMarkerPage can be moved to this one)

Copy link
Contributor Author

@JamesMcIntosh JamesMcIntosh Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged them and add it to the PR #4400

@ditman ditman merged commit f6d93a7 into flutter:master Sep 30, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 30, 2021
NickalasB added a commit to NickalasB/plugins that referenced this pull request Sep 30, 2021
* master:
  [google_maps_flutter] Add Marker drag events (flutter#2838)
  [flutter_plugin_tools] Validate pubspec description (flutter#4396)
  Add file_selector to the repo list (flutter#4395)
  [in_app_purchase] Fix in_app_purchase_android/README.md (flutter#4363)
  [google_maps_flutter_web] Add Marker drag events (flutter#4385)
  [webview_flutter] Fixed todos in FlutterWebView.java (flutter#4394)
  Handle `PurchaseStatus.restored` correctly in example. (flutter#4393)
  Handle restored purchases in iOS example app (flutter#4392)
  [file_selector] Remove custom analysis options (flutter#4382)
  [flutter_plugin_tools] Check licenses in Kotlin (flutter#4373)
  Fixed _CastError when running example App (flutter#4390)
  [in_app_purchase] Ensure the introductoryPriceMicros field is transported as a String. (flutter#4370)
  Load navigation controls immediately. (flutter#4377)
  [camera] Fix IllegalStateException being thrown in Android implementation when switching activities. (flutter#4319)

# Conflicts:
#	packages/webview_flutter/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/webview_flutter_android/CHANGELOG.md
mgonzalezc pushed a commit to mgonzalezc/plugins that referenced this pull request Oct 12, 2021
* master: (1126 commits)
  [webview_flutter] Adjust test URLs again (flutter#4407)
  [google_sign_in] Add serverAuthCode attribute to google_sign_in_platform_interface user data (flutter#4179)
  [camera] Add filter for unsupported cameras on Android (flutter#4418)
  [webview_flutter] Update webview platform interface with new methods for running JavaScript. (flutter#4401)
  [webview_flutter] Add zoomEnabled to webview flutter platform interface (flutter#4404)
  [ci] Remove obsolete Dockerfile (flutter#4405)
  Fix order-dependant platform interface tests (flutter#4406)
  [google_maps_flutter]: LatLng longitude loses precision in constructor #90574 (flutter#4374)
  [google_maps_flutter] Add Marker drag events (flutter#2838)
  [flutter_plugin_tools] Validate pubspec description (flutter#4396)
  Add file_selector to the repo list (flutter#4395)
  [in_app_purchase] Fix in_app_purchase_android/README.md (flutter#4363)
  [google_maps_flutter_web] Add Marker drag events (flutter#4385)
  [webview_flutter] Fixed todos in FlutterWebView.java (flutter#4394)
  Handle `PurchaseStatus.restored` correctly in example. (flutter#4393)
  Handle restored purchases in iOS example app (flutter#4392)
  [file_selector] Remove custom analysis options (flutter#4382)
  [flutter_plugin_tools] Check licenses in Kotlin (flutter#4373)
  Fixed _CastError when running example App (flutter#4390)
  [in_app_purchase] Ensure the introductoryPriceMicros field is transported as a String. (flutter#4370)
  ...

# Conflicts:
#	packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
amantoux pushed a commit to amantoux/plugins that referenced this pull request Dec 11, 2021
KyleFin pushed a commit to KyleFin/plugins that referenced this pull request Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants