原文地址:iOS中地图的添加(定位、划线和添加大头针)
作者:伤心的小果冻
// ViewController.h
// xiaoguodongMapTest
//
// Created by Dong on 13-10-4.
// Copyright (c) 2013年 dong. All rights reserved.
//
#import
#import
#import
@interface ViewController : UIViewController
{
}
@end
//
// ViewController.m
// xiaoguodongMapTest
//
// Created by Dong on 13-10-4.
// Copyright (c) 2013年 dong. All rights reserved.
//
#import "ViewController.h"
#import "customAnnotation.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)createRoute
{
}
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
{
}
-(void)createAnnotationWithCoor ds:(CLLocationCoordinate2D) coords {
//customAnnotation *annotation = [[customAnnotation alloc] init];
//点击大头针出现的标题和子标题
annotation.title = @"标题";
annotation.subtitle = @"子标题";
[map addAnnotation:annotation];
}
- (void)viewDidLoad
{
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
}
@end
// customAnnotation.h
// xiaoguodongMapTest
//
// Created by Dong on 13-10-5.
// Copyright (c) 2013年 dong. All rights reserved.
//
#import
#import
@interface customAnnotation : NSObject
{
}
@property (nonatomic , readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic , retain) NSString *title;
@property (nonatomic , retain) NSString *subtitle;
-(id) initWithCoordinate: (CLLocationCoordinate2D)coords;
@end
//
// customAnnotation.m
// xiaoguodongMapTest
//
// Created by Dong on 13-10-5.
// Copyright (c) 2013年 dong. All rights reserved.
//
#import "customAnnotation.h"
@implementation customAnnotation
@synthesize coordinate,subtitle,title;
-(id) initWithCoordinate: (CLLocationCoordinate2D)coords
{
}
@end