Callout being shown after zoom, even though I'm hiding it

3495
2
04-29-2015 10:18 PM
KeithTurner
New Contributor III

I have an onzoomlistener that hides the callout and requests data for the new map extent (a graphiclayer being populated from json).  The issue is that the callout is re-appearing after the zoom animation stops.  There does seem to be a reference to this in the docs - they say something along the lines of during an animation the callout is hidden and shown again after the animation stops.  This appears to be a bug, as I am making a call to hide the callout, but it shows it again.  I want it to stay off after a zoom.  The graphic which the callout is associated with may no longer be there after a zoom.

Putting a callout.hide() in either the preAction and postAction of the onzoomlistener has no effect.

Is there a way to do this, or a workaround?

Keith

0 Kudos
2 Replies
KeithTurner
New Contributor III

I was trying a couple other things that I didn't expect to work and found something that almost works.  If I do a callout.animatedHide() in the postAction of the onZoomListener, it does hide the callout.

But, it still does the hide/show first.  So, do something to make the map zoom, it hides the callout, it zooms, it shows the callout, then the animatedhide hides the callout again.

Definitely not optimal, but an improvement.  Still looking for a good workaround.

Keith

0 Kudos
ShellyGill1
Esri Contributor

Hi Keith,

I think the problem is that if you try and hide the callout within the zoom listener, it's too late - the MapView has already taken care of temporarily hiding the callout (to prevent flickering and make it easier to use gestures on the map without the callout in the way). Check the MapView.getCallout().isShowing() - it will be false already. You can get in earlier however by using the MapOnTouchListener:

MapOnTouchListener | ArcGIS Android 10.2.5 API

Try setting one of these on your MapView, and then in the generic onTouch event, try your call to hide the callout there, e.g. :

// In onCreate or somewhere suitable:

MapTouchListener mMapTouchListener = new MapTouchListener(getApplicationContext(), map);

map.setOnTouchListener(mMapTouchListener);

// Define the touch listener class

class MapTouchListener extends MapOnTouchListener {

  public MapTouchListener(Context context, MapView view) {

  super(context, view);

  }

  @Override
  public boolean onTouch(View v, MotionEvent event) {

  Log.i(TAG, "onTouch Before getCallout.hide: " + map.getCallout().isShowing());

  map.getCallout().hide();

  Log.i(TAG, "onTouch After getCallout.hide: " + map.getCallout().isShowing());

  return super.onTouch(v, event);

  }

}

This should kick in before the zoom handling, so the callout will already be hidden before the MapView checks if it's shown to do the auto-hiding.

Hope this helps,

0 Kudos