2012-01-03 89 views
1

我成功地從我的tutorial.wat之一獲取當前位置的經度和緯度,我想要將它整合到我的mapview中,以便id獲得一個藍色指示器在我的mapview.i中瞭解添加註釋時的mapview基礎知識,但是如何整合我的當前位置.id如果你們給我提供了一個例子,那麼這會非常有用。下面是代碼。如何在mapview中顯示我目前的位置(GPS)

- (void)locationUpdate:(CLLocation *)location { 
speedLabel.text = [NSString stringWithFormat:@"SPEED: %f", [location speed]]; 
latitudeLabel.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude]; 
longitudeLabel.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude]; 
altitudeLabel.text = [NSString stringWithFormat:@"ALTITUDE: %f", [location altitude]]; 
NSLog(@"will dis :%d",location.coordinate.latitude); 

}

回答

2

獲取表示在地圖上的用戶當前位置的藍指示劑是非常簡單的。剛上包含的MKMapView您的視圖控制器設置

[self.mapView setShowsUserLocation:YES];

此外,在您當前位置附近設置mapView的區域很有用。欲瞭解更多信息,請查詢this Apple's example

+0

感謝Michal dat worked.i有兩個查詢1)我想要一個對話框,是否允許我的應用程序使用currnet位置2)gps區域必須是100米 – kingston 2012-01-03 14:53:32

+0

1)它由系統自動顯示。 2)玩弄我上面提到的示例代碼(特別是檢查方法gotoLocation)。有關如何計算跨度的提示,請參閱http://developer.apple.com/library/ios/#DOCUMENTATION/MapKit/Reference/MapKitDataTypesReference/Reference/reference.html#//apple_ref/doc/uid/TP40009734-CH1 -SW29 – 2012-01-03 14:58:29

+0

mkay ............ – kingston 2012-01-03 15:06:50