<?xml version="1.0" encoding="utf-8"?> <resources> <calloutViewStyle titleTextColor="#000000" titleTextSize="10" titleTextStyle="0" titleTextTypeFace="0" backgroundColor="#ffffff" backgroundAlpha="255" frameColor="#000000" flat="true" anchor="5" /> </resources>
package com.esri.android.calloutcentertest;  import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; import com.esri.android.map.Callout; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer; import com.esri.android.map.event.OnSingleTapListener; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference;  public class CalloutCenterTestActivity extends Activity {  MapView map = null;   /** Called when the activity is first created. */  public void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.main);    // Retrieve the map and initial extent from XML layout   map = (MapView)findViewById(R.id.map);   map.addLayer(new ArcGISDynamicMapServiceLayer(    "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")   );     // The map.getCallout().setCoordinates() / map.centerAt() bug.   Toast.makeText(this, "TAP SCREEN TO SHOW ESRI HQ", Toast.LENGTH_LONG).show();   final Context ctx = this;   map.setOnSingleTapListener(new OnSingleTapListener() {    private static final long serialVersionUID = 5173550791541184304L;     public void onSingleTap(float x, float y) {     Toast.makeText(ctx, "SHOWING ESRI HQ IN CALLOUT", Toast.LENGTH_SHORT).show();          // Create a point for ESRI HQ in WebMercator coordinate system.     Point esri4326 = new Point(-117.1957, 34.05691);     Point esri102100 = (Point) GeometryEngine.project(      esri4326,      SpatialReference.create(4326),      SpatialReference.create(102100)     );      // Construct the Callout content.     TextView textView = new TextView(ctx);     textView.setText("ESRI HQ");          // Show the callout at the correct location.     Callout callout = map.getCallout();      callout.setContent(textView);     callout.setCoordinates(esri102100);     callout.setStyle(R.xml.calloutstyle);     callout.refresh();     callout.show();          // The map pans to ESRI HQ but the callout stays behind!     map.centerAt(esri102100, true);          // If the user pans the map interactively, the callout corrects itself.    }   } );  }   protected void onPause() {   super.onPause();   map.pause();  }   protected void onResume() {   super.onResume();   map.unpause();  } }Solved! Go to Solution.
map.centerAt(esri102100, false);
callout.setContent(body); callout.setStyle(R.xml.calloutxml); callout.setCoordinates(centerPT); map.zoomin(); map.zoomToResolution(centerPT, 100); callout.show();
// Show the callout at the correct location. Callout callout = mMapView.getCallout(); callout.setContent(textView); callout.setCoordinates(point); callout.setStyle(R.xml.callout); // @WORKAROUND - Force map to zoom in mMapView.zoomToResolution(point, 100); callout.refresh(); callout.show();
