• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

まずは地図を表示して、現在位置にピンを立てるところまで。
MKMap-1.png

via

http://blog.objectgraph.com/index.php/2009/04/02/iphone-sdk-30-playing-with-map-kit/

MapKit.frameworkを追加する

MapKit.png

Controller.hでMapKit/MapKit.hをImport

MapKit/MapKit.hをImportして、MKMapViewをプロパティに持つ:

   1  #import <UIKit/UIKit.h>
   2  #import <MapKit/MapKit.h>
   3  
   4  @interface MapTutorialViewController : UIViewController {
   5  	MKMapView *_mapView;
   6  }
   7  
   8  @end

Controller.mでMKMapViewを初期化

showsUserLocationをTRUEにすることで、現在の居場所にピンを立ててくれる。

   1  - (void)viewDidLoad {
   2      [super viewDidLoad];
   3  
   4  	_mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
   5  	_mapView.showsUserLocation=TRUE;
   6  	[self.view addSubview:_mapView];

実機でやると、地図は出るが現在位置に近い地図でないので??ですが、それはまた次で。

posted by Png satoko on Thu 3 Sep 2009 at 16:37

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry1596
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ