开发者

google maps in android

I am a new user of google maps API in android OS. I have made a small application in which i am using google maps. I want to add a functionality that when i double click (multi touch) on a map the map should zoom in. IS there anybody who has an idea how to do this or if it is possible please p开发者_运维问答rovid a code example. Thanks in advance.

BR, SilentCoders


I've done something like this in an app using maps api. Although I did this in an overlay item, the principle should be the same.

You could try using TouchListener and GestureDetector to detect the touch events and such.

Note that this is not all actual working code, you need to adopt it so it fits into your implementation.

...
class MyDetector extends SimpleOnGestureListener {
    @Override
    public boolean onDoubleTap(MotionEvent event) {
        mapView.getController().zoomInFixing((int) event.getX(), (int) event.getY());
        return super.onDoubleTap(
    }
}


// maybe do this in your init or something
GestureDetector gDetector = new GestureDetector(new MyDetector());
mapView.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return gDetector.onTouchEvent(event);
    }
});

Something like that "should" work :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜