tags:

views:

266

answers:

1

i am using MAPKIT, i want to addAnnotations to the map. i having say GPS coordinates of 4-5 locations, and i want to plot them on the map.

i have added one annotation on the map.it works. But when i want to display multiple annotations, i have a problem i am following the same code specified in the below link.

http://blog.objectgraph.com/index.php/2009/04/08/iphone-sdk-30-playing-with-map-kit-part-3/

Please can you guide me, with the code to display multiple annotations. I know, what i have done below is wrong, please help me with the code, i have for now hardcoded the GPS coordinates and placed them in lat and longi array

   NSMutableArray *lat=[[NSMutableArray alloc]initWithCapacity:2];
  NSMutableArray *longi=[[NSMutableArray alloc]initWithCapacity:2];

  NSNumber *firstlat=[[NSNumber alloc] initWithInt:18.222];
  NSNumber *Secondlat=[[NSNumber alloc] initWithInt:18.659089 ];
  NSNumber *firstlongi=[[NSNumber alloc] initWithInt:73.554];
  NSNumber *Secondlongi=[[NSNumber alloc] initWithInt:73.2234 ];

 [lat insertObject:firstlat atIndex:0];
 [lat insertObject:Secondlat atIndex:1];

 [longi insertObject:firstlongi atIndex:0];
 [longi insertObject:Secondlongi atIndex:1];

 NSMutableArray *placemark_array=[[NSMutableArray alloc]init];

 for (NSInteger i=0; i<[lat count]; i++) {

 location.latitude =(int)[lat objectAtIndex:i];


 location.longitude=(int)[longi objectAtIndex:i];


 ParkPlaceMark *placemark=[[ParkPlaceMark alloc]initWithCoordinate:location ];
 [placemark_array addObject:placemark ];


   [mapView addAnnotations: placemark_array];
}


 [self.view insertSubview:mapView atIndex:0];