解决方法
我也一直在寻找一个“完成拖曳”解决方案,以便在地图结束移动之后的时刻检测地图中心.我没有找到它,所以我做了这个简单的实现,工作正常:
private class MyMapView extends MapView { private GeoPoint lastMapCenter; private boolean isTouchEnded; private boolean isFirstComputeScroll; public MyMapView(Context context,String apiKey) { super(context,apiKey); this.lastMapCenter = new GeoPoint(0,0); this.isTouchEnded = false; this.isFirstComputeScroll = true; } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) this.isTouchEnded = false; else if (event.getAction() == MotionEvent.ACTION_UP) this.isTouchEnded = true; else if (event.getAction() == MotionEvent.ACTION_MOVE) this.isFirstComputeScroll = true; return super.onTouchEvent(event); } @Override public void computeScroll() { super.computeScroll(); if (this.isTouchEnded && this.lastMapCenter.equals(this.getMapCenter()) && this.isFirstComputeScroll) { // here you use this.getMapCenter() (e.g. call onEndDrag method) this.isFirstComputeScroll = false; } else this.lastMapCenter = this.getMapCenter(); } }
就这样,我希望它有帮助! O /