0

Displays the interested location on map view which are multiple locations.

MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.coordinate = CLLocationCoordinate2DMake([[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"latitude"] floatValue], [[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"longitude"] floatValue]);
    annotation.title = [[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"name"];
    [mapView selectAnnotation:annotation animated:YES];
    [mapView addAnnotation:annotation];

Its show pinpoint on mapview. On select pinpoints, it does not shows popupbox for MKPointAnnotation.

KkMIW
  • 1,092
  • 1
  • 17
  • 27
  • 1
    First, the selectAnnotation will have no effect unless the annotation is visible (so it must be done after adding it and after it's visible). Second, make sure annotation.title is not blank (NSLog it after setting it). If the title ("name") is blank, callout will not display. –  Oct 16 '14 at 11:01
  • @Anna Thanks its worked.... Want to add one more thing. how to sent an custom image for pinpoints. – KkMIW Oct 16 '14 at 11:47

1 Answers1

0

Your code is perfect just swap this line

[mapView selectAnnotation:annotation animated:YES];
[mapView addAnnotation:annotation];

to this, and run again,

[mapView addAnnotation:annotation];
[self performSelector:@selector(selectAnnoation:) withObject:annotation afterDelay:0.1];


- (void)selectAnnoation:(Annotation *)annotation {
    if(annotation)
    [mapView selectAnnotation:annotation animated:YES];
}
Hemang
  • 26,840
  • 19
  • 119
  • 186