I'm writing an app in Xamarin.IOS which has a controller that displays a Google Maps MapView, and I would like to add a marker when the user taps and holds over any point in the map
So far I've tried to add the gesture recognizer to the MapView object, but its not working. This is my code for the map controller:
public async override void ViewDidLoad ()
{
base.ViewDidLoad ();
View.BackgroundColor = UIColor.White;
var geolocator = new Geolocator { DesiredAccuracy = 50 };
location = await geolocator.GetPositionAsync (10000);
var camera = CameraPosition.FromCamera (latitude: location.Latitude,
longitude: location.Longitude, zoom: 6);
mapView = MapView.FromCamera (RectangleF.Empty, camera);
mapView.MyLocationEnabled = true;
var longGesture = new UILongPressGestureRecognizer (LongPress);
longGesture.MinimumPressDuration = 2.0;
mapView.AddGestureRecognizer (longGesture);
mapView.StartRendering ();
View = mapView;
}
public override void ViewWillDisappear (bool animated)
{
mapView.StopRendering ();
base.ViewWillDisappear (animated);
}
[Export("LongPress")]
void LongPress (UILongPressGestureRecognizer gesture)
{
Console.WriteLine (gesture.LocationInView(mapView).X + gesture.LocationInView(mapView).Y);
}
the gesture handler is never called!