我已經添加了地圖視圖,並添加了需要的map-kit框架工作和核心位置框架,使用iOS6,我添加了這些方法,但沒有獲取當前座標,因此我可以顯示gps跟蹤指標。從CLLocationManager獲取座標
下面是代碼:地圖
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
CLLocation* location = [locations lastObject];
NSLog(@"first time -- locations.count = %d", locations.count);
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) > 15.0) {
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
}
}
它給我的默認值(北緯37.785834,-122.406417經度),而不是我的地方的當前位置。
如果您在模擬器中試用它,您將獲得默認值。您必須在設備上運行代碼才能獲得實際的座標值。 – 2013-03-12 04:31:50
非常感謝你Vidya Murthy,還有一件事,我有閱讀reywenderlich教程,他下載了一些文件,以顯示谷歌地圖中的街道或路徑使用gps進行跟蹤,這是必需的。 – terminator 2013-03-12 04:38:32
我想加入你的進一步討論,我的Gmail郵箱[email protected]給你的鏈接郵件 – terminator 2013-03-12 04:45:53