How to get click event of marker using MapBox SDK?

I got the solution for marker click event in mapbox using a functionality provided by mapbox sdk called ItemizedIconOverlay.

I have done like following :

   public void placeGTMarker() {
        alMarkerGT = new ArrayList<Marker>();
        marker = new Marker("my Marker", "", latLng);
        marker.setMarker(activity.getResources()
                .getDrawable(R.drawable.map_pin));
        mv.addMarker(marker);
        alMarkerGT.add(marker);
        itemizedIconOverlayGT = new ItemizedIconOverlay(activity, alMarkerGT,
                new OnItemGestureListener<Marker>() {

                    @Override
                    public boolean onItemSingleTapUp(int index, Marker item) {
                        return false;
                    }

                    @Override
                    public boolean onItemLongPress(int index, Marker item) {
                        return false;
                    }
                });
        mv.addItemizedOverlay(itemizedIconOverlayGT);
    }

We can perform any event on onItemSingleTapUp for single click and for long click we can use onItemLongPress method.

I have used in my application and it works great


You can set a MarkerClickListener on the MapboxMap

map.setOnMarkerClickListener(this);

and then have your class/activity/fragment implement MapboxMap.OnMarkerClickListener

@Override
public boolean onMarkerClick(@NonNull Marker marker) {
    return true;
}