0

以下は、カスタム アノテーションを配列にロードし、addAnnotations を使用してこの配列をマップに追加するコードです。マップにピンが表示されません。に置き換える[annotations addObject:annotation];[annotations addObject:item.placemark];ピンが表示されますが、それらはカスタム アノテーションではありません。Annotation という customAnnotation クラスがあります。私は何を間違っていますか?

NSMutableArray *annotations = [NSMutableArray array];

                [response.mapItems enumerateObjectsUsingBlock:^(MKMapItem *item, NSUInteger idx, BOOL *stop) {

                    // if we already have an annotation for this MKMapItem,
                    // just return because you don't have to add it again

                    for (id<MKAnnotation>annotation in mapView.annotations)
                    {
                        if (annotation.coordinate.latitude == item.placemark.coordinate.latitude &&
                            annotation.coordinate.longitude == item.placemark.coordinate.longitude)
                        {
                            return;
                        }

                    }


                    // otherwise add it

                    Annotation *annotation = [[Annotation alloc] initWithPlacemark:item.placemark];
                    annotation.title = mapItem.name;
                    annotation.subtitle = mapItem.placemark.addressDictionary[(NSString *)kABPersonAddressStreetKey];
                    [annotations addObject:annotation];

 [self.mapView addAnnotations:annotations];
4

1 に答える 1