Xamarin.ios 添加带有点击和按住手势的谷歌地图标记

Xamarin.ios 添加带有点击和按住手势的谷歌地图标记,xamarin.ios,xamarin,google-maps-sdk-ios,Xamarin.ios,Xamarin,Google Maps Sdk Ios,我正在Xamarin.IOS中编写一个应用程序,它有一个显示Google Maps地图视图的控制器,我想在用户点击并按住地图中的任何点时添加一个标记 到目前为止,我已经尝试将手势识别器添加到MapView对象,但它不起作用。这是我的地图控制器代码: public异步重写void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor=UIColor.White; var geolocator=新的geolocator{DesiredAcc

我正在Xamarin.IOS中编写一个应用程序,它有一个显示Google Maps地图视图的控制器,我想在用户点击并按住地图中的任何点时添加一个标记

到目前为止,我已经尝试将手势识别器添加到MapView对象,但它不起作用。这是我的地图控制器代码:

public异步重写void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor=UIColor.White;
var geolocator=新的geolocator{DesiredAccuracy=50};
位置=等待geolocator.GetPositionAsync(10000);
var camera=CameraPosition.FromCamera(纬度:位置。纬度,
经度:位置。经度,缩放:6);
mapView=mapView.FromCamera(矩形F.Empty,camera);
mapView.MyLocationEnabled=true;
var longshirpose=新的UILongPressGestureRecognitor(LongPress);
longshift.MinimumPressDuration=2.0;
mapView.AddGestureRecognitor(长手势);
mapView.StartRendering();
视图=地图视图;
}
公共覆盖无效视图将消失(布尔动画)
{   
mapView.stopredering();
base.viewwill消失(动画);
}
[出口(“LongPress”)]
无效长按(UILongPressGestureRecognitor手势)
{
Console.WriteLine(手势.位置视图(mapView).X+手势.位置视图(mapView).Y);
}

永远不会调用手势处理程序

事实证明,我不需要添加一个手势来完成这项任务。MapView对象公开了一个我可以订阅的事件:

mapView.LongPress += HandleLongPress;
void HandleLongPress (object sender, GMSCoordEventArgs e)
{
//Here I can add my marker. e contains the location point where the user tapped...
}

事实证明,我不需要添加一个手势来实现这一点。MapView对象公开了一个我可以订阅的事件:

mapView.LongPress += HandleLongPress;
void HandleLongPress (object sender, GMSCoordEventArgs e)
{
//Here I can add my marker. e contains the location point where the user tapped...
}

mapView.CoordinatedLongPressed+=HandleLongPress
在我的例子中
mapView.CoordinateLongPress+=HandleLongPress在我的情况下