Okay Here's what Iam trying to do. I would like to display multiple for the coordinates that are stored as latitudes and longitudes in an array called latlongStrings. They are then broken into array chunks and assigned to newRegions latitude and longitude's. This is the below code.
- (void)gotoLocation
{
MKCoordinateRegion newRegion;
int index = 0;
for(index=0;index<[latlongStrings count];index++)
{
NSArray *chunks = [[latlongStrings objectAtIndex:index] componentsSeparatedByString:@":"];
newRegion.center.latitude = [[chunks objectAtIndex:0] doubleValue];
newRegion.center.longitude = [[chunks objectAtIndex:1] doubleValue];
newRegion.span.latitudeDelta = 0.112872;
newRegion.span.longitudeDelta = 0.109863;
[self.mapView setRegion:newRegion animated:NO];
}
}
My viewDidLoad function looks like this:
- (void)viewDidLoad {
latlongStrings= [[NSMutableArray alloc] init];
[latlongStrings addObject:@"37.786996:-122.440100"];
[latlongStrings addObject:@"37.250556:-96.358333"];
self.mapAnnotations = [[NSMutableArray alloc] init];
AdoptingAnnotation *adAnnotation = [[AdoptingAnnotation alloc] init];
AdoptingAnnotation *ad2 = [[AdoptingAnnotation alloc] init];
[self.mapAnnotations insertObject:adAnnotation atIndex:0];
[self.mapAnnotations insertObject:ad2 atIndex:1];
[adAnnotation release];
[ad2 release];
[self cityAction];
}
- (void)cityAction
{
[self gotoLocation];
[self.mapView removeAnnotations:self.mapView.annotations];
[self.mapView addAnnotations:self.mapAnnotations];
}
The program only renders one location and that is the lastly added location. I am finding it difficult locate all the coordinates and pin them. CityAction is called from viewDidLoad function while gotoLocation is called from cityAction. Please help. Thanks