如何在iphone中使用不同的纬度和经度值丢弃多个引脚?
我有10个纬度和经度值。因此,通过使用这些值,我需要在地图中删除10个引脚(取决于纬度值计数)。
答案 0 :(得分:1)
为放置标记创建类
#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
将所有地点信息(使用lat和longi)放在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];
}
}