Tutorial details

Map Annotations | App Code for Sale | Preview

Map Annotations | iOS Tutorial

How to add mapp annotations in your map view

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcodetutorialmapannot.htm

In this tutorial i will be showing you how to add mapp annotations in your map view


  • 1 Class File

In this tutorial i will be showing you how to add map annotations into your map view i carry on from a previous tutorial. So if you are watching this for the first time i suggest you check out the previous tutorial and start there

Add a new class and make sure its a subclass of NSObject Name it NewClass Import the MapKit foundation

NewClass.h PAGE TOP

#import <MapKit/MKAnnotation.h>

@interface NewClass : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
    NSString *title;
    NSString *subtitle;  
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle; 

NewClass.m PAGE TOP

@implementation NewClass
@synthesize coordinate,title,subtitle;

ViewController.m PAGE TOP

#import "NewClass.h"
@implementation ViewController
-(void)viewDidLoad {
    [super viewDidLoad];

    [mapview setMapType:MKMapTypeStandard];
    [mapview setZoomEnabled:YES];
    [mapview setScrollEnabled:YES];

    MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
    region.center.latitude = 52.509078;
    region.center.longitude = -1.884799;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapview setRegion:region animated:YES];

    NewClass *ann = [[NewClass alloc] init];
    ann.title = @"AVFC";
    ann.subtitle = @"Aston Villa Football Club";
    ann.coordinate = region.center;
    [mapview addAnnotation:ann];

Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.