我是新手 Android 开发人员。我正在开发一个使用 GoogleMaps 的应用程序。我必须在 GoogleMaps 中实现双击缩放。当我双击地图时,它应该放大。如果可能,请提供示例代码。
我已经编写了以下代码,但我不知道要添加什么。
public class Maps extends MapActivity implements OnGestureListener, OnDoubleTapListener {
private GestureDetector detector;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// MapViewer mapViewer = new MapViewer(null, null);
MapView mapView = (MapView) findViewById(R.id.mapview);
detector = new GestureDetector(this, this);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
public boolean onDoubleTap(MotionEvent e) {
mapView.getController().zoomIn();
return false;
}
public boolean onDoubleTapEvent(MotionEvent e) {
return false;
}
public boolean onSingleTapConfirmed(MotionEvent e) {
return false;
}
public boolean onDown(MotionEvent e) {
return false;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
public void onLongPress(MotionEvent e) {
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
public void onShowPress(MotionEvent e) {
}
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
}