| 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 |
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]
Jan 9, 2014
Approved - same error here
May 26, 2014
error reproduced.
Sep 11, 2014
(No comment was entered for this change.)
Status:
Acknowledged
Labels: Internal-17477240
Oct 11, 2014
same problem here.
Apr 14, 2015
Run into the same issue.
May 3, 2015
This should be a P1 bug from my perspective. Not sure why it stay forever.
Jul 8, 2015
Same problem here.
Jul 13, 2015
Same problem here. Please fix
Jul 13, 2015
Same problem here!
Sep 29, 2015
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
@Arvis, you just explained the bug, InfoWindows shouldn't be reopened if it is already visible.
Sep 29, 2015
@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
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
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 |