private void OnChangedDragState(object sender, MKMapViewDragStateEventArgs e) { if (e.NewState == MKAnnotationViewDragState.Starting) { _isDragging = true; } _lalitude = e.AnnotationView.Annotation.Coordinate.Latitude; _longitude = e.AnnotationView.Annotation.Coordinate.Longitude; }
/// <summary> /// When the drag state changed /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event Arguments</param> private void OnChangedDragState(object sender, MKMapViewDragStateEventArgs e) { var annotation = e.AnnotationView.Annotation as TKCustomMapAnnotation; if (annotation == null) return; if (e.NewState == MKAnnotationViewDragState.Starting) { this._isDragging = true; } else if (e.NewState == MKAnnotationViewDragState.Dragging) { annotation.CustomPin.Position = e.AnnotationView.Annotation.Coordinate.ToPosition(); } else if (e.NewState == MKAnnotationViewDragState.Ending || e.NewState == MKAnnotationViewDragState.Canceling) { e.AnnotationView.DragState = MKAnnotationViewDragState.None; this._isDragging = false; if (this.FormsMap.PinDragEndCommand != null && this.FormsMap.PinDragEndCommand.CanExecute(annotation.CustomPin)) { this.FormsMap.PinDragEndCommand.Execute(annotation.CustomPin); } } }