-
Notifications
You must be signed in to change notification settings - Fork 63
Slecting Annotation View? ::question:: #23
Comments
Hi @MMasterson, you can do something like this: - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
if ([view.annotation isKindOfClass:[FBAnnotationCluster class]]) {
FBAnnotationCluster *cluster = (FBAnnotationCluster *)view.annotation;
int i = 0;
MKMapPoint points[cluster.annotations.count];
for (id<MKAnnotation> annotation in cluster.annotations){
points[i++] = MKMapPointForCoordinate(annotation.coordinate);
}
MKPolygon *polygon = [MKPolygon polygonWithPoints:points count:i];
MKMapRect newMapRect = [polygon boundingMapRect];
[mapView setVisibleMapRect:newMapRect edgePadding:UIEdgeInsetsMake(50, 50, 50, 50) animated:YES];
}
} |
hi @filipbec , thank you very much for all your work. Thank you |
@Quentin-Malgaud does this help? func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
if (view.annotation is FBAnnotationCluster) {
var cluster: FBAnnotationCluster = view.annotation as! FBAnnotationCluster
var i: Int = 0
var points: MKMapPoint
for annotation: MKAnnotation in cluster.annotations {
points[i++] = MKMapPointForCoordinate(annotation.coordinate)
}
var polygon: MKPolygon = MKPolygon.polygonWithPoints(points, count: i)
var newMapRect: MKMapRect = polygon.boundingMapRect()
mapView.setVisibleMapRect(newMapRect, edgePadding: UIEdgeInsetsMake(50, 50, 50, 50), animated: true)
}
} *Points is the list of the pins you wanna show annotations for |
Hi @MMasterson, thank you very much for this one. Helped me a lot ;)
Thank you again |
How is the select of the annotation fired? I'm trying to snap to a region and display the annotation.
The text was updated successfully, but these errors were encountered: