Reputation: 2340
I was trying to close the default infowindow in the android map.
I used .hideInfoWindow()
but nothing appends.
Thanks.
Upvotes: 13
Views: 12992
Reputation: 11
Setting the pin title and snippet to null, will result in no info window being displayed. This shall cover both cases when selecting and clicking a pin.
Upvotes: 0
Reputation: 1730
Change the return statement
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
(to)
@Override
public boolean onMarkerClick(Marker marker) {
return true;
}
Upvotes: 16
Reputation: 411
Use
mapa.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
marker.hideInfoWindow();
}
});
I hope that helps.
Upvotes: 11
Reputation: 61
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;
}
}
}
Upvotes: 6