How to handle click event in Google Xamarin map component for ios

I am using the xagarin googel map component to develop google map application in iOS. When the user touches the map, I want to get the location of the map that the user is touching. any idea.

early.

+3
source share
2 answers

MapView has a tapped event, as well as several Touches * events

mapView.Tapped += delegate(object sender, GMSCoordEventArgs e) {
  Console.WriteLine("tapped at " + e.Coordinate.Latitude + "," + e.Coordinate.Longitude);
};
+3
source

GoogleMap: marker click event with and without ClusterManager

For Xamarin.iOS, the Google map will use the TappedMarker event. It can be used in three different ways.


The first implementation method:


MapView didTapMarker. GMUClusterManager,

    [Export("mapView:didTapMarker:")]
    public bool TappedMarker(MapView mapView, Marker marker)
    {
        var id = marker.Title;
        Console.WriteLine(id);

        return true;
    }

:


GoogleMap TappedMarker

    this.GMapView.TappedMarker = (map, marker) =>
    {
        var id = marker.Title;
        Console.WriteLine(id);

        return true;
    }

:


GoogleMap TappedMarker.

    this.GMapView.TappedMarker = markerClicked;

markerClicked

    bool markerClicked(MapView map, Marker marker)
    {
        var id = marker.Title;
        Console.WriteLine(id);

        return true;
    }
0

All Articles