-(void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
didChangeDragState:(MKAnnotationViewDragState)newState
fromOldState:(MKAnnotationViewDragState)oldState
Q
如何從以下方法
2
A
回答
6
0
您可以檢查拖動狀態,然後使用annotationView.annotation.coordinate.latitude
和annotationView.annotation.coordinate.latitude
您將獲得新位置的座標。
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState
{
//if dragging ended
if (newState == MKAnnotationViewDragStateNone && oldState == MKAnnotationViewDragStateEnding) {
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 0.00212872;
span.longitudeDelta = 0.00212872;
CLLocationCoordinate2D location;
location.latitude = annotationView.annotation.coordinate.latitude;
location.longitude = annotationView.annotation.coordinate.longitude;
[self getAddress:location.latitude withLong:location.longitude];
region.span = span;
region.center = location;
if (addAnnotation != nil) {
[myMap removeAnnotation:addAnnotation];
[addAnnotation release];
addAnnotation = nil;
}
addAnnotation = [[Annotation alloc] init];
addAnnotation.coordinate = location;
[myMap addAnnotation:addAnnotation];
[myMap setRegion:region animated:YES];
[myMap regionThatFits:region];
}
}
addAnnotation是Annotation
的對象。
相關問題
- 1. 如何在以下情況下模擬方法調用?
- 2. Rspec爲以下方法
- 3. 破譯以下方法
- 4. 如何從方法
- 5. 如何從方法
- 6. Java枚舉方法何時重寫以下方法?
- 7. PHP:從下拉get方法
- 8. 如何使用替代方法解決以下復發問題?
- 9. 如何在listview中取消插入以下方法asp.net vb
- 10. 如何編寫識別以下語言的單詞的方法
- 11. 如何使用PInvoke方法聲明以下內容?
- 12. 如何對以下方法進行單元測試
- 13. 如何使用以下方法獲取許多額外數據?
- 14. 我如何收拾以下POST JAVA方法
- 15. 以下方法的複雜程度如何?
- 16. 如何使用以下方法反轉字符串數組?
- 17. 如何在Java 8流中編寫以下方法?
- 18. 如何以編程方式從網站下載圖片?
- 19. 如何以編程方式從SharePoint站點下載文件?
- 20. 如何以編程方式從網站下載文件c#
- 21. 如何以編程方式從Google Play下載APK文件?
- 22. 如何從方法Collectors.groupingBy
- 23. 如何從一個方法
- 24. 如何從一個方法
- 25. 如何從匿名方法
- 26. 如何從一個方法
- 27. add方法以類從NSManagedObject
- 28. 基本的泛型方法以及如何從非泛型類調用方法?
- 29. 如何從Java Kotlin方法調用以換碼字符命名的方法?
- 30. 如何從靜態上下文中引用非靜態方法
接受按鈕在哪裏? – Gaurav 2013-03-05 11:44:14