Map View 2

文章日期:06/05/2013 02:02 pm

把以下 Object-C 放入 -(void)viewDidLoad 中

step 1: 觀看方法

mapView
.mapType = MKMapTypeHybrid;


step 2: 加入大頭針

// 定位置    

CLLocationCoordinate2D locationOfPuiChing;

locationOfPuiChing.latitude = 22.201392;

locationOfPuiChing.longitude = 113.547864;


// 放下大頭針    

MKPointAnnotation *pin = [[[MKPointAnnotation alloc]init]autorelease];

pin.coordinate = locationOfPuiChing;

pin.title = @"Pui Ching Middle School";

pin.subtitle = @"Av.Horta no.7";

[mapView addAnnotation:pin];


step 3: 拉近距離觀看    


MKCoordinateRegion
region = MKCoordinateRegionMakeWithDistance(locationOfPuiChing, 100.0, 100.0);

[mapView setRegion:region animated:YES];