Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3938468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:11:18+00:00 2026-05-20T00:11:18+00:00

I have a MapView in an activity and it works fine, the map shows,

  • 0

I have a MapView in an activity and it works fine, the map shows, and it responds to taps, and I can extract the location easily. However this handler is also responding to the pinch-zoom, so if a user tries to pinch-zoom, the app responds as if they tapped (and it’s very confusing for them).

How can I respond to taps on a MapView and only pick up single-taps, specifically ignoring pinch-zoom and double-taps?

Do I need to use OnTouchEvent() instead of OnTap()? If so how do I distinguish between the different touch events, and how do I access the GeoPoint?

Here’s the code from inside my MapActivity:

class MapOverlay extends com.google.android.maps.Overlay
{
    @Override
    public boolean onTap(GeoPoint p, MapView map)
    {
        if ( p!=null )
        {
            // Do stuff with the geopoint
            return true;                                 // We handled the tap
        }
        else
        {
            return false;                                // We didn't handle the tap
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:11:18+00:00Added an answer on May 20, 2026 at 12:11 am

    After much head-scratching and trying various approaches, this one is working well so far. The code follows the motion events. When we get an ACTION_DOWN event, it marks the isPinch flag as false (we don’t know if it’s a pinch or not yet), but as soon as we get a touch event (i.e. ACTION_MOVE) involving two fingers, isPinch is set to true, and so when the onTap() event fires, it can see if there was a pinch or not.

    class MapOverlay extends com.google.android.maps.Overlay
    {
    private boolean   isPinch  =  false;
    
    @Override
    public boolean onTap(GeoPoint p, MapView map){
        if ( isPinch ){
            return false;
        }else{
            Log.i(TAG,"TAP!");
            if ( p!=null ){
                handleGeoPoint(p);
                return true;            // We handled the tap
            }else{
                return false;           // Null GeoPoint
            }
        }
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent e, MapView mapView)
    {
        int fingers = e.getPointerCount();
        if( e.getAction()==MotionEvent.ACTION_DOWN ){
            isPinch=false;  // Touch DOWN, don't know if it's a pinch yet
        }
        if( e.getAction()==MotionEvent.ACTION_MOVE && fingers==2 ){
            isPinch=true;   // Two fingers, def a pinch
        }
        return super.onTouchEvent(e,mapView);
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having awful problems with this. I have a MapView, in my activity I
I have two OverlayItem's on a MapView. How can I draw a route between
Is there a way to start an activity from a view? I have this
I have a mapView activity that has a LocationListener registered to check for a
I have this textbox in the other activity and a button which leads to
I have this layout in xml. And when I run the activity at the
In my application i have used mapview. On particular place i can put annotation.
Is there a way to have the MapView not show my current location? I'm
Possible Duplicate: Double Tap -> Zoom on Android MapView? I have an Activity that
I have a problem that I can't solve... In my Activity, I instantiate a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.