1

双击时我需要缩放。为什么这不起作用?我研究了很长时间,没有任何结果。没有识别到​​触摸事件

public class MyMapActivity extends MapActivity implements OnGestureListener{
private MapView mapView;

@Override
public void onCreate(Bundle savedInstanceState) {

requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.mapView);
mGestureDetector = new GestureDetector(this,this);
detector.setOnDoubleTapListener(new OnDoubleTapListener(){
    @Override
public boolean onDoubleTap(MotionEvent e) {
 int x = (int)e.getX(), y = (int)e.getY();;  
 Projection p = map.getProjection();  
 map.getController().animateTo(p.fromPixels(x, y));
 map.getController().zoomInFixing(x, y);  
 return false;
}

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    return false;
}

    });
}
@Override
public boolean onTouchEvent(MotionEvent me) {
this.mGestureDetector.onTouchEvent(me);
return super.onTouchEvent(me); 
}
4

2 回答 2

2

请参阅教程,它有完整的如何或在此处此处查看有关 stackoverflow 的类似问题。

于 2012-10-28T05:31:12.130 回答
2

尝试查看MapView Ballons支持双击缩放等功能的库!它非常好,易于使用并与项目集成。MapView 气球

于 2012-10-28T06:43:20.947 回答