I have two NSMutableArray, first keeps some location’s latitudes and second keeps longitudes. Then, I want to see this locations on map with markers. This code shows one point on map but I have several points at NSMutableArray. How can I do this? Is there anyone help me?
- (void)viewDidLoad
{
[super viewDidLoad];
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocationCoordinate2D location;
location.latitude = 40.182533;
location.longitude = 29.066868;
region.span=span;
region.center=location;
if(addAnnotation != nil) {
[mapView removeAnnotation:addAnnotation];
[addAnnotation release];
addAnnotation = nil;
}
addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:location];
[mapView addAnnotation:addAnnotation];
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
// Do any additional setup after loading the view from its nib.
}
You need to create annotation for each lat-lon and add to the mapview. Assuming your lat lon array in balance and order the algorithm can go like below.