Search code examples
iphoneiosmapkitmkannotation

How can get new location from below method


-(void)mapView:(MKMapView *)mapView 
    annotationView:(MKAnnotationView *)view                  
    didChangeDragState:(MKAnnotationViewDragState)newState 
    fromOldState:(MKAnnotationViewDragState)oldState

Solution

  • You an use this:

    - (void)mapView:(MKMapView *)mapView 
            annotationView:(MKAnnotationView *)annotationView 
            didChangeDragState:(MKAnnotationViewDragState)newState 
            fromOldState:(MKAnnotationViewDragState)oldState 
    {
        if (newState == MKAnnotationViewDragStateEnding)
        {
            CLLocationCoordinate2D droppedAt = annotationView.annotation.coordinate;
            NSLog(@"dropped at %f,%f", droppedAt.latitude, droppedAt.longitude);
        }
    }
    

    This will give you the coordinates of the final location when the MKAnnotationView is dropped.