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