У меня есть представление mapView и Annotation, которое отбрасывает булавки в области на основе long / lat для серии объектов, представляющих физические ветви. У меня есть вызов для аннотаций, которые предлагают открыть общее приложение Maps, чтобы дать им указания от их местоположения ... но я не могу понять, как получить адрес из объекта / аннотации филиала и передать его, когда CalloutAccessoryControlTapped срабатывает:
Отраслевые объекты:
CLLocationCoordinate2D newCord;
newCord.latitude = 34.0038;
newCord.longitude = -84.0965;
corp = [[LocationwithAnnotation alloc] initWithCoordinate:newCord];
corp.mTitle = @"Corp Office";
corp.mSubTitle = @"123 Main Street, Duluth GA";
[mapView addAnnotation:corp];
[corp release];
newCord.latitude = 33.0038;
newCord.longitude = -84.3965;
uga = [[LocationwithAnnotation alloc] initWithCoordinate:newCord];
uga.mTitle = @"uga Office";
uga.mSubTitle = @"123 Main Street, Atlanta GA";
[mapView addAnnotation:uga];
[corp release];
Эти аннотации добавляются на карту, а затем, когда вызывается выноска, я хочу иметь возможность передать их в приложение карт с выбранными субтитрами (например, corp).
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
NSLog(@"%@", mapView.selectedAnnotations);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Directions"
message:@"Get directions to this branch?"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles: @"Yes, please", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
MKUserLocation *loc = mapView.userLocation.location;
double latitude = loc.location.coordinate.latitude;
NSString *lat = [NSString stringWithFormat:@"%f",latitude];
double longitude = loc.location.coordinate.longitude;
NSString *lon = [NSString stringWithFormat:@"%f",longitude];
NSString *base = @"http://maps.google.com/maps?";
NSString *dest = [@"daddr=" stringByAppendingString: mapView.SelectedAnnotations; // Doesn't work.
Единственное, что мой NSLog - это дамп, это просто адрес памяти для SelectedAnnotation ... так как я могу получить объект из этого?