Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

double click/tap map zoom (Android) [duplicate]

Possible Duplicate:
Double Tap -> Zoom on Android MapView?

I have an Activity that extends MapActivity. I use Google Maps.
I need to zoom in by double clicking or double tapping.

Can someone help me with this?

I have already looked at the below, but they are not what I'm looking for.

Double Tap -> Zoom on Android MapView?

Fling gesture detection on grid layout

I realized that onTouchListener is being called only once, why is that so?

// set Gesture
detector = new GestureDetector(new GestureReactor());
mapView.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        System.out.println("Inside onTouch");
        return detector.onTouchEvent(event);
    }
});

I have private class:

private class GestureReactor extends SimpleOnGestureListener {
    @Override
    public boolean onDoubleTap(MotionEvent e) {
        System.out.println("inside onDouble");
        controller.zoomInFixing((int) e.getX(), (int) e.getY());
        return super.onDoubleTap(e);
    }
}

and

private GestureDetector detector;
like image 815
Varand Pezeshkian Avatar asked Dec 15 '10 20:12

Varand Pezeshkian


Video Answer


1 Answers

Since you want a copy-paste answer, look here.

EDIT:

In my public class MainMap extends MapActivity I have a field called private MyMapView mv;

I then made a class which extends MapView like this: public class MyMapView extends MapView.

So you just make a new class which extends MapView, copy-paste the code you found in the link in there, and use your new class in your Activity which extends MapActivity.

like image 196
iarwain01 Avatar answered Sep 30 '22 08:09

iarwain01