query method

Iterable<T> query(
  1. LatLngBounds queryBounds
)

Returns all items whose bounds overlap with the given queryBounds.

This is a "broad phase" check. It returns potential matches. Precise geometry checks (like point-in-polygon) should be done on the results.

Implementation

Iterable<T> query(LatLngBounds queryBounds) sync* {
  final visited = <Key>{};

  for (final hash in _getHashes(queryBounds)) {
    final bucket = _buckets[hash];
    if (bucket == null) continue;

    for (final key in bucket) {
      if (visited.add(key)) {
        final entry = _items[key]!;
        // Precise bounds overlap check
        if (entry.bounds.isOverlapping(queryBounds)) {
          yield entry.item;
        }
      }
    }
  }
}