protected override void OnAttached() { var mapView = Control as MapView; if (mapView == null) { throw new NotSupportedException(Control.GetType() + " is not supported."); } behavior = (Element as Map)?.Behaviors?.OfType <ClickBehavior>()?.FirstOrDefault(); if (behavior == null) { return; } // GoogleMapインスタンスを得る var callback = new OnMapReadyCallback(); callback.OnMapReadyAction = (gMap) => { googleMap = gMap; googleMap.MapClick += GoogleMap_MapClick; googleMap.MapLongClick += GoogleMap_MapLongClick; }; mapView.GetMapAsync(callback); }
protected override void OnDetached() { mapView.RemoveGestureRecognizer(tapGesture); tapGesture.Dispose(); tapGesture = null; longPressGesture.Dispose(); longPressGesture = null; mapView = null; behavior = null; }
protected override void OnAttached() { mapControl = Control as MapControl; if (mapControl == null) { throw new NotSupportedException(Control.GetType() + " is not supported."); } behavior = (Element as Map)?.Behaviors?.OfType <ClickBehavior>()?.FirstOrDefault(); if (behavior == null) { return; } mapControl.MapTapped += MapControl_MapTapped; mapControl.MapHolding += MapControl_MapHolding; }
protected override void OnAttached() { mapView = Control as MKMapView; if (mapView == null) { throw new NotSupportedException(Control.GetType() + " is not supported."); } behavior = (Element as Map)?.Behaviors?.OfType <ClickBehavior>()?.FirstOrDefault(); if (behavior == null) { return; } tapGesture = new UITapGestureRecognizer(recognizer => MapClicked?.Invoke(this, new MapClickedEventArgs( ConvertLocationToPosition(recognizer, mapView))) ) { NumberOfTapsRequired = 1, }; longPressGesture = new UILongPressGestureRecognizer(recognizer => { if (recognizer.State != UIGestureRecognizerState.Began) { return; } MapLongClicked?.Invoke(this, new MapClickedEventArgs( ConvertLocationToPosition(recognizer, mapView))); }); tapGesture.RequireGestureRecognizerToFail(longPressGesture); mapView.AddGestureRecognizer(longPressGesture); mapView.AddGestureRecognizer(tapGesture); }