2013-11-14 3 views
0

Размер пузырька аннотацииView слишком мал 9 из 10 раз. Я вызываю [self.mapView selectAnnotation:self.selectedVenue animated:YES];, чтобы показать аннотацию, когда вы выбираете строку. Установил ли я animated:YES или NO он по-прежнему отображает неправильный размер. Однако, если я увеличу размер высоты отображения карты до 200 литров, все будет выглядеть отлично, за исключением того, что изображение карты слишком велико для экрана 3,5 дюйма.MKPinAnnotationView не отображается правильно

Я хочу, чтобы вид на карту был таким размером и пузырем для аннотаций заголовок и подзаголовок правильно

изображение:.. https://dl.dropboxusercontent.com/u/5105730/anno.png

Вот как я создаю мой взгляд аннотаций

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ 

if ([annotation isKindOfClass:[FSVenue class]]) { 
    static NSString *PlaceAnnotationIdentifier = @"Place Identifier"; 

    MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:PlaceAnnotationIdentifier]; 

    if (annotationView == nil) { 
     annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:PlaceAnnotationIdentifier]; 
    } 

    annotationView.annotation = annotation; 

    UIButton *calloutButton = [UIButton buttonWithType:(UIButtonTypeContactAdd)]; 
    calloutButton.tintColor = self.themeColor; 

    annotationView.enabled = YES; 
    annotationView.pinColor = MKPinAnnotationColorGreen; 
    annotationView.canShowCallout = YES; 
    annotationView.rightCalloutAccessoryView = calloutButton; 
    annotationView.animatesDrop = YES; 

    return annotationView; 
} 

return nil; 

}

ответ

0

Вы должны увеличить видимый прямоугольник вашего вида карты, добавив свои аннотации следующим образом.

[self.yourMapview addAnnotations:self.yourAnnotationsArray]; 
[self zoomToAnnotations]; 

Вызов этого метода после добавления аннотации как этот

-(void)zoomToAnnotations{ 

    MKMapRect zoomRect = MKMapRectNull; 

    for (_yourAnnotation in self.yourMapView.annotations) { 
     MKMapPoint annotationPoint = MKMapPointForCoordinate(_yourAnnotation.coordinate); 
     MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1); 
     if (MKMapRectIsNull(zoomRect)) { 
      zoomRect = pointRect; 
     }else{ 
      zoomRect = MKMapRectUnion(zoomRect, pointRect); 
     } 
    } 
    if (zoomRect.size.width == 0.10) /* for single annotation available in map */ 
    { 
     zoomRect = MKMapRectMake(zoomRect.origin.x, zoomRect.origin.y, 100000, 100000); 
    } 

    [[self yourMapView] setVisibleMapRect:zoomRect edgePadding:UIEdgeInsetsMake(50, 50, 50, 50) animated:YES]; 

} 
Смежные вопросы