parseCluster static method

Cluster parseCluster(
  1. String clusterManagerIdString,
  2. Object positionObject,
  3. Map boundsMap,
  4. List markerIdsList,
)

Parses cluster data from dynamic json objects and returns Cluster object. Used by the cluster#onTap method call handler and the GoogleMapsInspectorAndroid.getClusters response parser.

Implementation

static Cluster parseCluster(
    String clusterManagerIdString,
    Object positionObject,
    Map<dynamic, dynamic> boundsMap,
    List<dynamic> markerIdsList) {
  final ClusterManagerId clusterManagerId =
      ClusterManagerId(clusterManagerIdString);
  final LatLng position = LatLng.fromJson(positionObject)!;

  final Map<String, List<dynamic>> latLngData = boundsMap.map(
      (dynamic key, dynamic object) => MapEntry<String, List<dynamic>>(
          key as String, object as List<dynamic>));

  final LatLngBounds bounds = LatLngBounds(
      northeast: LatLng.fromJson(latLngData['northeast'])!,
      southwest: LatLng.fromJson(latLngData['southwest'])!);

  final List<MarkerId> markerIds = markerIdsList
      .map((dynamic markerId) => MarkerId(markerId as String))
      .toList();

  return Cluster(
    clusterManagerId,
    markerIds,
    position: position,
    bounds: bounds,
  );
}