views:

93

answers:

1

Hello friends, 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 provid a code example. Thanks in advance.

BR, SilentCoders

A: 

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 :)

Tomas
Thank you Tomas for your reply. Could you please provide lilbit more help. Do i need to adopt GestureDetector code or onDoubleTap code? Can i add this code in my activity class? Sorry it is a silly question but as u know i am a new android developer. Can u provide some code?BR,Siletcoders
SilentCoder