KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The annotation pin is draggable but I couldn't drop it to the destination location. The problem is how could I get the destination location's coordinate where i drop the annotation pin? Any method exist? Edit 1: The center of the annotation pin seems never changed where ever I drop the pin. - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { NSLog(@"x is %f", annotationView.center.x); NSLog(@"y is %f", annotationView.center.y); CGPoint dropPoint = CGPointMake(annotationView.center.x, annotationView.center.y); CLLocationCoordinate2D newCoordinate = [self.mapView convertPoint:dropPoint toCoordinateFromView:annotationView.superview]; [annotationView.annotation setCoordinate:newCoordinate]; } } Edit 2: Annotation.h @property (nonatomic,readwrite,assign) CLLocationCoordinate2D coordinate; Annotation.m - (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate { coordinate = newCoordinate; } Edit 3: where ever I drag the pin, the NSLog out put of the droppedAt is always the same. - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { CLLocationCoordinate2D droppedAt = annotationView.annotation.coordinate; NSLog(@"Pin dropped at %f,%f", droppedAt.latitude, droppedAt.longitude); } } Edit 4: Annotaion.m @dynamic startAddr; - (CLLocationCoordinate2D)coordinate { coordinate.latitude = [self.startAddr.latitude doubleV
Tags (comma-separated)
Save Edits
Cancel