下面的代码执行以下操作:选中“焦点”复选框时,地图将动画到地图中的单个叠加层项目中。有一个问题:当我拖动地图以使地图在我选中复选框时仍在移动时,检查没有视觉效果。有任何想法吗?
List<Overlay> mapOverlays;
Drawable drawable;
AssetMarkersOverlay itemizedOverlay;
private CheckBox autofocusCheckBox;
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.getController().setZoom(4);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.bubble_blue);
itemizedOverlay = new AssetMarkersOverlay(drawable);
String assetName = "TEST";
int lat = 3;
int lon = 3;
ArrayList<GeoPoint> geoPointList = new ArrayList<GeoPoint>();
GeoPoint point = new GeoPoint(lat, lon);
autofocusCheckBox = (CheckBox) findViewById(R.id.showInMap);
autofocusCheckBox.setTag(point);
autofocusCheckBox
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked && buttonView.getTag() != null) {
focusAsset((GeoPoint) buttonView.getTag());
}
}
});
geoPointList.add(point);
itemizedOverlay.addOverlay(lat, lon, assetName, assetName);
mapOverlays = mapView.getOverlays();
mapOverlays.clear();
mapView.postInvalidate();
mapOverlays.add(itemizedOverlay);
fitPoints(geoPointList, mapView);
mapView.postInvalidate();
}
private void focusAsset(GeoPoint point) {
mapView.requestFocus();
mapView.clearAnimation();
mapView.getController().stopAnimation(true);
mapView.getController().setZoom(14);
mapView.getController().animateTo(point);
mapView.postInvalidate();
}