I was trying to close the default infowindow in the android map.
I used .hideInfoWindow()
but nothing appends.
Thanks.
Change the return statement
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
(to)
@Override
public boolean onMarkerClick(Marker marker) {
return true;
}
I assume you want to close the infowindow when you click the marker for the second time. It seems you need to keep track of the last clicked marker. I can't get it to work by simply checking if the clicked marker is currently shown and then close it, but this works nicely.
private Marker lastClicked;
private class MyMarkerClickListener implements OnMarkerClickListener {
@Override
public boolean onMarkerClick(Marker marker) {
if (lastClicked != null && lastClicked.equals(marker)) {
lastClicked = null;
marker.hideInfoWindow();
return true;
} else {
lastClicked = marker;
return false;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With