Skip to content

mrdnote/XamarinClustererDemo

Repository files navigation

XamarinClustererDemo

Clustering port of FBAnnotationClustering by infinum https://github.com/infinum/FBAnnotationClustering

Usage

Add the shared library named "SharpMapKitClusterer" to your iOS project.

Create the clustering manager in your view controller:

List<IMKAnnotation> sampleAnnotations = new List<IMKAnnotation>();
// add annotations to sampleAnnotations here
FBClusteringManager clusteringManager = new FBClusteringManager(sampleAnnotations);

The annotations are not added directly to the map anymore, instead use the RegionChanged event to update the clusters (and "normal" annotations) in the map:

MapView.RegionChanged += (object sender, MKMapViewChangeEventArgs e) =>
{
  double scale = MapView.Bounds.Size.Width / MapView.VisibleMapRect.Size.Width;
  List<IMKAnnotation> annotationsToDisplay = clusteringManager.ClusteredAnnotationsWithinMapRect(MapView.VisibleMapRect, scale);
  clusteringManager.DisplayAnnotations(annotationsToDisplay, MapView);
};

Check out the sample project for usage and how to display a cluster marker with a counter on top of it.

A big thanks goes out to infinum!

©2016 Dnote Software - http://www.dnote.nl

XamarinClustererDemo is available under the MIT license. See the LICENSE file for more info

About

Clustering port of FBAnnotationClustering by infinum https://github.com/infinum/FBAnnotationClustering

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages