2011-05-26 59 views

回答

0
- (IBAction) showCurrentLocation{ 
    MKCoordinateRegion region; 
    MKCoordinateSpan span;  
    span.latitudeDelta=0.007; 
    span.longitudeDelta=0.007; 
    CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate]; 
    //NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude); 

    region.span=span; 
    region.center=location; 


    [mapview setRegion:region animated:TRUE]; 
    [mapview regionThatFits:region];  
} 
0

你需要告訴地圖視圖來顯示用戶的位置(這不是在默認情況下)。這增加了viewDidLoad中

[mapView setShowsUserLocation:YES]; 

注意,在模擬器中,用戶位置總是加州庫柏蒂諾市,所以它取決於地圖的當前中心和縮放,你可能看不到。

+0

你有沒有確切的例子?請給我鏈接 – Chinna 2011-05-26 10:21:59