tanweijiu / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

Hide Bubble onScroll... #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Mathieu,

I hope this is not a stipid question...
How can I close/hide/dismiss a bubble when scrolling?
I want the bubble to stay centered and open when zooming in but I want it to 
close when scolling the map...
I did try the following code in the setMapListener onScroll Event which returns 
as a java NullPointerException.

try {
   if (mMapView.findViewById(R.layout.bonuspack_bubble).getVisibility() == View.VISIBLE) {
      mMapView.findViewById(R.layout.bonuspack_bubble).setVisibility(View.GONE);
}
} catch (Exception e) {
   Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
}

Thanks!

Original issue reported on code.google.com by TobiSc...@gmail.com on 18 Mar 2014 at 7:38

GoogleCodeExporter commented 9 years ago
Interesting. 

I imagine that R.layout.bonuspack_bubble is not set as the id of the bubble 
mView, this is just the resource id of its layout. 
So mMapView.findViewById(R.layout.bonuspack_bubble) do not find it and returns 
null. 

The issue with the current Marker/Bubble implementation is that it's not easy 
to know which bubble is opened. 

You could call Marker.hideInfoWindow(), but this implies to call it on every 
Marker added to overlays - not necessarily easy/clever. 

An other idea: sub-class the MarkerInfoWindow, then "do something else": 
- in the constructor you could set a specific ID (or a Tag) to the mView, and 
use your method (or findViewWithTag) in the mapListener. 

- in onOpen and onClose, you could keep track of opened bubble in a static 
member of the class. And use this static member in the mapListener. 

Don't hesitate to share your thoughts. Knowing easily which bubble (from which 
marker) is opened is definitely something useful, that has been lost when 
moving from ItemizedOverlayWithBubble to Marker, and that I would like to 
restore as a core feature. 

Original comment by mathieu....@gmail.com on 18 Mar 2014 at 10:38

GoogleCodeExporter commented 9 years ago
Big improvements in v4.4: 
InfoWindow.closeAllInfoWindowsOn, InfoWindow.getOpenedInfoWindowsOn added
Marker.isInfoWindowShown now correct even when the InfoWindow is shared. 

Original comment by mathieu....@gmail.com on 10 Apr 2014 at 10:21