我正在創建一個MKMapView應用程序,用戶可以在其中將註釋引腳拖放到任何特定位置。直到現在它的工作。但是我想要什麼,當用戶點擊刷新按鈕時,註釋引腳應該轉到當前用戶的位置。 所以按鈕點擊什麼,我不得不做出讓the pin should move from dragged location to user's location.
MKMapView註釋拖放引腳,轉到用戶位置按鈕單擊
感謝
我正在創建一個MKMapView應用程序,用戶可以在其中將註釋引腳拖放到任何特定位置。直到現在它的工作。但是我想要什麼,當用戶點擊刷新按鈕時,註釋引腳應該轉到當前用戶的位置。 所以按鈕點擊什麼,我不得不做出讓the pin should move from dragged location to user's location.
MKMapView註釋拖放引腳,轉到用戶位置按鈕單擊
感謝
我只是給你基本的邏輯,也許對你有所幫助。
當你的應用程序。當時第一次運行將當前的緯度和經度值添加到特定的變量字段。 (做持續的阻力和註釋的下降。過程再經過)
當你點擊刷新按鈕,然後先寫
[mapView removeAnnotations:mapView.annotations];
對於刪除您的註釋MapView類。
然後在得到latitude
和longitude
的值後,從您的變量。 並根據經緯度和長變量編寫添加註釋的代碼。
您的解決方案正在運行。但問題是兩個針腳舊的和新的用戶位置。我只是想刪除舊的引腳。因爲我正在使用自定義圖像的引腳。 [mapView removeAnnotations:mapView.annotations];工作,但是當我縮放地圖上顯示拖動的引腳。這裏有任何幫助。 – user1997951 2013-03-28 10:43:59
@ user1997951-你有不同的針顏色,然後這個答案http://stackoverflow.com/questions/5049280/remove-mkmapview-annotations-with-a-certain-pincolor或http://stackoverflow.com/questions/13278659 /(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id
- MKAnnotationView * a = [[MKAnnotationView alloc] initWithAnnotation:註解reuseIdentifier:@「currentloc」]; 如果(a == nil) a = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@「currentloc」]; a.image = [UIImage imageNamed:@「1234.png」]; a.draggable = YES; a.canShowCallout = YES; ''。這個方法每次調用時都會縮放,同時拖動引腳和當前用戶位置都會顯示。 – user1997951 2013-03-28 10:51:36
- (void)moveToCurrentLocation:(id)sender
{
[mymapview setCenterCoordinate:[mymapview.userLocation coordinate] animated:YES];
}
IT將地圖視圖移動到您的當前位置(用戶的位置),並刪除當前標註爲iPatel在以前的評論說。
使用GPS位置查找當前位置,之後將其移動該引腳到LAT-LON位置 – 2013-03-28 09:29:16
這可能會幫助你 http://stackoverflow.com/questions/5326690/how-to-find-獲取經緯度location-using-mapkit-in-xcode – 2013-03-28 09:36:18