supercluster 0.0.2 copy "supercluster: ^0.0.2" to clipboard
supercluster: ^0.0.2 copied to clipboard

outdated

A port of MapBox's javascript supercluster library for fast marker clustering.

example/supercluster_example.dart

import 'package:supercluster/supercluster.dart';

void main() {
  final supercluster =
      Supercluster<CustomMapPoint>(getX: (p) => p.lon, getY: (p) => p.lat);
  supercluster.load([
    CustomMapPoint(name: 'first', lat: 46, lon: 1.5),
    CustomMapPoint(name: 'second', lat: 46.4, lon: 0.9),
    CustomMapPoint(name: 'third', lat: 45, lon: 19),
  ]);

  final clustersAndPoints =
      supercluster.getClustersAndPoints(0.0, 43, 8, 47, 10).map(
            (e) => e.map(
              cluster: (cluster) => 'A cluster',
              mapPoint: (mapPoint) => mapPoint.data.toString(),
            ),
          );

  print(clustersAndPoints.join(', '));
  // Output: result: first (46.0, 1.5), second (46.4, 0.9)
}

class CustomMapPoint {
  String name;
  final double lat;
  final double lon;

  CustomMapPoint({
    required this.name,
    required this.lat,
    required this.lon,
  });

  @override
  String toString() => '$name ($lat, $lon)';
}
7
likes
0
pub points
84%
popularity

Publisher

verified publisherbalanci.ng

A port of MapBox's javascript supercluster library for fast marker clustering.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

freezed_annotation, kdbush

More

Packages that depend on supercluster