0
我有一個啓動谷歌地圖應用程序的應用程序。代碼是:CoreLocation當前位置
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[[NSURL alloc] initWithString: @"http://maps.google.com/maps?daddr=Obere+Laube,+Konstanz,+Germany&saddr="]];
saddr =應該是當前位置。我得到的當前位置與
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f,%f", [newLocation coordinate]);
日誌顯示正確的座標一樣
2010-04-05 15:33:25.436 deBordeaux[60657:207] 37.331689,-122.030731
我沒有找到傳送座標到URL字符串的正確途徑。有人可以給我一個提示嗎?
嗯,我在我的.h
入口在我的方法我用「newLocation」,而不是你的「位置」。的代碼是:
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f,%f", [newLocation coordinate]);
NSLog(@"%f", [newLocation coordinate].latitude);
storedLocation = [newLocation coordinate];
NSLog(@"Standort neu String: %@", storedLocation);
作爲結果獲得:
- 2010-04-05 20:28:44.397 deBordeaux [64179:207] 37.331689,-122.030731
- 2010-04-05 20:28:44.398 deBordeaux [64179:207] 37.331689
- 編程接收信號:「EXC_BAD_ACCESS」。
感謝您的快速答覆。我瞭解「ll =」的用法,而不是「saddr =」。我的問題是,UIApplication ....的代碼位於 - (IBAction)nav ...中,後面的位置座標位於#pragma標記CLLocationManagerDelegate中。我找不到在NSString中「存儲」位置座標的方法。 – Christian 2010-04-05 17:45:52