showAnnotations zeigt keine Annotations an

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • showAnnotations zeigt keine Annotations an

    Ich hänge da jetzt schon seit ein paar Tagen fest. So langsam gehen mir die Ideen aus.

    Ich will auf einer Karte 1-n Strecken anzeigen. Jeder Startpunkt einer Strecke soll das gleiche custom.image bekommen. Im Titel der Annotation stehen Streckentypische Informationen
    Ich will alle Annotions anzeigen.
    Das solle mit

    C-Quellcode

    1. [self.mapView showAnnotations:self.mapView.annotations animated:NO];
    funktionieren.

    Irgendetwas mache ich falsch, denn es werden zwar alle Strecken und Custom-Imagaes angezeigt (Bild1) ,aber die Titel erscheinen erst, wenn man auf den Startpunkt einer Strecke tippt (Bilder 2&3).
    1.png 2.png 3.png

    so baue ich die Map auf:

    C-Quellcode

    1. for(NSDictionary *dict in trackingArray)
    2. {
    3. CLLocationCoordinate2D startCoordinate;
    4. startCoordinate.latitude = [[dict objectForKey:@"LatitudeVon"]floatValue];
    5. startCoordinate.longitude = [[dict objectForKey:@"LongitudeVon"]floatValue];
    6. CLLocationCoordinate2D endCoordinate;
    7. endCoordinate.latitude = [[dict objectForKey:@"LatitudeBis"]floatValue];
    8. endCoordinate.longitude = [[dict objectForKey:@"LongitudeBis"]floatValue];
    9. float distance = [self distance:[[dict objectForKey:@"LatitudeVon"]floatValue]
    10. fromLongitude:[[dict objectForKey:@"LongitudeVon"]floatValue]
    11. toLatitude:[[dict objectForKey:@"LatitudeBis"]floatValue]
    12. toLongitude:[[dict objectForKey:@"LongitudeBis"]floatValue]];
    13. HUPointAnnotation *startMarker = [[HUPointAnnotation alloc] init];
    14. startMarker.coordinate = startCoordinate;
    15. startMarker.title = [NSString stringWithFormat:@"%@ %4.0f m",clubName, distance];
    16. startMarker.imageName = @"golfer.png";
    17. [self.mapView addAnnotation:startMarker];
    18. CLLocationCoordinate2D points[2];
    19. points[0] = endCoordinate;
    20. points[1] = startCoordinate;
    21. MKPolyline *polyLine=[MKPolyline polylineWithCoordinates:points count:2];
    22. [self.mapView addOverlay:polyLine];
    23. }
    24. [self.mapView showAnnotations:self.mapView.annotations animated:NO];
    Alles anzeigen

    Quellcode

    1. - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation
    2. {
    3. if ([annotation isKindOfClass:[MKUserLocation class]])
    4. return nil;
    5. if ([annotation isKindOfClass:[HUPointAnnotation class]])
    6. {
    7. HUPointAnnotation *customAnnotation = annotation;
    8. static NSString *annotationIdentifier = @"MyAnnotation";
    9. MKAnnotationView *annotationView = [theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
    10. if (!annotationView)
    11. {
    12. annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
    13. annotationView.canShowCallout = YES;
    14. }
    15. else
    16. {
    17. annotationView.annotation = annotation;
    18. }
    19. annotationView.image = [UIImage imageNamed:customAnnotation.imageName];
    20. //[annotationView setAnnotation:customAnnotation];
    21. return annotationView;
    22. }
    23. return nil;
    24. }
    Alles anzeigen
    HUPointAnnotation.h

    C-Quellcode

    1. #import <MapKit/MapKit.h>
    2. @interface HUPointAnnotation : MKPointAnnotation
    3. @property(nonatomic, strong) NSString *imageName;
    4. @property (nonatomic,copy) NSString *title;
    5. @property (nonatomic,copy) NSString *subtitle;
    6. @end
    HUPointAnnotation.m



    C-Quellcode

    1. #import "HUPointAnnotation.h"
    2. @implementation HUPointAnnotation
    3. @synthesize title, subtitle, imageName;
    4. @end


    wie bekomme ich das hin, dass alle Titel angezeigt werden? ?(
    Ich habe auch keine Loesung, aber ich bewundere das Problem!
    _____________________________________________________


    Hape42