children method

List<T>? children(
  1. int? clusterId
)

Returns a list of clusters that are children of the given cluster.

The list is comprised of the original points passed into the constructor or clusters of points (and perhaps other clusters) produced by createCluster().

Implementation

List<T>? children(int? clusterId) {
  if (clusterId == null) {
    return null;
  }

  var originId = clusterId >> 5;
  var originZoom = clusterId % 32;

  var index = _trees[originZoom];
  if (index == null) {
    return null;
  }

  var origin = index.points[originId];

  var r = radius / (extent * math.pow(2, originZoom - 1));
  List<int?> ids = index.within(origin.x ?? 0.0, origin.y ?? 0.0, r);

  var children = <T>[];
  for (var id in ids) {
    var c = index.points[id!];

    if (c.parentId == clusterId) {
      children.add((c.pointsSize != null && c.pointsSize! > 0)
          ? _createCluster!(c, _xLng(c.x!), _yLat(c.y!))
          : _points[c.index!]);
    }
  }

  return children;
}