我在一个while循环内运行一个处理程序,针对一个纬度/经度跨度,所以如果我在某个跨度之外,该地图将自动放大。我正在使用完全相同的设置,比较缩放级别而不是跨度,它工作得很好。这就是我正在做的...
public static void smoothZoomToSpan(final MapController controller,
MapView v, GeoPoint center, int latitudeSpan, int longitudeSpan) {
final Handler handler = new Handler();
final MapView mapView = v;
final int currentLatitudeSpan = v.getLatitudeSpan();
final int currentLongitudeSpan = v.getLongitudeSpan();
final int targetLatitudeSpan = latitudeSpan;
final int targetLongitudeSpan = longitudeSpan;
controller.animateTo(center, new Runnable() {
public void run() {
int curLatSpan = currentLatitudeSpan;
int curLngSpan = currentLongitudeSpan;
int tarLatSpn = targetLatitudeSpan;
int tarLngSpan = targetLongitudeSpan;
long delay = 0;
while ((curLatSpan - 6000 > tarLatSpn)
|| (curLngSpan - 6000 > tarLngSpan)) {
Log.e("ZoomIn", "Thinks we should!");
handler.postDelayed(new Runnable() {
@Override
public void run() {
controller.zoomIn();
Log.e("ZoomIn", "Zoomed");
}
}, delay);
delay += 150; // Change this to whatever is good on the
// device
}
Log.e("ZoomIn", "completed");
}
});
}
执行此代码后,Logcat 输出“认为我们应该!” (基本上淹没原木)无休止。但它从来没有对我的处理程序做任何事情......实际的 zoomIn 调用永远不会触发,它只会永远循环,直到我强制关闭我的应用程序。我究竟做错了什么?