BSavaliya BSavaliya - 2 months ago 17x
Android Question

How to get click event of marker using MapBox SDK?

I am using MapBox SDK for offline map I have added multiple markers on map,
how to get click event for markers.
Is there any way to get click event of marker?


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);
        itemizedIconOverlayGT = new ItemizedIconOverlay(activity, alMarkerGT,
                new OnItemGestureListener<Marker>() {

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

                    public boolean onItemLongPress(int index, Marker item) {
                        return false;

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