mchristie
mchristie

Reputation: 241

Second tap/click on marker doesn't call OnMarkerClickListener

I've added an OnMarkerClickListener to my map. When I tap on a marker, the OnMarkerClickListener gets invoked and displays an AlertDialog. But, if I cancel out of the AlertDialog and tap on the same marker a second time, the OnMarkerClickListener isn't called. Here's my OnMarkerClickListener:

googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

  @Override
  public boolean onMarkerClick(final Marker marker) {

    AlertDialog.Builder builder = new AlertDialog.Builder(
        DirectionsActivity.this);
    builder.setMessage(marker.getSnippet());
    builder.setTitle(marker.getTitle());
    builder.setPositiveButton("Open in Google Maps",
        new OnClickListener() {

          // ...
          }
        });

    builder.setNegativeButton("Cancel", null);

    AlertDialog dialog = builder.create();
    dialog.show();

    return false;
  }
});

Simply moving or zooming the map allows me to make an additional click on the same marker. Because of this, if my OnMarkerClickListener.onMarkerClick returns true then the default handling, which includes centering the map on the clicked marker, is executed and I can make a second click on the same marker, but a third and subsequent clicks don't do anything. So the problem seems to be that a click on the same marker isn't being recognized until the map zoom or center changes.

I'm not doing anything special with my markers except that I do have custom icons derived from bitmaps.

Is anyone else having this problem? Anything I should check that I might be doing wrong? Or is this a known issue?

Upvotes: 3

Views: 2045

Answers (2)

Mailis Toompuu
Mailis Toompuu

Reputation: 1729

In the 'onMarkerClick' method, set return value to 'true'.

Upvotes: 0

mchristie
mchristie

Reputation: 241

Just to close the loop here, turns out this is a bug. bbalazs created a bug report here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4829 but was merged in as a duplicate of this bug report: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4760

You can vote on http://code.google.com/p/gmaps-api-issues/issues/detail?id=4760 by clicking on its star icon.

Upvotes: 2

Related Questions