Mono port of the excellent CCHMapClusterController library.
- A NuGet package is available in nuget.org. Simply search for
CCHMapClusterController
.
- The DLL is released using Github Release. Follow this link to find the version you want.
- Open the
CCHMapClusterController-Mono.sln
solution. - Build in Release (or Debug if you want the symbolication).
- Copy the created DLL in the
CCHMapClusterController-Mono/bin/{Debug|Release}
folder to your project. - You're done !
Important note
When the MKMapView
request annotation views, the given IMKAnnotation
may be wrapped in a MKAnnotationWrapper
object (see issue #2).
The workaround consists of calling the runtime to get the underlying NSObject
, see below.
using CCH.MapClusterController;
namespace MyNamespace
{
public partial class MapViewController : UIViewController
{
CCHMapClusterController _mapClusterController;
public MapViewController() : base("MapViewController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var annotations = /* Get annotations */;
_mapClusterController = new CCHMapClusterController(MapView);
_mapClusterController.AddAnnotations(annotations, null);
MapView.Delegate = new MapDelegate();
}
}
internal class MapDelegate : MKMapViewDelegate
{
public MapDelegate() : base()
{
}
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation anno)
{
var annotation = ObjCRuntime.Runtime.GetNSObject(anno.Handle) as CCHMapClusterAnnotation; // this is required to get the underlying annotation object
return null;
}
}
}
- Nicolas VERINAUD (@nverinaud)
- Claus Höfele (original author of the Objective-C library)
Released under the MIT License. For more see LICENSE.md
.