Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[google_maps_flutter_android] Clustering support review fixes
  • Loading branch information
jokerttu committed Apr 30, 2024
commit 21b4b28bea59316bb3f06958a665f33383d4b862
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ void onClusterItemRendered(@NonNull MarkerBuilder item, @NonNull Marker marker)
@SuppressWarnings("unchecked")
private static String getClusterManagerId(Object clusterManagerData) {
Map<String, Object> clusterMap = (Map<String, Object>) clusterManagerData;
// The "clusterManagerId" key is set at:
// https://github.com/flutter/packages/blob/dce6f0c91fcf01ee3a67e3475155ec9f16ce2a66/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager.dart#L62
return (String) clusterMap.get("clusterManagerId");
}

Expand All @@ -172,7 +174,9 @@ public void getClustersWithClusterManagerId(
ClusterManager<MarkerBuilder> clusterManager = clusterManagerIdToManager.get(clusterManagerId);
if (clusterManager == null) {
result.error(
"Invalid clusterManagerId", "getClusters called with invalid clusterManagerId", null);
"Invalid clusterManagerId",
"getClusters called with invalid clusterManagerId:" + clusterManagerId,
null);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ static Object clusterToJson(String clusterManagerId, Cluster<MarkerBuilder> clus
Object bounds = latLngBoundsToJson(latLngBoundsBuilder.build());

final Map<String, Object> data = new HashMap<>(4);

// For dart side implementation see parseCluster method at
// packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart
data.put("clusterManagerId", clusterManagerId);
data.put("position", position);
data.put("bounds", bounds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ public void onSnapshotReady(Bitmap bitmap) {
}
case "clusterManager#getClusters":
{
// The "clusterManagerId" is set in getClusters method at:
// packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_map_inspector_android.dart
Object clusterManagerId = call.argument("clusterManagerId");
clusterManagersController.getClustersWithClusterManagerId(
(String) clusterManagerId, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ MarkerOptions build() {

/** Update existing markerOptions with builder values */
void update(MarkerOptions markerOptionsToUpdate) {
markerOptionsToUpdate.position(markerOptions.getPosition());
markerOptionsToUpdate.alpha(markerOptions.getAlpha());
markerOptionsToUpdate.anchor(markerOptions.getAnchorU(), markerOptions.getAnchorV());
markerOptionsToUpdate.draggable(markerOptions.isDraggable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ void hideMarkerInfoWindow(String markerId, MethodChannel.Result result) {
markerController.hideInfoWindow();
result.success(null);
} else {
result.error(
"Invalid markerId",
"hideInfoWindow called with invalid markerId or for hidden cluster marker",
null);
result.error("Invalid markerId", "hideInfoWindow called with invalid markerId", null);
}
}

Expand All @@ -111,10 +108,7 @@ void isInfoWindowShown(String markerId, MethodChannel.Result result) {
if (markerController != null) {
result.success(markerController.isInfoWindowShown());
} else {
result.error(
"Invalid markerId",
"isInfoWindowShown called with invalid markerId or for hidden cluster marker",
null);
result.error("Invalid markerId", "isInfoWindowShown called with invalid markerId", null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
}

/// Parses cluster data from dynamic json objects and returns [Cluster] object.
/// Used by `cluster#onTap` method call handler and [getClusters] response parser.
/// Used by the `cluster#onTap` method call handler and the
/// [GoogleMapsInspectorAndroid.getClusters] response parser.
static Cluster parseCluster(
String clusterManagerIdString,
Object positionObject,
Expand Down