Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

infoWindow (Google Maps) catching an event of closing the window

What's your ways of triggering action when infowindow is being closed? I can't find any listeners for that. I was thinking about running some background Runnable checking if marker.isInfoWindowShown().

What I wish to do - display button over my map, when user clicks point (infoWindow appears), there's also this button on the bottom of the screen. When infoWindow dissapears, the button is also no longer visible.

Any hints which listeners I should read about?

like image 617
wtk Avatar asked Sep 12 '13 00:09

wtk


2 Answers

Currently in google maps android api, there is no direct listener corresponding to the closing of a marker's infowindow. But you can achieve the required functionality in your app, by checking for the below events that would act as the reasons for closing an infowindow:

1, GoogleMap.OnMapClickListener : When a user taps on the map, any currently visible infowindow will be closed. So you can add a logic in this listener for executing the functionality required when infowindow is closed

2, marker.hideInfoWindow () : Another reason why an infowindow will be closed will be if you call the hideinfowindow method on a marker. If you call this method, then you should add the functionality required when infowindow is closed, immediately after calling this method.

like image 64
tony m Avatar answered Sep 23 '22 15:09

tony m


Well I am too late to answer this but now it is possible to know when the infowindow of google map get closed by using the following method.

 @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        mMap.setOnInfoWindowCloseListener(new GoogleMap.OnInfoWindowCloseListener() {
            @Override
            public void onInfoWindowClose(Marker marker) {
               //hide or do something you want
            }
        });
}
like image 34
Umar Ata Avatar answered Sep 20 '22 15:09

Umar Ata