0

How can I drop multiple pins using different latitude and longitude values in iphone?

I have the 10 latitude and longitude values. So, by using those values I need to drop the 10 pins in map (depends on the latitude values count).

j0k
  • 22,600
  • 28
  • 79
  • 90
Pavne
  • 89
  • 8
  • 1
    [What have you tried?](http://whathaveyoutried.com/) – rckoenes Feb 07 '13 at 13:25
  • Search around u'll have numerous answers. like http://stackoverflow.com/questions/11221291/i-am-trying-to-drop-multiple-pins-on-a-map-view-but-getting-error and this https://www.google.com/url?q=http://stackoverflow.com/questions/6688718/map-view-dropping-multiple-pins&sa=U&ei=zqsTUcbUIoKNmQXUq4DQDg&ved=0CAsQFjAC&client=internal-uds-cse&usg=AFQjCNHOKcX8VkveIxOHL2xEW8Jekjgfjw ect – rptwsthi Feb 07 '13 at 13:26

1 Answers1

1

create class for put place mark

#import <MapKit/MapKit.h>

@interface DDAnnotation : MKPlacemark 

// Re-declare MKAnnotation's readonly property 'coordinate' to readwrite. 
@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;

@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *subtitle;

@end

/////// implimentation

#import "DDAnnotation.h"

@implementation DDAnnotation

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
{
    if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
    {
        self.coordinate = coordinate;
    }
    return self;
}
@end

Put all place information (with lat and longi) in self.listOfPlaces

- (void)showAllPlaces
{

    for(int i=0; i<self.listOfPlaces.count; i++)
    {
        NSMutableDictionary *cPlace = [self.listOfPlaces objectAtIndex:i];
        CLLocationCoordinate2D pCoordinate ;
        pCoordinate.latitude = [[cPlace objectForKey:@"latitude"] doubleValue];
        pCoordinate.longitude = [[cPlace objectForKey:@"longitude"] doubleValue];

        DDAnnotation *annotation = [[DDAnnotation alloc] initWithCoordinate:pCoordinate addressDictionary:nil] ;

        annotation.title = [cPlace objectForKey:@"placeName"];
        annotation.subtitle = [cPlace objectForKey:@"placeDescription"];
        annotation.image = [cPlace objectForKey:@"markerImage"];
        annotation.placeID = [cPlace objectForKey:@"placeID"];

        [self.mapView addAnnotation:annotation];
    }
    }
iPatel
  • 46,010
  • 16
  • 115
  • 137
  • I used this sample code .but Im getting all pins are at one place. how can i get the pins at different places depends on latitude and longitude values? – Pavne Feb 15 '13 at 06:26
  • @Pavne- it is problem of your lat and long value (may be same ) – iPatel Mar 02 '13 at 03:47