ページ

2011年5月27日金曜日

XcodeでiPhoneシミュレータにMapを表示させる





myMapViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface myMapViewController : UIViewController {

 MKMapView *mapView;
}

@property(nonatomic,retain) IBOutlet MKMapView *mapView;

@end



myMapViewController.m
#import "myMapViewController.h"

@implementation myMapViewController

@synthesize mapView;


- (void)viewDidLoad {
    [super viewDidLoad];
 
 mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
 
 mapView.mapType = MKMapTypeHybrid;
 
 CLLocationCoordinate2D coord = {latitude: 35.660208, longitude:139.729078};
 MKCoordinateSpan span = {latitudeDelta: 0.001, longitudeDelta: 0.001};
 
 MKCoordinateRegion region = {coord,span};
 [mapView setRegion:region];
 
 [self.view addSubview:mapView];
}

- (void)didReceiveMemoryWarning {
 // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
 
 // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
 // Release any retained subviews of the main view.
 // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end



参考


YouTube - Xcode Tutorial: MapView Set Location
http://www.youtube.com/watch?v=FLc6GIA3syY&hd=1

MKMapView tutorial using latitude and longitude - iPhone Dev SDK Forum
http://www.iphonedevsdk.com/forum/tutorial-discussion/39374-mkmapview-tutorial-using-latitude-longitude.html

0 件のコメント:

コメントを投稿