How to add another annotation in the mapview a certain distance from current location

Wondering how to add another annotation in the mapview a certain distance from current location?

Answers


you can use below sample code;

// .h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface AddressAnnotation : NSObject<MKAnnotation> {
    CLLocationCoordinate2D coordinate;
    NSString *title;
    NSString *subtitle;
    MKPinAnnotationColor pinColor;
}
@property (nonatomic,retain) NSString *title;
@property (nonatomic,retain) NSString *subtitle;
@property (nonatomic, assign) MKPinAnnotationColor pinColor;
@end

// .m
#import "AddressAnnotation.h"

@implementation AddressAnnotation
@synthesize coordinate;
@synthesize title;
@synthesize subtitle;
@synthesize pinColor;
- (NSString *)subtitle{
    return subtitle;
}
- (NSString *)title{
    return title;
}
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
    coordinate=c;
    return self;
}
@end
currentLocation.latitude = latitudeValue;
currentLocation.longitude = longitudeValue;
AddressAnnotation *addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:currentLocation];
[addAnnotation setTitle:@"Title"];
[addAnnotation setPinColor:MKPinAnnotationColorGreen];
[map addAnnotation:addAnnotation];
[addAnnotation release];

otherLocation.latitude = latitudeValue;
otherLocation.longitude = longitudeValue;
addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:otherLocation];
[addAnnotation setTitle:@"otherTitle"];
[map addAnnotation:addAnnotation];
[addAnnotation release];

Need Your Help

Oracle help on syntax error ORA-00907

sql oracle

When I am trying to run code which is similar to the below one, Iam getting ORA-00907: missing right paranthesis error. Seems I have closed all paranthesis correctly.