My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 5408: Bug: Calling Marker.showInfoWindow() in onMarkerClick(Marker) and returning true causes Marker.isInfoWindowShown to still return false on subsequent marker clicks
45 people starred this issue and may be notified of changes. Back to list
Status:  Acknowledged
Owner:  ----


Sign in to add a comment
 
Reported by [email protected], May 17, 2013
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.

Example code:
public class MainActivity extends Activity implements OnMarkerClickListener {

	private static final String TAG = "InfoWindowsBug";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		GoogleMap map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
		map.setOnMarkerClickListener(this);
		map.addMarker(new MarkerOptions().position(new LatLng(0d, 0d)).title("something"));
	}

	@Override
	public boolean onMarkerClick(Marker marker) {
		Log.v(TAG, "before: " + marker.isInfoWindowShown());
		if(marker.isInfoWindowShown()) {
			marker.hideInfoWindow();
		} else {
			marker.showInfoWindow();
		}
		Log.v(TAG, "after: " + marker.isInfoWindowShown());
		return true;
	}
}

I realize this probably looks like I'm needlessly re-implementing the default behavior of toggling info window visibility when a marker is clicked, but this is needed for a more complex scenario  (which would be inappropriate to post in full here) to implement a user's feature request in my clustering library, see https://github.com/twotoasters/clusterkraf/issues/10

Steps to repeat  issue
1 . Run the above example code
2. Tap the only marker on the map
3. Tap the only marker on the map again

Expected results 
Logcat output
InfoWindowsBug: before: false
InfoWindowsBug: after: true
InfoWindowsBug: before: true
InfoWindowsBug: after: false

User experience
After #2, info window shown
After #3, info window not shown

Actual results
Logcat output
InfoWindowsBug: before: false
InfoWindowsBug: after: true
InfoWindowsBug: before: false
InfoWindowsBug: after: true

User experience
After #2, info window shown
After #3, info window shown


*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************
Nov 11, 2013
#1 [email protected]
This behavior is difficult to work with for apps that want to work with multiple markers. Tap on info window calls doesn't always delete the inforWindow as expected, and tap away creates unnecessary marker. Please advise. 
Jan 9, 2014
#2 [email protected]
Approved - same error here
May 26, 2014
#3 [email protected]
error reproduced.
Sep 11, 2014
Project Member #4 [email protected]
(No comment was entered for this change.)
Status: Acknowledged
Labels: Internal-17477240
Oct 11, 2014
#5 [email protected]
same problem here.
Apr 14, 2015
#6 [email protected]
Run into the same issue.
May 3, 2015
#7 [email protected]
This should be a P1 bug from my perspective. Not sure why it stay forever.
Jul 8, 2015
#8 [email protected]
Same problem here.
Jul 13, 2015
#9 [email protected]
Same problem here. Please fix
Jul 13, 2015
#10 [email protected]
Same problem here!
Sep 29, 2015
#12 [email protected]
Actually it is not a bug!

According to the documents of Google Maps for Android V2:
"Only one info window is displayed at a time. If a user clicks on another marker, the current info window will be hidden and the new info window will be displayed."

The second click on same marker is just like any click on any other marker. So the Infowindows is immediately closed. Infowindows is already hidden for the marker at that time when overridden method onMarkerClick() have been called. That's why isInfoWindowShown() method returns correct value. And you just reopened InfoWindows once again.
Sep 29, 2015
#13 [email protected]
@Arvis, you just explained the bug, InfoWindows shouldn't be reopened if it is already visible.
Sep 29, 2015
#14 davemac327
@Arvis, once opened, the info window stays open no matter how many times you click on the marker. That's a bug.
Sep 29, 2015
#16 [email protected]
That's not the bug according to the documentation!
We may consider that as bug from usage perspective.

@Override
public boolean onMarkerClick(Marker marker)
From business logic this is not the proper place to call marker.isInfoWindowShown() function because it's always false as supposed to be. When OnMarkerClickListener call this function any opened InfoWindow have been already hidden by Map framework itself (so status 'false' technically is correct).

You can check that by example modifying overridden 'onMarkerClick' method
to open InfoWindows on even cliks only. On odd cliks - do nothing and see InfoWindows closes automatically by framework without explicit call to marker.hideInfoWindow();

To get actual InfoWindow status you should call 'marker.isInfoWindowShown' from another events or functions by keeping local references to any markers on map.

  
May 16, 2016
#18 [email protected]
I agree this seems like expected behavior. All the correct callback are fired: IE the close listener for the InfoWindow. Seems like a good framework.
Sign in to add a comment

Powered by Google Project Hosting