Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to add multiple annotations on Map using this code.

 - (void)showOnMap {   
     sharedRequest = [RequestHandler sharedRquest];

     for (int i=0 ; i<[sharedRequest.dataArray count] ; i++) {

         NSMutableDictionary * location = [[[sharedRequest.dataArray objectAtIndex:i]objectForKey:@"geometry"]objectForKey:@"location"];
        double lat = [[location objectForKey:@"lat"]doubleValue];
         double lng = [[location objectForKey:@"lng"]doubleValue];

         CLLocationCoordinate2D coord = {lat,lng};
         MKPointAnnotation *point = [[MKPointAnnotation alloc]init];
         point.coordinate = coord;
         [self.mapView addAnnotation:point];
     }
     [_spinner stopAnimating]; 
}

EDIT This is the delegate I am using

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    sharedRequest = [RequestHandler sharedRquest];

    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 30000, 30000);
    [self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];

    [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];
}

but this code is not adding annotations.

P.S I am new to MapKit

Any help would be appreciable.

Thanks

share|improve this question
I have few basic Question ,, 1) Sure about IBOutlet --> mapView ? 2) Within the loop , getting the "coord values . Put NSLog () and let us know. ? – Kumar Kl 49 mins ago
I didn't get you. – Deepak Khiwani 46 mins ago
did you connected your mapView to the IBOutlet within the .h or .m of your class file . .? – Kumar Kl 41 mins ago
yea! man I am getting the user location on Map. – Deepak Khiwani 40 mins ago
and R u calling the method For ex: "[self showOnMap]" ; – Kumar Kl 36 mins ago
show 10 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.