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

[google_maps_flutter] Marker APIs are now widget based (Android) #1229

Merged
merged 3 commits into from
Feb 27, 2019
Merged

[google_maps_flutter] Marker APIs are now widget based (Android) #1229

merged 3 commits into from
Feb 27, 2019

Conversation

iskakaushik
Copy link
Contributor

note: This commit only deals with Android side of changes.

Additional Context: Maps Plugin is in the process of being
moved away from a controller based API to a widget based api.
This is to facilitate easier state management and address a
lot of the common issues.

@iskakaushik iskakaushik requested a review from amirh February 15, 2019 19:41
@iskakaushik iskakaushik changed the title [WIP] Marker APIs are now widget based Marker APIs are now widget based Feb 19, 2019
@iskakaushik
Copy link
Contributor Author

iskakaushik commented Feb 19, 2019

I've made changes to the iOS impl at https://github.com/iskakaushik/plugins/pull/2/files, keeping it separate for now though we would want to merge it into this branch before we land this feature.

@iskakaushik iskakaushik changed the title Marker APIs are now widget based Marker APIs are now widget based (Android) Feb 19, 2019
@bparrishMines bparrishMines changed the title Marker APIs are now widget based (Android) [google_maps_flutter] Marker APIs are now widget based (Android) Feb 22, 2019
Kaushik Iska added 2 commits February 22, 2019 13:29
note: This commit only deals with Android side of changes.
@@ -178,6 +153,7 @@ public void onMapReady(GoogleMap googleMap) {
googleMap.setOnCameraIdleListener(this);
googleMap.setOnMarkerClickListener(this);
updateMyLocationEnabled();
this.markersController.setGoogleMap(googleMap);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: omit the this.

*
* <p>To be kept in sync with MarkerId on dart side.
*/
public class MarkerId {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd just keep the marker IDs as Strings in the Android implementation, saves us some boilerplate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking the same, I was hoping that having a type here will let us distinguish between dart marker id and google map api's marker id (which we are keeping as a string).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the name should cover that well enough, it's used in a relatively narrow scope anyway...

methodChannel.invokeMethod("marker#onTap", Convert.toJson(markerId));
MarkerController markerController = markerIdToController.get(markerId);
if (markerController != null) {
return markerController.consumeTapEvents();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to do this here?

Copy link
Contributor Author

@iskakaushik iskakaushik Feb 22, 2019

Choose a reason for hiding this comment

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

The method contract is:

true if the listener has consumed the event (i.e., the default behavior should not occur); false otherwise (i.e., the default behavior should occur). The default behavior is for the camera to move to the marker and an info window to appear.

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener.html#onMarkerClick(com.google.android.gms.maps.model.Marker)

return;
}
for (Object rawMarkerId : markerIdsToRemove) {
if (rawMarkerId != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

uber nit: my personal preference would be to reverse the condition and continue to save one nesting level. Sending you some better articulated explanation offline.

@@ -117,6 +118,15 @@ static Object toJson(CameraPosition position) {
return data;
}

static Object toJson(MarkerId markerId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't change it as part of this PR to stay consistent, but all of these overloads of function with the same name feels error prone to me, I'd consider given each of them a different name, Also it's not converting to JSON but to a map.

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
Contributor

@amirh amirh left a comment

Choose a reason for hiding this comment

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

LGTM

@iskakaushik iskakaushik merged commit 06737e3 into flutter:master Feb 27, 2019
@iskakaushik iskakaushik deleted the feature/marker-api-mod branch February 27, 2019 15:22
romaluca pushed a commit to romaluca/plugins that referenced this pull request Mar 6, 2019
…tter#1229)

* Marker APIs are now widget based (Android)

note: This commit only deals with Android side of changes.

* Fix format

* Remove MarkerId class
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.

4 participants