我創建了一個應用程序,顯示與自定義引腳的自定義地圖上的不同點,並顯示標題和字幕與披露按鈕(所有權利)。當應用程序啓動地圖以創建路徑並提供路線時,問題就會出現。要從用戶的位置移動,我只需輸入URL「saddr =當前位置」即可。當我嘗試給用戶觸摸的目的地時,問題就出現了。谷歌地圖在地圖中的方向共享應用程序到個性化的註釋
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
[self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];
NSString* addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%1.6f%1.6f&saddr=Posizione Attuale", mapView.annotations.coordinate.latitude mapView.annotations.coordinate.longitude];
//也mapview.annotation.coordinate.latitude /經度不起作用
NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
我無法弄清楚如何通過註釋的座標中的一段代碼!
以下是我說,並補充註釋,以我的觀點
NSMutableArray* annotations=[[NSMutableArray alloc] init];
CLLocationCoordinate2D theCoordinate1;
theCoordinate1.latitude = 45.7;
theCoordinate1.longitude = 7.64;
myAnnotation* myAnnotation1=[[myAnnotation alloc] init];
myAnnotation1.coordinate=theCoordinate1;
[email protected]"Pippo";
[email protected]"Ufficio";
[myMapView addAnnotation:myAnnotation1];
這重複名稱不同4個要點(myAnnotation1,2,3,4),並協調其他!當用戶觸及1-2-3或4移動正確的目的地時,我該怎麼辦?
在此先感謝! :)
謝謝安娜,但如果我把NSString * addr = [NSString stringWithFormat:@「http://maps.google.com/maps?daddr=%1.6f%1.6f&saddr=Posizione Attuale」,mapView.annotations。 coordinate.latitude mapView.annotations.coordinate.longitude];它不工作,因爲「找不到屬性座標」。同樣的問題,我找不到我的註釋的經緯度 – TheInterestedOne 2012-02-04 16:09:47
如果我把'view.annotation.coordinate.latitude'和'view.annotation.coordinate.longitude'放在一起,xcode識別它們,但是當我觸摸揭示按鈕出現:「線程1在斷點5停止」,線條綠色突出顯示! :(在我的項目是正確的調用,或者我應該適應這個代碼到我的項目? – TheInterestedOne 2012-02-04 16:17:41
檢查URL對象是否出來nil NSLog addr字符串和url變量 – Anna 2012-02-04 16:53:48