mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

onMarkerClick is only called after the second click

Open SimonPSH opened this issue 9 years ago • 2 comments

Platform: Android 6.0.1 Mapbox SDK version: 5.0.2

Steps to trigger behavior

  1. Add an OnMarkerClick event listener to your mapboxmap
  2. Create a marker on your map with a title and snippet
  3. Click on marker

Expected behavior

OnMarkerClick is called immediately

Actual behavior

The info bubble is shown on the first click. Then on the second click, the bubble is hidden and OnMarkerClick is called

SimonPSH avatar Apr 27 '17 17:04 SimonPSH

Google Pixel Android 7.1.2 Mapbox 5.0.2

I'm seeing the same issue even without a snippet/title. But i've noticed when hooking OnMarkerViewClickListener from the maps MarkerViewManager it works as expected.

Maybe you could use it for now @SimonPSH.

mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(this);

DejanRistic avatar May 01 '17 21:05 DejanRistic

As mentioned by @DejanRistic, you probably need to hook into OnMarkerViewClickListener. When it comes to firing a click event when the InfoWindow is open, this is considered a worked as designed to allow customizing the click event occurring on the Marker. For example if you return true, the infowindow wouldn't be deselected. You can check the state of the InfoWindow with marker.isInfoWindowShown().

Let us know if you have any more questions or suggestions, but closing this for now.

tobrun avatar May 03 '17 10:05 tobrun