Lect0r / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

double tap should zoom in #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A double tap should zoom into the place where the double tap occurs. This
is useful because the "+" button will always only zoom into the center of
the map.

Original issue reported on code.google.com by misc2...@danielnaber.de on 25 Apr 2010 at 12:36

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 26 Apr 2010 at 7:16

GoogleCodeExporter commented 9 years ago
I've done this.

In OpenStreetMapView.java:

       /**
     * Zooms in at pixel centered at touchX, touchY
     * @param touchX
     * @param touchY
     */
    public void zoomInCentered(float touchX, float touchY) {
        GeoPoint center = this.getProjection().fromPixels(touchX, touchY);
        setMapCenter(center);
        zoomIn();
    }

and then hooking up the method:

private class OpenStreetMapViewDoubleClickListener implements 
GestureDetector.OnDoubleTapListener {
        public boolean onDoubleTap(MotionEvent e) {
            Log.i("double tap", "Double tap! " + e);
            OpenStreetMapView.this.zoomInCentered(e.getX(), e.getY());
            return true;
        }
        public boolean onDoubleTapEvent(MotionEvent e) {
            return false;
        }
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return false;
        }
    }

in variable fields:
    protected final GestureDetector.OnDoubleTapListener doubleTap = new OpenStreetMapViewDoubleClickListener();

In constructor:

    this.mGestureDetector.setOnDoubleTapListener(doubleTap);

Works fine.

Original comment by nicholas...@gmail.com on 23 Jul 2010 at 8:22

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r303.

Original comment by neilboyd on 26 Jul 2010 at 10:56

GoogleCodeExporter commented 9 years ago
It should really fix the point that was double-tapped, not center on it - 
that's what Google Maps does. But this is good enough for a start.

Original comment by neilboyd on 26 Jul 2010 at 10:58